import com.sun.async.test.JtagTester;
import com.sun.async.test.ManualPowerChannel;
import com.sun.async.test.NanosimModel;
+import com.sun.async.test.HsimModel;
import com.sun.async.test.VerilogModel;
import com.sun.async.test.Netscan4;
import com.sun.async.test.PowerChannel;
private static final int MORE_THAN_DATA_OUT_SATURATION_AMOUNT = 10;
// Nominal cycle time assuming 4 GHz throughput
- private static double CYCLE_TIME_NS;
+ public static double CYCLE_TIME_NS;
//-------------------------------- types ---------------------------------
fatal(true, "unrecognized CmdArgs.Mode");
return;
}
- model = cmdArgs.useVerilog ? new VerilogModel() : new NanosimModel();
-
+ model = cmdArgs.useVerilog
+ ? new VerilogModel()
+ : cmdArgs.useHsim
+ ? new HsimModel()
+ : new NanosimModel();
+
((SimulationModel)model).setOptimizedDirectReadsWrites(true);
CYCLE_TIME_NS = cmdArgs.useVerilog ? (100*20) : 0.250;
if (model instanceof VerilogModel)
((SimulationModel)model).start("verilog", "marina.v", VerilogModel.DUMPVARS, !cmdArgs.jtagShift);
+ else if (model instanceof HsimModel)
+ ((SimulationModel)model).start("hsim64", netListName, 0, !cmdArgs.jtagShift);
else
((SimulationModel)model).start("nanosim -c cfg", netListName, 0, !cmdArgs.jtagShift);
private Instruction setOlc(int olc) {
return new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter, olc);
}
+ private Instruction setOlcIfZero(int olc) {
+ return new Instruction.Set(dock,Predicate.Default,SetDest.OuterLoopCounter, olc);
+ }
private Instruction setIlc(int ilc) {
return new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, ilc);
}
),
});
expectNorthFifoExactly((predicate_olc_nonzero == (olc!=0)) ? 1 : 0);
+
+ for(int i=0; i<olc; i++)
+ marina.instrIn.fill(DEC);
+
adjustIndent(-2);
}
}
int olc = marina.getOLC();
prln("OLC=="+olc);
-
+
Ilc ilc = marina.getILC();
prln("ILC.done=="+ilc.getDone()+
" ILC.infinity=="+ilc.getInfinity()+
adjustIndent(-2);
prln("end getCtrsFlags");
}
+
private void walkOneOLC(Marina marina) {
prln("Begin walkOneOLC");
adjustIndent(2);
}
// Note: countOlc takes 44 minutes to run on nanosim
private void countOlc(Marina marina) {
- final int maxOlc = 63;
+ int maxOlc = 63;
prln("Begin countOlc");
adjustIndent(2);
-
- marina.instrIn.fill(new
- Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter, maxOlc));
+
+ marina.instrIn.fill(setOlc(maxOlc));
+
for (int i=maxOlc; i>=0; i--) {
+ model.waitNS(128 * CYCLE_TIME_NS);
prln("OLC should be: "+i);
int olc = marina.getOLC();
fatal(olc!=i, "bad OLC: "+olc+" expected: "+i);
private static MarinaPath null_path = new MarinaPath((MarinaFleet)dock.getShip().getFleet(),
MarinaUtils.sunToBerk(MarinaPacket.null_path));
+ private static final Instruction DEC =
+ new Instruction.Set(dock,Predicate.Default,SetDest.OuterLoopCounter, SetSource.Decrement);
+
+ private static final Instruction FLAG_NOP =
+ new Instruction.Set(dock, Predicate.IgnoreFlagD,
+ CLEAR_FLAG.add(Predicate.FlagA),
+ CLEAR_FLAG.add(Predicate.FlagB));
+
private static final Instruction NOP =
new Instruction.Move(dock,
Predicate.IgnoreFlagD, /* predicate */
marina.instrIn.fill(setIlc(1));
marina.fillSouthProperStopper(new Instruction[] {
RECV_DATA,
- new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter,1),
new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter,0),
SEND_DATA_IF_D_NOT_SET
});
});
marina.fillNorthProperStopper();
expectNorthFifoExactly(1);
+ marina.instrIn.fill(DEC);
marina.fillSouthProperStopper(new Instruction[] {
RECV_DATA,
private void testTailWaitsForHead(Marina marina) {
marina.instrIn.fill(setIlc(1));
marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter, 63));
-
+
marina.enableInstructionSend(false);
marina.enableInstructionRecirculate(true);
-
+
marina.instrIn.fill(TORPEDOABLE_RECV_DATA);
marina.instrIn.fill(new Instruction.Head(dock));
marina.instrIn.fill(SEND_DATA);
marina.instrIn.fill(TORPEDOABLE_RECV_DATA);
marina.instrIn.fill(new Instruction.Tail(dock));
marina.instrIn.fillTorpedo();
-
+
marina.enableInstructionRecirculate(false);
marina.enableInstructionSend(true);
marina.instrIn.run();
-
+
expectNorthFifoNoMoreThan(0);
prln("inserting into north proper stopper");
marina.fillNorthProperStopper();
fatal(nbToks!=1, "Expected one token to emerge but got: "+nbToks+" tokens");
}
+ /*
+ marina.instrIn.fill(setIlc(1));
+ marina.instrIn.fill(setOlc(1));
+
+ // this makes the head wait for the torpedo
+ marina.instrIn.fill(TORPEDOABLE_RECV_DATA);
+
+ // the head should wait for the tail
+ marina.instrIn.fill(new Instruction.Head(dock));
+ marina.instrIn.fill(NOP);
+ marina.instrIn.fill(SEND_DATA);
+ marina.instrIn.fill(RECV_DATA);
+
+ expectNorthFifoNoMoreThan(0);
+
+ marina.instrIn.fillTorpedo();
+ expectNorthFifoNoMoreThan(0);
+
+ marina.instrIn.fill(new Instruction.Tail(dock));
+ expectNorthFifoExactly(1);
+ */
+
private void testTailWithoutHead(Marina marina) {
marina.instrIn.fill(setIlc(1));
marina.fillSouthProperStopper(new Instruction[] {
private void testNonTorpedoableMoveDoesNotResetDFlag(Marina marina) {
marina.instrIn.fill(setIlc(1));
marina.fillSouthProperStopper(new Instruction[] {
- new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter,3),
+ new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter,63),
new Instruction.Move(dock,
Predicate.IgnoreFlagD, // predicate
true, // torpedoable
}
private void testAbort(Marina marina) {
-
+
marina.instrIn.fill(setIlc(1));
marina.fillSouthProperStopper(new Instruction[] {
new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.DataLatch,1),
new Instruction.Set(dock,Predicate.Default,SetDest.OuterLoopCounter,SetSource.Decrement),
new Instruction.Tail(dock),
}, true);
-
+
for(int i=0; i<4; i++) {
BitVector bv;
-
+
model.waitNS(128 * CYCLE_TIME_NS);
bv = new MarinaPacket(marina.data.drain()).data.bitReverse();
fatal(bv==null, "no data item found");
prln("got " + bv.toLong());
fatal(bv.toLong()!=1, "expected 1, got " + bv.toLong());
-
+
model.waitNS(128 * CYCLE_TIME_NS);
bv = new MarinaPacket(marina.data.drain()).data.bitReverse();
fatal(bv==null, "no data item found");
prln("got " + bv.toLong());
fatal(bv.toLong()!=1, "expected 1, got " + bv.toLong());
-
+
model.waitNS(128 * CYCLE_TIME_NS);
bv = new MarinaPacket(marina.data.drain()).data.bitReverse();
fatal(bv==null, "no data item found");
prln("got " + bv.toLong());
fatal(bv.toLong()!=2, "expected 2, got " + bv.toLong());
-
+
}
}
marina.fillSouthProperStopper(new Instruction[] {
RECV_DATA,
inst,
- setOlc(1),
+ NOP,
});
model.waitNS(64 * CYCLE_TIME_NS);
marina.fillNorthProperStopper();
new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter,SetSource.DataLatch)
});
+ model.waitNS(CYCLE_TIME_NS * 64);
+
int olc = marina.getOLC();
fatal(olc != (1<<bit), "expected olc to be " + (1<<bit) + ", but got " + olc);
}
RECV_TOKEN,
SEND_DATA,
});
- List<BitVector> dataItems = marina.data.drainMany(3);
- fatal(dataItems.size()!=1,
- "expected exactly one data item, got " + dataItems.size());
+ expectNorthFifoExactly(1);
adjustIndent(-2);
prln("End testSendAndRecvToken");
val),
SEND_DATA,
});
+ model.waitNS(CYCLE_TIME_NS * 64);
List<BitVector> dataItems = marina.data.drainMany(3);
fatal(dataItems.size()!=1, "expected exactly one data item, got " + dataItems.size());
SEND_DATA,
});
+ model.waitNS(CYCLE_TIME_NS * 64);
List<BitVector> dataItems = marina.data.drainMany(3);
fatal(dataItems.size()!=1, "expected exactly one data item, got " + dataItems.size());
false, /* dataOut */
false /* tokenOut */
),
+ FLAG_NOP,
new Instruction.Set(dock,Predicate.IgnoreFlagD,
Instruction.Set.FlagFunction.ZERO.add(Predicate.FlagC),
CLEAR_FLAG
prln("Begin sendTorpedo");
adjustIndent(2);
marina.instrIn.fill(setIlc(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");
+ marina.instrIn.fill(setOlc(63));
+
+ int olc;
+ olc = marina.getOLC();
+ fatal(olc!=63, "bad OLC: "+olc+" expected: 1");
+
marina.instrIn.fill(new
Instruction.Set(dock,Predicate.IgnoreFlagD, CLEAR_FLAG, CLEAR_FLAG));
fatal(marina.getFlagA(), "bad A flag: true");
prln("send torpedo. This should clear the OLC");
marina.instrIn.fillTorpedo();
- model.waitNS(64 * CYCLE_TIME_NS);
+ model.waitNS(128 * CYCLE_TIME_NS);
prln("A should remain false, B should be true");
fatal(marina.getFlagA(), "bad A flag: true");
marina.instrIn.fill(new
Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter, 63));
+ // FIXME: find another way to test this
olc = marina.getOLC();
fatal(olc!=63, "bad OLC: "+olc+" expected: 63");
for(int i=0; i<decr_amount; i++)
instructions[i] =
new Instruction.Set(dock,
- Predicate.IgnoreFlagD,
+ Predicate.Default,
SetDest.OuterLoopCounter,
SetSource.Decrement);
instructions[instructions.length-1] =
int expected = decr_amount>=olc ? 0 : 1;
dataItems = marina.data.drainMany(2);
fatal(dataItems.size()!=expected, "Expected "+expected+" item to emerge but got: "+dataItems.size()+" data items");
+ for(int i=0; i<Math.max(0, olc-decr_amount); i++)
+ marina.instrIn.fill(new Instruction.Set(dock,
+ Predicate.Default,
+ SetDest.OuterLoopCounter,
+ SetSource.Decrement));
}
adjustIndent(-2);
new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, notZero),
});
+ model.waitNS(64 * CYCLE_TIME_NS);
+
prln("Verify ILC using scan chain");
Ilc ilc = marina.getILC();
int ilcCount = ilc.getCount();
new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, notZero),
new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, 0),
});
+
+ model.waitNS(64 * CYCLE_TIME_NS);
prln("Verify ILC using scan chain");
ilc = marina.getILC();
new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter, 0),
new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter, notZero),
});
-
+
+ model.waitNS(64 * CYCLE_TIME_NS);
prln("Verify OLC count using scan chain");
int outOlc = marina.getOLC();
fatal(outOlc!=notZero, "bad OLC count: "+outOlc+" expected: "+notZero);
new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter, 0),
});
+ model.waitNS(64 * CYCLE_TIME_NS);
prln("Verify OLC count using scan chain");
outOlc = marina.getOLC();
fatal(outOlc!=0, "bad OLC count: "+outOlc+" expected: 0");
doOneTest(3026); // passes extracted parasitics
doOneTest(3027); // passes extracted parasitics
doOneTest(3028); // passes extracted parasitics
-
- // these tests take a while and usually pass
+
+ // these tests take a while and usually pass
doOneTest(1002);
doOneTest(1004);
doOneTest(1005);
doOneTest(3021);
doOneTest(3024);
doOneTest(3025);
-
+
// this takes an insanely long time
doOneTest(3017);
-
break;
}
case 1: testChains(marina); break; // passes, 24-Mar (+verilog)