public class Interpreter extends FleetTwoFleet implements Parser.FleetWithDynamicShips {
+ /** used to allocate serial numbers; see InterpreterDestination for further detail */
+ int maxAllocatedDestinationSerialNumber = 0;
+
private InterpreterShip debugShip = null;
private BlockingQueue<BitVector> debugStream = new LinkedBlockingQueue<BitVector>();
private HashMap<String,InterpreterShip> ships = new HashMap<String,InterpreterShip>();
// Instruction Encoding /////////////////////////////////////////////////////////////////////////
public BitVector getDestAddr(Path path) {
- long ret = ((InterpreterDestination)path.getDestination()).addr;
+ long ret = ((InterpreterDestination)path.getDestination()).getSerialNumber();
BitVector sig = path.getSignal();
BitVector bv = new BitVector(DISPATCH_PATH.valmaskwidth+1);
bv.set(ret);
abstract class InterpreterDestination extends Destination {
- private static int max_dest = 0;
-
- int addr;
-
- private boolean isInstructionDestination;
-
- public InterpreterDestination(InterpreterDock d, boolean isInstructionDestination) {
+ public InterpreterDestination(InterpreterDock d) {
super(d);
- this.isInstructionDestination = isInstructionDestination;
- synchronized(InterpreterDestination.class) {
- this.addr = max_dest;
- max_dest++;
+ synchronized(d.getInterpreter()) {
+ this.serialNumber = d.getInterpreter().maxAllocatedDestinationSerialNumber++;
}
}
public abstract void addDataFromFabric(Packet packet);
public abstract String toString();
+ /**
+ * The Fleet instruction encoding mechanism assumes that each
+ * source->dest path can be turned into a bitstring, and that the
+ * bitstring gives sufficient information to route the packet.
+ * Therefore, the interpreter assigns a "serial number" to every
+ * InterpreterDestination in a fleet and uses the serial number
+ * of the destination as the path.
+ */
+ private int serialNumber;
+ int getSerialNumber() { return serialNumber; }
}
// Destinations //////////////////////////////////////////////////////////////////////////////
/** includes the epilogue fifo */
- public InterpreterDestination instructionDestination = new InterpreterDestination(this, true) {
+ public InterpreterDestination instructionDestination = new InterpreterDestination(this) {
public String toString() { return getDock()+":i"; }
public void addDataFromFabric(Packet p) {
if (p.isToken()) {
}
}
};
- public InterpreterDestination dataDestination = new InterpreterDestination(this, false) {
+ public InterpreterDestination dataDestination = new InterpreterDestination(this) {
public String toString() { return getDock()+""; }
public void addDataFromFabric(Packet packet) { dataPackets.add(packet); }
};