+ // Each element of the following pair of arrays is one "test".
+ // The OLC will be loaded with olcs[i] and then decremented
+ // decr_amounts[i] times; after that has happened the zeroness
+ // of the OLC will be checked by executing a MOVE with
+ // [olc!=0] as the predicate.
+
+ int[] olcs = new int[] { 3, 3, 3, 10, 41 };
+ int[] decr_amounts = new int[] { 2, 3, 4, 9, 9 };
+
+ for(int which=0; which<olcs.length; which++) {
+ int olc = olcs[which];
+ int decr_amount = decr_amounts[which];
+
+ prln("inserting set olc="+olc);
+ prln("inserting set ilc=1");
+ marina.fillSouthProperStopper(new Instruction[] {
+ new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter,1),
+ new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter,olc),
+ });
+
+ // commenting the following four lines causes this test to pass
+
+ prln("inserting: "+decr_amount+" olc-- instructions");
+ prln("inserting: [!d] send data");
+ Instruction[] instructions = new Instruction[decr_amount+1];
+ for(int i=0; i<decr_amount; i++)
+ instructions[i] =
+ new Instruction.Set(dock,
+ Predicate.Default,
+ SetDest.OuterLoopCounter,
+ SetSource.Decrement);
+ instructions[instructions.length-1] =
+ new Instruction.Move(dock,
+ Predicate.Default, // predicate
+ false, // torpedoable
+ null, // path
+ false, // tokenIn
+ false, // dataIn
+ false, // latchData
+ false, // latchPath
+ true, // dataOut
+ false // tokenOut
+ );
+
+ marina.fillSouthProperStopper(instructions);
+ model.waitNS(64 * CYCLE_TIME_NS);
+
+ 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");
+
+ if (marina.kesselsCounter) {
+ // master clear on each iteration; otherwise we'd need to "run down" the olc
+ marina.masterClear();
+ marina.enableInstructionSend(true);
+ }
+ }
+
+ adjustIndent(-2);
+ prln("End testOlcDecrementAtHighSpeed");
+ }
+
+ private void flipIlcBit(Marina marina) {
+ prln("Begin flipIlcBit");
+ adjustIndent(2);
+ prln("Using the set ILC instruction, toggle a single bit between zero and one. \n" +
+ "Check correct setting of the ILC zero bit");
+
+ for (int i=0; i<6; i++) {
+ int notZero = 1<<i;
+
+ prln("Then immediately set ILC="+notZero);
+ marina.fillSouthProperStopper(new Instruction[] {
+ new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, 0),
+ 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();
+ fatal(ilcCount!=notZero, "bad ILC count: "+ilcCount+" expected: "+notZero);
+ fatal(ilc.getInfinity(), "bad ILC Infinity bit: true");
+
+ marina.fillSouthProperStopper(new Instruction[] {
+ 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();
+ ilcCount = ilc.getCount();
+ fatal(ilcCount!=0, "bad ILC count: "+ilcCount+" expected: 0");
+ fatal(ilc.getInfinity(), "bad ILC Infinity bit: true");
+ }
+
+ adjustIndent(-2);
+ prln("End flipIlcBit");
+ }
+ private void flipOlcBit(Marina marina) {
+ prln("Begin flipOlcBit");
+ adjustIndent(2);
+ prln("Using the set OLC instruction, toggle a single bit between zero and one. \n" +
+ "Check correct setting of the OLC zero bit");
+
+ marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD, CLEAR_FLAG, CLEAR_FLAG));
+
+ for (int i=0; i<6; i++) {
+ int notZero = 32 >> i;
+
+ if (marina.kesselsCounter) {
+ // master clear on each iteration; otherwise we'd need to "run down" the olc
+ marina.masterClear();
+ marina.enableInstructionSend(true);
+ }
+
+ int outOlc;
+ prln("Set OLC=0");
+ prln("Then immediately set OLC="+notZero);
+ marina.fillSouthProperStopper(new Instruction[] {
+ 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");
+ expectOlc(notZero);
+
+ if (!marina.kesselsCounter) {
+ prln("Set OLC="+notZero);
+ prln("Then immediately set OLC=0");
+ marina.fillSouthProperStopper(new Instruction[] {
+ new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter, notZero),
+ new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter, 0),
+ });
+
+ model.waitNS(64 * CYCLE_TIME_NS);
+ prln("Verify OLC count using scan chain");
+ expectOlc(0);
+ }
+ }