add test 3017
authorAdam Megacz <adam.megacz@sun.com>
Sun, 23 Nov 2008 22:14:37 +0000 (22:14 +0000)
committerAdam Megacz <adam.megacz@sun.com>
Sun, 23 Nov 2008 22:14:37 +0000 (22:14 +0000)
testCode/com/sun/vlsi/chips/marina/test/MarinaTest.java

index d0ab151..eeb93d4 100644 (file)
@@ -777,6 +777,20 @@ public class MarinaTest {
                              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  */
@@ -1121,7 +1135,6 @@ public class MarinaTest {
      *  through 216 iterations.
      */
     private void testFlagTruthTable(Marina marina) {
-        /*
        prln("Begin testFlagTruthTable");
        adjustIndent(2);
 
@@ -1134,50 +1147,50 @@ public class MarinaTest {
                     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) {
@@ -1608,6 +1621,7 @@ public class MarinaTest {
                 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.");