public BitVector getDataLatch() { return dock.dataLatch; }
public Queue<BitVector> getDataDestPackets() {
Queue<BitVector> values = new LinkedList<BitVector>();
- for (Packet p : dock.dataDestination.packets) {
+ for (Packet p : dock.dataPackets) {
if (p.isToken())
continue;
values.add(p.getValue());
public Queue<Instruction> getInstructionsInFabric() {
Queue<Instruction> instr = new LinkedList<Instruction>();
- for (Packet p : dock.instructionDestination.packets) {
- if (p.isToken())
- continue;
-
- BitVector bv = p.getValue();
- long val = 0;
- for(int i=0; i<bv.length(); i++)
- if (bv.get(i))
- val |= (1L << i);
- instr.add(dock.getInterpreter().readInstruction(val, dock));
- }
+ for (Instruction inst : dock.epilogue) instr.add(inst);
return instr;
}
import edu.berkeley.fleet.api.*;
import java.util.*;
-class InterpreterDestination extends Destination {
+abstract class InterpreterDestination extends Destination {
private static int max_dest = 0;
int addr;
- Queue<Packet> packets = new LinkedList<Packet>();
-
private boolean isInstructionDestination;
public InterpreterDestination(InterpreterDock d, boolean isInstructionDestination) {
}
/** adds the included datum to the port from the switch fabric side */
- public void addDataFromFabric(Packet packet) {
- packets.add(packet);
- }
-
- public String toString() {
- return getDock()+(isInstructionDestination ? ":i" : "");
- }
+ public abstract void addDataFromFabric(Packet packet);
+ public abstract String toString();
}
Instruction executing = null;
Queue<Instruction> instructions = new LinkedList<Instruction>();
Queue<Instruction> epilogue = new LinkedList<Instruction>();
+ Queue<Packet> dataPackets = new LinkedList<Packet>();
boolean dataReadyForShip = false;
boolean readyForDataFromShip = true;
long dataFromShip;
// Destinations //////////////////////////////////////////////////////////////////////////////
/** includes the epilogue fifo */
- public InterpreterDestination instructionDestination = new InterpreterDestination(this, true);
- public InterpreterDestination dataDestination = new InterpreterDestination(this, false);
+ public InterpreterDestination instructionDestination = new InterpreterDestination(this, true) {
+ public String toString() { return getDock()+":i"; }
+ public void addDataFromFabric(Packet p) {
+ if (p.isToken()) {
+ if (torpedoWaiting) throw new RuntimeException("two torpedoes collided!");
+ torpedoWaiting = true;
+ } else {
+ BitVector bv = p.getValue();
+ long val = 0;
+ for(int i=0; i<bv.length(); i++)
+ if (bv.get(i))
+ val |= (1L << i);
+ epilogue.add(getInterpreter().readInstruction(val, InterpreterDock.this));
+ }
+ }
+ };
+ public InterpreterDestination dataDestination = new InterpreterDestination(this, false) {
+ public String toString() { return getDock()+""; }
+ public void addDataFromFabric(Packet packet) { dataPackets.add(packet); }
+ };
InterpreterDock(InterpreterShip ship, DockDescription bbd) {
super(ship, bbd);
protected final void service() {
- if (instructionDestination.packets.size() > 0) {
- Packet p = instructionDestination.packets.remove();
- if (p.isToken()) {
- if (torpedoWaiting) throw new RuntimeException("two torpedoes collided!");
- torpedoWaiting = true;
- } else {
- BitVector bv = p.getValue();
- long val = 0;
- for(int i=0; i<bv.length(); i++)
- if (bv.get(i))
- val |= (1L << i);
- epilogue.add(getInterpreter().readInstruction(val, this));
- }
- }
-
if (hatchIsOpen && epilogue.size() > 0) {
Instruction inst = epilogue.remove();
if (inst instanceof Instruction.Head) {
}
if (move.dataIn && !isInputDock() && readyForDataFromShip) return;
- if (move.dataIn && isInputDock() && dataDestination.packets.size()==0) return;
- if (move.tokenIn && dataDestination.packets.size()==0) return;
+ if (move.dataIn && isInputDock() && dataPackets.size()==0) return;
+ if (move.tokenIn && dataPackets.size()==0) return;
}
if (executing.looping && olc>0)
Packet p = null;
if (move.tokenIn) {
- p = dataDestination.packets.remove();
+ p = dataPackets.remove();
if (p.getSignal() != null) flag_c = p.getSignal().get(0);
}
if (move.dataIn) {
BitVector bv = null;
if (isInputDock()) {
- p = dataDestination.packets.remove();
+ p = dataPackets.remove();
bv = new BitVector(p.getValue());
if (p.getSignal() != null) flag_c = p.getSignal().get(0);
} else {