//-------------------------- private data --------------------------------
private static long startTime;
- private Indenter indenter = new Indenter();
+ public static Indenter indenter = new Indenter();
private Marina marina;
private ChipModel model;
//private ChainControl cc;
int nbToks = marina.getNumTokens();
fatal(nbToks!=0, "Expected no tokens on initialization but got: "+nbToks+" tokens");
- prln("send token");
marina.instrIn.fill(
new Instruction.Move(dock,
Predicate.IgnoreFlagD, /* predicate */
for(int i=0; i<bv.length(); i+=2) bv.set(i, false);
MarinaPath path = new MarinaPath((MarinaFleet)dock.getShip().getFleet(), bv);
- prln("send data");
marina.instrIn.fill(new Instruction.Move(dock,
Predicate.IgnoreFlagD, /* predicate */
false, /* torpedoable */
fatal(dataItems.size()!=1, "Expected one data item to emerge but got: "+dataItems.size()+" data items");
MarinaPacket mp = new MarinaPacket(dataItems.get(0));
- prln("packet: "+mp);
fatal(mp.tokenhood, "Expected tokenhood=data, but got tokenhood=token");
adjustIndent(-2);
prln("Begin sendDataIlcInfinite");
adjustIndent(2);
- prln("ILC=\\infty");
- marina.instrIn.fill(
- new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter,SetSource.Infinity));
-
- getCtrsFlags(marina);
-
- prln("send data");
+ marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter,SetSource.Infinity));
marina.instrIn.fill(SEND_DATA);
- getCtrsFlags(marina);
-
// more than MAX_ILC
int howmany = 70;
List<BitVector> dataItems = marina.data.drainMany(howmany);
}
private void setOLC(Marina marina, int olc) {
- // ugly hack, to be removed when we fix the zero-detect circuit
- for(int i=0; i<2; i++) {
- marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter, olc));
- }
+ marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter, olc));
}
private void testFlagD(Marina marina) {
"predicate olc"+(predicate_olc_nonzero?"!=0":"==0"));
adjustIndent(2);
- prln("Inserting Set OLC="+olc);
setOLC(marina, olc);
-
- prln("Inserting ["+(predicate_olc_nonzero?"olc!=0":"olc==0")+"] send data");
marina.instrIn.fill(new Instruction.Move(dock,
predicate_olc_nonzero // predicate
? only_if_olc_nonzero
List<BitVector> dItems;
- prln("Setting OLC=1");
marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter, 1));
- prln("Setting ILC=1");
marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, 1));
for(boolean flag_a : new boolean[] { false, true }) {
adjustIndent(2);
for (int i=5; i>=0; i--) {
int inOlc = 1<<i;
- prln("Set inOlc="+inOlc);
marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter, inOlc));
int outOlc = marina.getOLC();
fatal(outOlc!=inOlc, "walkOneOLC: got="+outOlc+" expected="+inOlc);
prln("Begin countIlc");
adjustIndent(2);
- prln("Set ILC=63");
marina.instrIn.fill(new
Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, maxIlc));
fatal(ilc!=maxIlc, "bad ILC count: "+ilc+" expected: "+maxIlc);
prln("execute a move instruction that does nothing except decrement the ILC to zero");
-
marina.instrIn.fill(
new Instruction.Move(dock,
Predicate.IgnoreFlagD, // predicate
private static final Instruction REQUEUEING_SEND_DATA = SEND_DATA;
- private void testRequeueStage0(Marina marina) {
- prln("Begin testRequeueStage0");
- adjustIndent(2);
-
- prln("Executing Set OLC=0");
- setOLC(marina, 0);
- saturateInstructionFifo(marina, REQUEUEING_NOP, MORE_THAN_INSTRUCTION_IN_SATURATION_AMOUNT, false);
- adjustIndent(-2);
- prln("End testRequeueStage0");
- }
-
- private void testRequeueStage0to1(Marina marina) {
- prln("Begin testRequeueStage0to1");
- adjustIndent(2);
-
- prln("Executing Set OLC=63");
- setOLC(marina, 63);
- saturateInstructionFifo(marina, REQUEUEING_NOP, MORE_THAN_INSTRUCTION_IN_SATURATION_AMOUNT, true);
- adjustIndent(-2);
- prln("End testRequeueStage0to1");
- }
-
- /**
- * This test brings the requeue stage through the 0->1->3->0 state
- * transition sequence.
- *
-
- * According to the diagram in IES50, there are three transitions
- * (0->1, 1->3, 3->0) to perform, and in each state there are two
- * behaviors to verify (the two notations in each oval of the
- * state diagram). The "OD->drain" behavior of state 0 is
- * verified by testRequeueStage0().
- */
- private void testRequeueStage0to1to3to0(Marina marina) {
- List<BitVector> dataItems;
-
- int extras = 5;
- int olc_value = MORE_THAN_DATA_OUT_SATURATION_AMOUNT + extras;
-
- prln("Begin testRequeueStage0to1to3to0");
- adjustIndent(2);
-
- // State 0 //////////////////////////////////////////////////////////////////////////////
-
- prln("Executing Set OLC="+olc_value);
- setOLC(marina, olc_value);
- prln("Executing Set ILC=1");
- marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, 1));
-
- // verify state0 "EPI->ring" and 0->1 transition
- prln("Executing Send Data (requeueable); this will cause 0->1 transition and be discarded");
- marina.instrIn.fill(REQUEUEING_SEND_DATA);
-
- // State 1 //////////////////////////////////////////////////////////////////////////////
-
- // verify state1 "EPI->ring"
- prln("Executing Set ILC=1; this will be recirculated");
- marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, 1));
-
- prln("Executing Send Data; this will be recirculated");
- marina.instrIn.fill(REQUEUEING_SEND_DATA);
-
- prln("Executing Set OLC--; this will be recirculated");
- marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter,SetSource.Decrement));
-
- // verify state1 "OD waits"
- dataItems = marina.data.drainMany(2);
- fatal(dataItems.size()!=1, "Expected exactly one data item to emerge but got: "+dataItems.size()+" data items");
-
- // verify 1->3 transition
- prln("Executing Tail; this will cause the 2->3 transition and be discarded");
- marina.instrIn.fill(new Instruction.Tail(dock));
-
- // State 3 //////////////////////////////////////////////////////////////////////////////
-
- // verify state3 "OD->ring"
- dataItems = marina.data.drainMany(MORE_THAN_DATA_OUT_SATURATION_AMOUNT);
- fatal(dataItems.size()<MORE_THAN_DATA_OUT_SATURATION_AMOUNT,
- "Expected more than " + MORE_THAN_DATA_OUT_SATURATION_AMOUNT +
- " data items, but only got: "+dataItems.size()+" of them");
-
- // verify state3 "OD->ring"
- saturateInstructionFifo(marina, NOP, MORE_THAN_INSTRUCTION_IN_SATURATION_AMOUNT, true);
-
- // verify state3->state0
- dataItems = marina.data.drainMany(extras + 4);
- fatal(dataItems.size()!=(extras+1),
- "Expected exactly " + (extras+1) + " items to emerge, but got at least : "+dataItems.size()+" of them");
-
- // State 0 //////////////////////////////////////////////////////////////////////////////
-
- // verify that we are back in state0
- saturateInstructionFifo(marina, REQUEUEING_NOP, MORE_THAN_INSTRUCTION_IN_SATURATION_AMOUNT, false);
-
- adjustIndent(-2);
- prln("End testRequeueStage0to1to3to0");
- }
-
- /**
- * This test brings the requeue stage through the 0->2->3->0 state
- * transition sequence.
- *
- * According to the diagram in IES50, there are two transitions
- * (0->2, 2->3, 3->0) to perform, and in each state there are two
- * behaviors to verify (the two notations in each oval of the
- * state diagram). The "OD->drain" behavior of state 0 is
- * verified by testRequeueStage0().
- */
- private void testRequeueStage0to2to3to0(Marina marina) {
- List<BitVector> dataItems;
-
- int olc_value = 10;
- int number_of_non_requeueable_send_datas = INSTRUCTION_RING_CAPACITY;
-
- prln("Begin testRequeueStage0to2to3to0");
- adjustIndent(2);
-
- // State 0 //////////////////////////////////////////////////////////////////////////////
-
- prln("Executing Set OLC="+olc_value);
- setOLC(marina, olc_value);
-
- prln("Executing Set ILC=1");
- marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, 1));
-
- // insert many non-requeueing "send data item" instructions;
- // this will let us single-step the execution point by
- // extracting data items.
- for(int i=0; i<number_of_non_requeueable_send_datas; i++) {
- prln("Inserting Send Data");
- marina.instrIn.fill(SEND_DATA);
- }
-
- // this will send us a token later
- prln("Inserting [Rq] Nop; this will be discarded");
- marina.instrIn.fill(REQUEUEING_NOP);
-
- // this will send us a token later
- prln("Inserting [Rq] Send Data; this will be recirculated");
- marina.instrIn.fill(REQUEUEING_SEND_DATA);
-
- prln("Inserting [Rq] Set OLC--; this will be recirculated");
- marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter,SetSource.Decrement));
-
- // insert the tail, which will cause the 0->2 transition
- prln("Inserting Tail");
- marina.instrIn.fill(new Instruction.Tail(dock));
-
- // State 2 //////////////////////////////////////////////////////////////////////////////
-
- // confirm state 2 "EPI waits"
- prln("Saturating the instruction input to confirm that EPI waits");
- saturateInstructionFifo(marina, REQUEUEING_NOP, MORE_THAN_INSTRUCTION_IN_SATURATION_AMOUNT, true);
-
- // confirm state 2 "OD->drain"
- prln("Draining data output to cause the 2->3 transition");
- dataItems = marina.data.drainMany(number_of_non_requeueable_send_datas);
- fatal(dataItems.size()!=number_of_non_requeueable_send_datas,
- "Expected at least " + number_of_non_requeueable_send_datas +
- " items to emerge, but got only : "+dataItems.size()+" of them");
-
- // State 3 //////////////////////////////////////////////////////////////////////////////
-
- // verify state3 "EPI waits"
- prln("Verifying that EPI still waits in state3");
- fatal(marina.instrIn.getFillStateWire()!=MarinaUtils.StateWireState.FULL,
- "state3 EPI waits not verified");
- prln(" ok");
- prln("");
-
- // verify state3 "OD->ring" and state3->state0
- prln("Removing data items to run down the OLC to zero and cause 3->0 transition");
- dataItems = marina.data.drainMany(olc_value+10);
- fatal(dataItems.size()!=(olc_value+1),
- "Expected exactly " + (olc_value+1) + " items to emerge, but got: "+dataItems.size()+" of them");
-
- // State 0 //////////////////////////////////////////////////////////////////////////////
-
- // verify that we are back in state0
- prln("Confirming that we are back in state0");
- saturateInstructionFifo(marina, REQUEUEING_NOP, MORE_THAN_INSTRUCTION_IN_SATURATION_AMOUNT, false);
-
- adjustIndent(-2);
- prln("End testRequeueStage0to2to3to0");
- }
private void testWaitForTail(Marina marina) {
List<BitVector> dataItems;
prln("Begin testWaitForTail");
adjustIndent(2);
- prln("inserting instruction: Set OLC=63");
setOLC(marina, 63);
-
- prln("inserting instruction: head");
marina.instrIn.fill(new Instruction.Head(dock));
-
- prln("inserting instruction: Set ILC=1");
marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter,1));
-
- prln("inserting instruction: Send Data");
marina.instrIn.fill(SEND_DATA);
-
dataItems = marina.data.drainMany(1);
fatal(dataItems.size()!=0, "Expected exactly no data items to emerge but got at least: "+dataItems.size());
-
- prln("inserting instruction: tail");
marina.instrIn.fill(new Instruction.Tail(dock));
BitVector bv = marina.data.drain();
for(boolean which : new boolean[] { false, true }) {
prln("before instruction: a="+a_state+", b="+b_state+", c="+c_state);
-
// set A,B flags to a_state and b_state
marina.instrIn.fill(new
Instruction.Set(dock,Predicate.IgnoreFlagD,
which ? func : zero.add(Predicate.FlagB)
);
- prln("executing instruction: " + inst);
marina.instrIn.fill(inst);
boolean expected_a = !which ? func.evaluate(a_state, b_state, c_state, false) : a_state;
prln("Begin testSendAndRecvToken");
adjustIndent(2);
- prln("sending token");
marina.instrIn.fill(SEND_TOKEN);
-
- prln("receiving token");
marina.instrIn.fill(RECV_TOKEN);
-
- prln("sending data item");
marina.instrIn.fill(SEND_DATA);
-
- prln("checking to confirm that data item arrived");
List<BitVector> dataItems = marina.data.drainMany(3);
fatal(dataItems.size()!=1,
"expected exactly one data item, got " + dataItems.size());
adjustIndent(2);
for(long val : new long[] { (-1L << 14), -1, 0, 1 }) {
- prln("inserting Set Data Latch (sign-extended) 37'b" + Long.toString(val, 1));
marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,
Instruction.Set.SetDest.DataLatch,
val));
-
- prln("sending data item");
marina.instrIn.fill(SEND_DATA);
-
List<BitVector> dataItems = marina.data.drainMany(3);
fatal(dataItems.size()!=1, "expected exactly one data item, got " + dataItems.size());
prln("Begin testShiftedLiteral");
adjustIndent(2);
- prln("clearing the D register");
marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,
Instruction.Set.SetDest.DataLatch,
0));
for(long val : new long[] { -1, 0, 1, (-1L << 18) }) {
- prln("inserting Shift 19'b" + Long.toString(val, 1));
edu.berkeley.fleet.api.BitVector immediate =
new edu.berkeley.fleet.api.BitVector(19);
for(int i=0; i<immediate.length(); i++)
for(int i=0; i<19; i++)
dreg.set(i, immediate.get(i));
- prln("sending data item");
marina.instrIn.fill(SEND_DATA);
List<BitVector> dataItems = marina.data.drainMany(3);
MarinaPath path = new MarinaPath((MarinaFleet)dock.getShip().getFleet(), bv);
- prln("send data with path="+bv);
marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter,1));
marina.instrIn.fill(new Instruction.Move(dock,
Predicate.IgnoreFlagD, /* predicate */
for(int bit=0; bit<6; bit++) {
int ilc = bit<0 ? 0 : (1<<bit);
-
- prln("set ilc="+ilc);
marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter,ilc));
-
- prln("send data");
marina.instrIn.fill(SEND_DATA);
-
List<BitVector> dataItems = marina.data.drainMany();
fatal(dataItems.size()!=ilc, "Expected "+ilc+" data item(s) to emerge but got: "+dataItems.size()+" data items");
}
private void sendTorpedo(Marina marina) {
prln("Begin sendTorpedo");
adjustIndent(2);
-
- prln("Set OLC = 1");
marina.instrIn.fill(new
Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter, 1));
-
int olc = marina.getOLC();
fatal(olc!=1, "bad OLC: "+olc+" expected: 1");
-
- prln("Set A=0, B=0");
marina.instrIn.fill(new
Instruction.Set(dock,Predicate.IgnoreFlagD, CLEAR_FLAG, CLEAR_FLAG));
-
fatal(marina.getFlagA(), "bad A flag: true");
fatal(marina.getFlagB(), "bad B flag: true");
-
- prln("Set ILC = Infinity");
marina.instrIn.fill(new
Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, SetSource.Infinity));
-
+
prln("execute a move instruction that does nothing but loops until torpedo arrives");
marina.instrIn.fill(
new Instruction.Move(dock,
for(boolean torpedoable : new boolean[] { true, false }) {
- prln("send token");
marina.instrIn.fill(new Instruction.Move(dock,
Predicate.IgnoreFlagD, // predicate
false, // torpedoable
true // tokenOut
));
- prln("set ilc=\\infty");
marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter,SetSource.Infinity));
- prln("recv-and-send token");
marina.instrIn.fill(new Instruction.Move(dock,
Predicate.IgnoreFlagD, // predicate
torpedoable, // torpedoable
));
// FIXME: this probably should be removed, unless Ivan doesn't want to change the behavior
- prln("set ilc=1");
marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter,1));
- prln("send data");
marina.instrIn.fill(SEND_DATA);
// expect nothing to come out, because the NOP is executing
dataItems = marina.data.drainMany(2);
fatal(dataItems.size()!=0, "Expected no data item(s) to emerge but got at least: "+dataItems.size()+" data items");
- prln("send torpedo");
marina.instrIn.fillTorpedo();
int expected = torpedoable?1:0;
for (int i=0; i<6; i++) {
int notZero = 1<<i;
- prln("Set ILC=0");
- marina.instrIn.fill(new
- Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, 0));
+
+ marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, 0));
prln("Then immediately set ILC="+notZero);
- marina.instrIn.fill(new
- Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, notZero));
+ marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, notZero));
prln("Verify ILC using scan chain");
Ilc ilc = marina.getILC();
int ilcCount = ilc.getCount();
fatal(ilcCount!=notZero, "bad ILC count: "+ilcCount+" expected: "+notZero);
-
fatal(ilc.getInfinity(), "bad ILC Infinity bit: true");
- prln("Set ILC="+notZero);
- marina.instrIn.fill(new
- Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, notZero));
-
- prln("Then immediately set ILC=0");
- marina.instrIn.fill(new
- Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, 0));
+ marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, notZero));
+ marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, 0));
prln("Verify ILC using scan chain");
ilc = marina.getILC();
ilcCount = ilc.getCount();
fatal(ilcCount!=0, "bad ILC count: "+ilcCount+" expected: 0");
-
fatal(ilc.getInfinity(), "bad ILC Infinity bit: true");
}
prln("Using the set OLC instruction, toggle a single bit between zero and one. \n" +
"Check correct setting of the OLC zero bit");
- prln("Set A=0, B=0");
- marina.instrIn.fill(new
- Instruction.Set(dock,Predicate.IgnoreFlagD, CLEAR_FLAG, CLEAR_FLAG));
+ marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD, CLEAR_FLAG, CLEAR_FLAG));
for (int i=0; i<6; i++) {
int notZero = 32 >> i;
case 0: {
// these tests run fairly quickly
-
doOneTest(1);
doOneTest(2);
doOneTest(3);
case 3003: testFlagC(marina); break; // 23-Apr (+verilog)
case 3004: testFlagD(marina); break; // 23-Apr (+verilog)
- case 3005: testRequeueStage0(marina); break;
- case 3006: testRequeueStage0to1(marina); break;
- case 3007: testRequeueStage0to1to3to0(marina); break;
- case 3008: testRequeueStage0to2to3to0(marina); break;
- //case 3010: testRequeueStageDrop(marina); break; // no longer relevant (behavior changed)
-
case 3009: testWaitForTail(marina); break; // 22-Apr (+verilog)
case 3010: sendData(marina); break; // passes, 24-Mar (+verilog)