import java.util.*;
import edu.berkeley.fleet.two.*;
import edu.berkeley.fleet.api.*;
+import edu.berkeley.sbp.util.ANSI;
/** anything that has a source (instruction horn) address on the switch fabric */
class InterpreterDock extends FleetTwoDock {
boolean torpedoWaiting = false;
boolean flushing = false;
- Queue<Instruction> instructions = new LinkedList<Instruction>();
- Queue<Packet> dataPackets = new LinkedList<Packet>();
+ LinkedList<Instruction> instructions = new LinkedList<Instruction>();
+ LinkedList<Packet> dataPackets = new LinkedList<Packet>();
// HACK
- private Queue<Instruction> instructionsBackedUpIntoSwitchFabric = new LinkedList<Instruction>();
+ private LinkedList<Instruction> instructionsBackedUpIntoSwitchFabric = new LinkedList<Instruction>();
boolean dataReadyForShip = false;
boolean readyForDataFromShip = true;
+
+ // FIXME: should be a BitVector
long dataFromShip;
boolean flagCFromShip;
dataFromShip = data;
flagCFromShip = pending_flag_c;
}
+
+
+ // Debugging //////////////////////////////////////////////////////////////////////////////
+
+ public void dumpState() {
+ if (instructions.size()==0 &&
+ dataPackets.size()==0 &&
+ instructionsBackedUpIntoSwitchFabric.size()==0 &&
+ !requeueStageHasTailInstruction &&
+ !requeueStageInCirculatingState &&
+ !torpedoWaiting &&
+ !flushing &&
+ !dataReadyForShip &&
+ readyForDataFromShip)
+ return;
+ System.out.println("state of "+ANSI.green(this)+": "+
+ (ilc==1?"":("[ilc="+(ilc==-1 ? "*" : (ilc+""))+"] "))+
+ (olc==1?"":("[olc="+olc+"] "))+
+ (flag_a?"[a] ":"")+
+ (flag_b?"[b] ":"")+
+ (flag_c?"[c] ":"")+
+ (flag_d?"[d] ":"")+
+ (requeueStageInCirculatingState?"[recirculating] ":"")+
+ (requeueStageHasTailInstruction?"[tail waiting] ":"")+
+ (torpedoWaiting?"[torpedo waiting] ":"")+
+ (flushing?"[flushing] ":"")
+ );
+ if (!readyForDataFromShip)
+ System.out.println(ANSI.cyan(" ship has proffered: " + dataFromShip));
+ if (dataReadyForShip)
+ System.out.println(ANSI.cyan(" waiting for ship to accept: " + dataLatch.toLong()));
+ for(Instruction i : instructions)
+ System.out.println(ANSI.red(" "+i));
+ for(Instruction i : instructionsBackedUpIntoSwitchFabric)
+ System.out.println(ANSI.red(ANSI.bold(" "+i+" BACKED UP")));
+ for(Packet p : dataPackets)
+ System.out.println(ANSI.cyan(" "+p));
+ }
+
}