sendToken runs
authorrkao <rkao>
Fri, 7 Nov 2008 21:30:01 +0000 (21:30 +0000)
committerrkao <rkao>
Fri, 7 Nov 2008 21:30:01 +0000 (21:30 +0000)
testCode/com/sun/vlsi/chips/marina/test/InstructionStopper.java
testCode/com/sun/vlsi/chips/marina/test/MarinaTest.java

index c17b773..8e747ed 100644 (file)
@@ -14,10 +14,17 @@ import edu.berkeley.fleet.marina.MarinaFleet;
 /** InstructionStopper is a scaffold that lets us create a 36 bit propperStopper
  * by using a 52 bit propperStopper and throwing away the unused bits. */
 public class InstructionStopper extends ProperStopper {
+       public static final BitVector TORPEDO;
        public static final int INSTR_SZ = 36;
     public static final MarinaFleet MARINA = new MarinaFleet();
     public static final Dock DOCK = MARINA.getOnlyInputDock();
 
+    static {
+               BitVector d = new BitVector(37, "token");  d.setFromLong(0);
+       BitVector t = new BitVector(1, "token");   t.setFromLong(0);
+       BitVector a = new BitVector(14, "addr");   a.setFromLong(0);
+               TORPEDO = d.cat(t).cat(a); 
+    }
        // Convert a Berkeley BitVector into a Sun BitVector
        private BitVector berkToSun(edu.berkeley.fleet.api.BitVector berkBits) {
         BitVector sunBits = new BitVector(INSTR_SZ, "instr");
@@ -42,10 +49,12 @@ public class InstructionStopper extends ProperStopper {
                                          ChainControl cc, ChipModel model,
                                          Indenter indenter) {
                super(propInst, controlChain, dataChain, reportChain, cc, model, indenter);
-               
        }
        @Override
     public void fill(BitVector instr) {
+               // allow user to pass in complete item: data + token + addr
+               if (instr.getNumBits()==(37+1+14)) {super.fill(instr); return;}
+               
                int n = instr.getNumBits();
        fatal(n!=INSTR_SZ, "InstructionStopper.fill: wrong num bits: "+n+", expect: "+INSTR_SZ);
                fatal(INSTR_SZ>37, "Instructions can't be more than 37 bits");
index 4efe298..3aa18ab 100644 (file)
@@ -36,7 +36,17 @@ public class MarinaTest {
        public static final int INSTR_SZ = 36;
        
        public static final Dock DOCK = InstructionStopper.DOCK;
-
+    public static final Instruction.Set.FlagFunction CLEAR_FLAG 
+       = Instruction.Set.FlagFunction.ZERO;
+    public static final Instruction.Set.FlagFunction SET_FLAG 
+        = Instruction.Set.FlagFunction.ZERO.add(Predicate.FlagA)
+                                           .add(Predicate.NotFlagA);
+    public static final Instruction.Set.FlagFunction A_FLAG 
+        = Instruction.Set.FlagFunction.ZERO.add(Predicate.FlagA);
+
+    public static final Instruction.Set.FlagFunction B_FLAG 
+       = Instruction.Set.FlagFunction.ZERO.add(Predicate.FlagB);
+    
        // COLUMN_LATENCY is a delay that is larger than the latency through an Infinity column
        private static final int COLUMN_LATENCY = 10; // nanoseconds
        
@@ -502,6 +512,7 @@ public class MarinaTest {
 
         Instruction.Set.FlagFunction zero = Instruction.Set.FlagFunction.ZERO;
         Instruction.Set.FlagFunction one  = zero;
+
         
         // we should be able to use any pair of FlagX+NotFlagX,
         // but we toss them all in to maximize the chances of the
@@ -530,6 +541,78 @@ public class MarinaTest {
        adjustIndent(-2);
        prln("End testFlagAB");         
     }
+    private void sendTorpedo(IsolatedInDock inDock) {
+       prln("Begin sendTorpedo");
+       adjustIndent(2);
+       
+       prln("OLC = 63");
+               inDock.instrIn.fill(new 
+                       Instruction.Set(DOCK,false,Predicate.IgnoreOLC,SetDest.OuterLoopCounter, 63));
+
+               int olc = inDock.getOLC();
+               fatal(olc!=63, "bad OLC: "+olc+" expected: 63");
+
+               prln("A=0, B=0");
+               inDock.instrIn.fill(new 
+            Instruction.Set(DOCK,false,Predicate.IgnoreOLC, CLEAR_FLAG, CLEAR_FLAG));
+
+               fatal(inDock.getFlagA(), "bad A flag: true");
+               fatal(inDock.getFlagB(), "bad B flag: true");
+               
+               prln("ILC = Infinity");
+               inDock.instrIn.fill(new 
+               Instruction.Set(DOCK,false,Predicate.IgnoreOLC,SetDest.InnerLoopCounter, SetSource.Infinity));
+               
+               prln("execute a move instruction that does nothing but loops until torpedo arrives"); 
+        inDock.instrIn.fill(
+            new Instruction.Move(DOCK,
+                                    false,                             /* requeueing */
+                                 Predicate.IgnoreOLC,   /* predicate   */
+                                 true,                 /* torpedoable */
+                                 null,                  /* path        */
+                                 false,                 /* tokenIn     */
+                                 false,                 /* dataIn      */
+                                 false,                 /* latchData   */
+                                 false,                 /* latchPath   */
+                                 false,                 /* dataOut     */
+                                 false                  /* tokenOut    */
+                                 ));
+        
+               prln("NOP This instruction can't predicate on OLC because of a hardware bug");
+               inDock.instrIn.fill(new 
+            Instruction.Set(DOCK,false,Predicate.Default, CLEAR_FLAG, CLEAR_FLAG));
+
+               prln("A=1, B=1 This instruction should get torpedoed along with the Move");
+               inDock.instrIn.fill(new 
+                       Instruction.Set(DOCK,false,Predicate.Default, SET_FLAG, SET_FLAG));
+
+               prln("send torpedo. This should clear the OLC");
+               inDock.instrIn.fill(InstructionStopper.TORPEDO);
+               
+               getCtrsFlags(inDock);
+               
+               prln("A and B should remain false");
+               fatal(inDock.getFlagA(), "bad A flag: true");
+               fatal(inDock.getFlagB(), "bad B flag: true");
+       
+       prln("OLC = 63. Reload OLC after torpedo");
+               inDock.instrIn.fill(new 
+                       Instruction.Set(DOCK,false,Predicate.IgnoreOLC,SetDest.OuterLoopCounter, 63));
+
+               olc = inDock.getOLC();
+               fatal(olc!=63, "bad OLC: "+olc+" expected: 63");
+               
+               prln("A=1, B=1 This instruction should execute because OLC!=0");
+               inDock.instrIn.fill(new 
+                       Instruction.Set(DOCK,false,Predicate.Default, SET_FLAG, SET_FLAG));
+
+               prln("A and B should be true");
+               fatal(!inDock.getFlagA(), "bad A flag: false");
+               fatal(!inDock.getFlagB(), "bad B flag: false");
+               
+               adjustIndent(-2);
+       prln("End sendTorpedo");        
+    }    
        private void doOneTest(int testNum) {
         prln("MarinaTest: performing test: "+testNum);
         design.masterClear(tester);
@@ -546,6 +629,7 @@ public class MarinaTest {
                case 1000:              walkOneILC((IsolatedInDock)design);                     break;
                case 1001:              countIlc((IsolatedInDock)design);                               break;
                case 1002:              countOlc((IsolatedInDock)design);                               break;
+               case 1003:              sendTorpedo((IsolatedInDock)design);                    break;
                
                // Bill's tests begin with 2000
                case 2000: break;