updates for kessels counter
authorAdam Megacz <adam.megacz@sun.com>
Thu, 28 May 2009 06:23:17 +0000 (06:23 +0000)
committerAdam Megacz <adam.megacz@sun.com>
Thu, 28 May 2009 06:23:17 +0000 (06:23 +0000)
testCode/com/sun/vlsi/chips/marina/test/MarinaTest.java

index 7c80022..0a58ba3 100644 (file)
@@ -14,6 +14,7 @@ import com.sun.async.test.JtagSubchainTesterModel;
 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;
@@ -97,7 +98,7 @@ public class MarinaTest {
     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 ---------------------------------
 
@@ -212,8 +213,12 @@ public class MarinaTest {
                 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;
@@ -247,6 +252,8 @@ public class MarinaTest {
 
         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);
 
@@ -543,6 +550,9 @@ public class MarinaTest {
     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);
     }
@@ -583,6 +593,10 @@ public class MarinaTest {
                                              ),
                     });
                 expectNorthFifoExactly((predicate_olc_nonzero == (olc!=0)) ? 1 : 0);
+
+                for(int i=0; i<olc; i++)
+                    marina.instrIn.fill(DEC);
+
                 adjustIndent(-2);
             }
         }
@@ -655,7 +669,7 @@ public class MarinaTest {
         
         int olc = marina.getOLC();
         prln("OLC=="+olc);
-        
+
         Ilc ilc = marina.getILC();
         prln("ILC.done=="+ilc.getDone()+
              " ILC.infinity=="+ilc.getInfinity()+
@@ -665,6 +679,7 @@ public class MarinaTest {
         adjustIndent(-2);
         prln("end getCtrsFlags");
     }
+
     private void walkOneOLC(Marina marina) {
         prln("Begin walkOneOLC");
         adjustIndent(2);
@@ -736,13 +751,14 @@ public class MarinaTest {
     }
     // 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);
@@ -777,6 +793,14 @@ public class MarinaTest {
     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   */
@@ -901,7 +925,6 @@ public class MarinaTest {
         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
             });
@@ -925,6 +948,7 @@ public class MarinaTest {
             });
         marina.fillNorthProperStopper();
         expectNorthFifoExactly(1);
+        marina.instrIn.fill(DEC);
 
         marina.fillSouthProperStopper(new Instruction[] {
                 RECV_DATA,
@@ -939,10 +963,10 @@ public class MarinaTest {
     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);
@@ -951,11 +975,11 @@ public class MarinaTest {
         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();
@@ -964,6 +988,28 @@ public class MarinaTest {
         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[] {
@@ -1002,7 +1048,7 @@ public class MarinaTest {
     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 
@@ -1045,7 +1091,7 @@ public class MarinaTest {
     }
 
     private void testAbort(Marina marina) {
-
+        
         marina.instrIn.fill(setIlc(1));
         marina.fillSouthProperStopper(new Instruction[] {
                 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.DataLatch,1),
@@ -1058,28 +1104,28 @@ public class MarinaTest {
                 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());
-
+            
         }
     }
 
@@ -1127,7 +1173,7 @@ public class MarinaTest {
                     marina.fillSouthProperStopper(new Instruction[] {
                             RECV_DATA,
                             inst,
-                            setOlc(1),
+                            NOP,
                         });
                     model.waitNS(64 * CYCLE_TIME_NS);
                     marina.fillNorthProperStopper();
@@ -1321,6 +1367,8 @@ public class MarinaTest {
                     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); 
         }
@@ -1370,9 +1418,7 @@ public class MarinaTest {
                 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");       
@@ -1391,6 +1437,7 @@ public class MarinaTest {
                                         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());
@@ -1444,6 +1491,7 @@ public class MarinaTest {
                     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());
 
@@ -1505,6 +1553,7 @@ public class MarinaTest {
                                              false,                 /* dataOut     */
                                              false                  /* tokenOut    */
                                              ),
+                        FLAG_NOP,
                         new Instruction.Set(dock,Predicate.IgnoreFlagD,
                                             Instruction.Set.FlagFunction.ZERO.add(Predicate.FlagC),
                                             CLEAR_FLAG
@@ -1661,10 +1710,12 @@ public class MarinaTest {
         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");
@@ -1698,7 +1749,7 @@ public class MarinaTest {
 
         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");
@@ -1708,6 +1759,7 @@ public class MarinaTest {
         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");
                 
@@ -1813,7 +1865,7 @@ public class MarinaTest {
             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] =
@@ -1834,6 +1886,11 @@ public class MarinaTest {
             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);
@@ -1855,6 +1912,8 @@ public class MarinaTest {
                     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();
@@ -1865,6 +1924,8 @@ public class MarinaTest {
                     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();
@@ -1892,7 +1953,8 @@ public class MarinaTest {
                     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);
@@ -1904,6 +1966,7 @@ public class MarinaTest {
                     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");
@@ -2000,8 +2063,8 @@ public class MarinaTest {
                     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);
@@ -2011,10 +2074,9 @@ public class MarinaTest {
                     doOneTest(3021);
                     doOneTest(3024);
                     doOneTest(3025);
-
+                    
                     // this takes an insanely long time
                     doOneTest(3017);
-
                     break;
                 }
                 case 1:    testChains(marina);                     break; // passes, 24-Mar (+verilog)