From 66fddc1edfcfa1fa63b7a8e94f9cda45ac78d715 Mon Sep 17 00:00:00 2001 From: megacz Date: Wed, 7 Jan 2009 19:36:18 -0800 Subject: [PATCH] move InterpreterDestination serial number into the Interpreter class --- .../berkeley/fleet/interpreter/Interpreter.java | 5 +++- .../fleet/interpreter/InterpreterDestination.java | 24 +++++++++++--------- .../fleet/interpreter/InterpreterDock.java | 4 ++-- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/edu/berkeley/fleet/interpreter/Interpreter.java b/src/edu/berkeley/fleet/interpreter/Interpreter.java index 438855b..752ac72 100644 --- a/src/edu/berkeley/fleet/interpreter/Interpreter.java +++ b/src/edu/berkeley/fleet/interpreter/Interpreter.java @@ -11,6 +11,9 @@ import edu.berkeley.fleet.util.*; 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 debugStream = new LinkedBlockingQueue(); private HashMap ships = new HashMap(); @@ -77,7 +80,7 @@ public class Interpreter extends FleetTwoFleet implements Parser.FleetWithDynami // 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); diff --git a/src/edu/berkeley/fleet/interpreter/InterpreterDestination.java b/src/edu/berkeley/fleet/interpreter/InterpreterDestination.java index 49b56a6..df86579 100644 --- a/src/edu/berkeley/fleet/interpreter/InterpreterDestination.java +++ b/src/edu/berkeley/fleet/interpreter/InterpreterDestination.java @@ -4,18 +4,10 @@ import java.util.*; 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++; } } @@ -23,4 +15,14 @@ abstract class InterpreterDestination extends Destination { 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; } } diff --git a/src/edu/berkeley/fleet/interpreter/InterpreterDock.java b/src/edu/berkeley/fleet/interpreter/InterpreterDock.java index f24bbdf..11774ef 100644 --- a/src/edu/berkeley/fleet/interpreter/InterpreterDock.java +++ b/src/edu/berkeley/fleet/interpreter/InterpreterDock.java @@ -51,7 +51,7 @@ class InterpreterDock extends FleetTwoDock { // 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()) { @@ -67,7 +67,7 @@ class InterpreterDock extends FleetTwoDock { } } }; - 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); } }; -- 1.7.10.4