false /* tokenOut */
);
+ private static final Instruction RECV_DATA =
+ new Instruction.Move(DOCK,
+ false, /* requeueing */
+ Predicate.IgnoreOLC, /* predicate */
+ false, /* torpedoable */
+ null, /* path */
+ false, /* tokenIn */
+ true, /* dataIn */
+ true, /* latchData */
+ false, /* latchPath */
+ false, /* dataOut */
+ false /* tokenOut */
+ );
+
private static final Instruction SEND_TOKEN =
new Instruction.Move(DOCK,
false, /* requeueing */
* through 216 iterations.
*/
private void testFlagTruthTable(Marina marina) {
- /*
prln("Begin testFlagTruthTable");
adjustIndent(2);
for(boolean a_state : new boolean[] { false, true })
for(boolean b_state : new boolean[] { false, true })
for(boolean c_state : new boolean[] { false, true }) {
-
- // set A,B flags to a_state and b_state
- marina.instrIn.fill(new
- Instruction.Set(DOCK,false,Predicate.IgnoreOLC,
- a_state ? one : zero,
- b_state ? one : zero
- ));
-
- // set C flag to c_state
- // FIXME: implement this once we get the c-flag working
- if (c_state) continue;
-
- marina.instrIn.fill(new
- Instruction.Set(DOCK,false,Predicate.IgnoreOLC,
- ,
- b_state
- ));
-
-
-
+ 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,false,Predicate.IgnoreOLC,
+ a_state ? one : zero,
+ b_state ? one : zero
+ ));
+
+ // set C flag to c_state
+ BitVector data = new BitVector(37, "empty");
+ BitVector addr = new BitVector(14, "empty");
+ for(int i=0; i<data.getNumBits(); i++) data.set(i, false);
+ for(int i=0; i<addr.getNumBits(); i++) addr.set(i, false);
+ addr.set(0, c_state);
+ marina.fillNorthProperStopper(data, false, addr);
+ marina.instrIn.fill(RECV_DATA);
+
+ Instruction.Set.FlagFunction func = zero;
+ if (a_input!=null) func = func.add(a_input);
+ if (b_input!=null) func = func.add(b_input);
+ if (c_input!=null) func = func.add(c_input);
+
+ Instruction inst = new
+ Instruction.Set(DOCK,false,Predicate.IgnoreOLC,
+ !which ? func : zero.add(Predicate.FlagA),
+ 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;
+ boolean expected_b = which ? func.evaluate(a_state, b_state, c_state, false) : b_state;
+ fatal(expected_a != marina.getFlagA(),
+ "expected A="+expected_a+", but got "+marina.getFlagA());
+ fatal(expected_b != marina.getFlagB(),
+ "expected B="+expected_b+", but got "+marina.getFlagB());
+ }
}
-
- // we should be able to use any pair of FlagX+NotFlagX,
- // but we toss them all in to maximize the chances of the
- // test passing (later we will try the individual
- // combinations to maximize the chances of failure).
- one = one.add(Predicate.FlagA);
- one = one.add(Predicate.NotFlagA);
- one = one.add(Predicate.FlagB);
- one = one.add(Predicate.NotFlagB);
- one = one.add(Predicate.FlagC);
- one = one.add(Predicate.NotFlagC);
-
- // clear the flags to a known state, then check both 0->1 and 1->0 transitions
- for(boolean b : new boolean[] { false, true, false }) {
- prln((b?"Setting":"Clearing")+" flags");
-
- fatal(marina.getFlagA()!=b, "after "+(b?"setting":"clearing")+" FlagA, it was still "+(b?"clear":"set"));
- fatal(marina.getFlagB()!=b, "after "+(b?"setting":"clearing")+" FlagB, it was still "+(b?"clear":"set"));
- }
-
adjustIndent(-2);
prln("End testFlagTruthTable");
- */
}
private void recvData(Marina marina) {
case 3014: testShiftedLiteral(marina); break;
case 3015: testSendAndRecvToken(marina); break;
case 3016: sendDataIlcInfinite(marina); break;
+ case 3017: testFlagTruthTable(marina); break;
default:
fatal(true, "Test number: "+testNum+" doesn't exist.");