projects
/
fleet.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d865b7c
)
add initial support for virtual destinations
author
adam
<adam@megacz.com>
Sat, 17 Feb 2007 08:40:21 +0000
(09:40 +0100)
committer
adam
<adam@megacz.com>
Sat, 17 Feb 2007 08:40:21 +0000
(09:40 +0100)
src/edu/berkeley/fleet/api/BenkoBox.java
patch
|
blob
|
history
src/edu/berkeley/fleet/api/Destination.java
[new file with mode: 0644]
patch
|
blob
src/edu/berkeley/fleet/api/Instruction.java
patch
|
blob
|
history
src/edu/berkeley/fleet/ies44/InstructionEncoder.java
patch
|
blob
|
history
src/edu/berkeley/fleet/interpreter/Interpreter.java
patch
|
blob
|
history
tests/alu2/simple-alu2-test.fleet
patch
|
blob
|
history
diff --git
a/src/edu/berkeley/fleet/api/BenkoBox.java
b/src/edu/berkeley/fleet/api/BenkoBox.java
index
1e93825
..
5a3d9dd
100644
(file)
--- a/
src/edu/berkeley/fleet/api/BenkoBox.java
+++ b/
src/edu/berkeley/fleet/api/BenkoBox.java
@@
-1,6
+1,7
@@
package edu.berkeley.fleet.api;
package edu.berkeley.fleet.api;
+import java.util.*;
-public abstract class BenkoBox {
+public abstract class BenkoBox extends Destination {
/** you should extend subclasses, not this class directly */
//FIXME
/** you should extend subclasses, not this class directly */
//FIXME
@@
-24,4
+25,10
@@
public abstract class BenkoBox {
public Outbox() { }
}
public Outbox() { }
}
+ /** get all destinations associated with this BenkoBox */
+ public Iterable<Destination> getDestinations() {
+ HashSet<Destination> self = new HashSet<Destination>();
+ self.add(this);
+ return self;
+ }
}
}
diff --git a/src/edu/berkeley/fleet/api/Destination.java
b/src/edu/berkeley/fleet/api/Destination.java
new file mode 100644
(file)
index 0000000..
8bf7270
--- /dev/null
+++ b/
src/edu/berkeley/fleet/api/Destination.java
@@ -0,0
+1,10
@@
+package edu.berkeley.fleet.api;
+
+public abstract class Destination {
+
+ Destination() { }
+
+ /** return the Ship to which this BenkoBox belongs */
+ public abstract Ship getShip();
+
+}
diff --git
a/src/edu/berkeley/fleet/api/Instruction.java
b/src/edu/berkeley/fleet/api/Instruction.java
index
5e3c106
..
5b89965
100644
(file)
--- a/
src/edu/berkeley/fleet/api/Instruction.java
+++ b/
src/edu/berkeley/fleet/api/Instruction.java
@@
-18,9
+18,9
@@
public abstract class Instruction {
public static class Executable extends Instruction {
public static class Executable extends Instruction {
- public final BenkoBox benkoBox;
- public final BenkoBox dest;
- public final int count;
+ public final BenkoBox benkoBox;
+ public final Destination dest;
+ public final int count;
public final boolean tokenIn;
public final boolean dataIn;
public final boolean tokenIn;
public final boolean dataIn;
@@
-30,15
+30,15
@@
public abstract class Instruction {
public final boolean recycle;
/** count=0 denotes a standing move */
public final boolean recycle;
/** count=0 denotes a standing move */
- public Executable(BenkoBox benkoBox,
- BenkoBox dest,
- int count,
- boolean tokenIn,
- boolean dataIn,
- boolean latch,
- boolean dataOut,
- boolean tokenOut,
- boolean recycle) {
+ public Executable(BenkoBox benkoBox,
+ Destination dest,
+ int count,
+ boolean tokenIn,
+ boolean dataIn,
+ boolean latch,
+ boolean dataOut,
+ boolean tokenOut,
+ boolean recycle) {
this.benkoBox = benkoBox;
this.dest = dest;
this.count = count;
this.benkoBox = benkoBox;
this.dest = dest;
this.count = count;
@@
-94,12
+94,12
@@
public abstract class Instruction {
}
public static class Literal extends Instruction {
}
public static class Literal extends Instruction {
- public final BenkoBox dest;
- protected Literal(BenkoBox dest) { this.dest = dest; }
+ public final Destination dest;
+ protected Literal(Destination dest) { this.dest = dest; }
public static class Absolute extends Literal {
public final long value;
public static class Absolute extends Literal {
public final long value;
- public Absolute(BenkoBox dest, long value) { super(dest); this.value = value; }
+ public Absolute(Destination dest, long value) { super(dest); this.value = value; }
public String toString() {
return value + ": sendto " + dest;
}
public String toString() {
return value + ": sendto " + dest;
}
@@
-108,7
+108,7
@@
public abstract class Instruction {
public static class Relative extends Literal {
/** value transmitted will be offset plus the address from which this instruction was loaded */
public final long offset;
public static class Relative extends Literal {
/** value transmitted will be offset plus the address from which this instruction was loaded */
public final long offset;
- public Relative(BenkoBox dest, long offset) { super(dest); this.offset = offset; }
+ public Relative(Destination dest, long offset) { super(dest); this.offset = offset; }
public String toString() {
String off = ""+offset;
if (offset > 0) off = "+"+off;
public String toString() {
String off = ""+offset;
if (offset > 0) off = "+"+off;
@@
-120,7
+120,7
@@
public abstract class Instruction {
/** address of CBD, relative to address that this instruction was loaded from */
public final long offset;
public final long size;
/** address of CBD, relative to address that this instruction was loaded from */
public final long offset;
public final long size;
- public CodeBagDescriptor(BenkoBox dest, long offset, long size) {
+ public CodeBagDescriptor(Destination dest, long offset, long size) {
super(dest); this.offset = offset; this.size = size; }
public String toString() {
String off = ""+offset;
super(dest); this.offset = offset; this.size = size; }
public String toString() {
String off = ""+offset;
diff --git
a/src/edu/berkeley/fleet/ies44/InstructionEncoder.java
b/src/edu/berkeley/fleet/ies44/InstructionEncoder.java
index
e8f38a3
..
0e9174d
100644
(file)
--- a/
src/edu/berkeley/fleet/ies44/InstructionEncoder.java
+++ b/
src/edu/berkeley/fleet/ies44/InstructionEncoder.java
@@
-6,7
+6,7
@@
import java.io.*;
public abstract class InstructionEncoder {
/** get the bits describing this box's location on the DESTINATION HORN */
public abstract class InstructionEncoder {
/** get the bits describing this box's location on the DESTINATION HORN */
- public abstract long getBoxAddr(BenkoBox box);
+ public abstract long getBoxAddr(Destination box);
/** get the bits describing this box's location on the INSTRUCTION HORN */
public abstract long getBoxInstAddr(BenkoBox box);
/** get the bits describing this box's location on the INSTRUCTION HORN */
public abstract long getBoxInstAddr(BenkoBox box);
@@
-91,7
+91,7
@@
public abstract class InstructionEncoder {
if (d instanceof Instruction.Executable) {
Instruction.Executable inst = (Instruction.Executable)d;
if (d instanceof Instruction.Executable) {
Instruction.Executable inst = (Instruction.Executable)d;
- BenkoBox dest = inst.dest;
+ Destination dest = inst.dest;
instr = dest==null ? 0 : (getBoxAddr(dest) << 1);
if (inst.count >= (1<<8))
throw new RuntimeException("count field must be less than 128");
instr = dest==null ? 0 : (getBoxAddr(dest) << 1);
if (inst.count >= (1<<8))
throw new RuntimeException("count field must be less than 128");
diff --git
a/src/edu/berkeley/fleet/interpreter/Interpreter.java
b/src/edu/berkeley/fleet/interpreter/Interpreter.java
index
16f36b8
..
d78be10
100644
(file)
--- a/
src/edu/berkeley/fleet/interpreter/Interpreter.java
+++ b/
src/edu/berkeley/fleet/interpreter/Interpreter.java
@@
-206,7
+206,7
@@
public class Interpreter extends Fleet {
public void writeInstruction(DataOutputStream os, Instruction d) throws IOException { iie.writeInstruction(os, d); }
private class InterpreterInstructionEncoder extends InstructionEncoder {
public void writeInstruction(DataOutputStream os, Instruction d) throws IOException { iie.writeInstruction(os, d); }
private class InterpreterInstructionEncoder extends InstructionEncoder {
- public long getBoxAddr(BenkoBox box) { return ((InterpreterBenkoBox)box).addr; }
+ public long getBoxAddr(Destination box) { return ((InterpreterBenkoBox)box).addr; }
public long getBoxInstAddr(BenkoBox box) { return ((InterpreterBenkoBox)box).instr_addr; }
public BenkoBox getBoxByAddr(long dest) {
for(Ship ship : Interpreter.this)
public long getBoxInstAddr(BenkoBox box) { return ((InterpreterBenkoBox)box).instr_addr; }
public BenkoBox getBoxByAddr(long dest) {
for(Ship ship : Interpreter.this)
diff --git
a/tests/alu2/simple-alu2-test.fleet
b/tests/alu2/simple-alu2-test.fleet
index
965d80a
..
9ca5d4d
100644
(file)
--- a/
tests/alu2/simple-alu2-test.fleet
+++ b/
tests/alu2/simple-alu2-test.fleet
@@
-22,8
+22,7
@@
Alu2.SUB: sendto alu.inOp;
Alu2.MIN: sendto alu.inOp;
Alu2.MAX: sendto alu.inOp;
Alu2.MIN: sendto alu.inOp;
Alu2.MAX: sendto alu.inOp;
-alu.in1: [*] take, deliver;
-alu.in2: [*] take, deliver;
-alu.inOp: [*] take, deliver;
-alu.out:
- [*] take, sendto debug.in;
+alu.in1: [*] take, deliver;
+alu.in2: [*] take, deliver;
+alu.inOp: [*] take, deliver;
+alu.out: [*] take, sendto debug.in;