lots of changes to Marina test code, mostly for scan chain counters
[fleet.git] / src / com / sun / vlsi / chips / marina / test / Marina.java
index 759662d..5aa6dae 100644 (file)
@@ -43,7 +43,7 @@ public class Marina {
         prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.olcWcont@0.scanEx3h@1"; // bits 2,4,6
     private static final String OLC_PATH_ODD = 
         prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.olcWcont@0.scanEx3h@2"; // bits 1,3,5
-    private static final String OLC_PATH_KESSEL = 
+    public static final String OLC_PATH_KESSEL = 
         prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.counte@0.adamScan@1.scanEx6h@";
     private static final String ILC_PATH_ODD = 
         prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.ilcMoveO@0.scanEx4h@0"; // bits 1,3,5,7
@@ -110,7 +110,7 @@ public class Marina {
 
     // The name of the scan chain
     // The instance path, from the top cell of the netlist, of the instance of infinityWithCover 
-    private final ChainControls cc;           // specifies the scan chain
+    public final ChainControls cc;           // specifies the scan chain
     private final ChipModel model;
     public final ProperStopper data;
     public final InstructionStopper instrIn;
@@ -119,7 +119,7 @@ public class Marina {
     private void pr(String msg) {indenter.pr(msg);}
     
     /** Shift the report scan chain */
-    private void shiftReport(boolean readEnable, boolean writeEnable) {
+    public void shiftReport(boolean readEnable, boolean writeEnable) {
         cc.shift(REPORT_CHAIN, readEnable, writeEnable);
     }
     
@@ -142,14 +142,37 @@ public class Marina {
                                  CONTROL_CHAIN, 
                                  DATA_CHAIN,  
                                  REPORT_CHAIN,
-                                 cc, model, clockHack, indenter);
+                                 cc, model, clockHack, indenter,
+                                 prefix+"northFif@1.fillDrai@1.instruct@0.cntScnTh@1.cntScnOn@1");
         instrIn = new InstructionStopper("south fifo",
                                          prefix+"southFif@1.tapPropS@1.properSt@1", 
                                          CONTROL_CHAIN,
                                          DATA_CHAIN,
                                          REPORT_CHAIN,
-                                         cc, model, clockHack, indenter);
+                                         cc, model, clockHack, indenter,
+                                         prefix+"southFif@1.tapPropS@1.instruct@0.cntScnTh@1.cntScnOn@1");
     }
+
+    int northCount = 0;
+    int southCount = 0;
+
+    public void stopAndResetCounters() {
+        instrIn.setCounterEnable(false);
+        data.setCounterEnable(false);
+        cc.shift(DATA_CHAIN, true, false);        
+        northCount = data.getCounterValue();
+        southCount = instrIn.getCounterValue();
+        data.setCounterValue(0);
+        instrIn.setCounterValue(0);
+    }
+    public void startCounters() {
+        instrIn.setCounterEnable(true);
+        data.setCounterEnable(true);
+    }
+    public int getNorthCount() { return northCount; }
+    public int getSouthCount() { return southCount; }
+
+
     public void masterClear() {
         final double WIDTH = 10; // ns
         // Put a high going pulse on the internal chip master clear signal
@@ -269,12 +292,14 @@ public class Marina {
             nModel.setNodeVoltage(MASTER_CLEAR,0.0);
             nModel.waitNS(1);
         } else {
+
             mc0.setLogicState(true);
             mc1.setLogicState(true);
             model.waitNS(1000);
             mc0.setLogicState(false);
             mc1.setLogicState(false);
             model.waitNS(1000);
+
         }
         resetAfterMasterClear();
     }
@@ -352,8 +377,34 @@ public class Marina {
             //System.out.println("kesselsCounter = " + bits);
             int first = 0;
             int second = 0;
-            for(int i=0; i<6; i++) first  |= bits.get(4+i*3)   ? (1<<i) : 0;
-            for(int i=0; i<6; i++) second |= bits.get(4+i*3+2) ? (1<<i) : 0;
+            String hi="";
+            String lo="";
+            String latched="";
+            String res="";
+            for(int i=0; i<6; i++) {
+                first  |= bits.get(4+i*3)   ? (1<<i) : 0;
+                second |= bits.get(4+i*3+2) ? (1<<i) : 0;
+                hi = (bits.get(4+i*3)   ? "1" : "0") + hi;
+                lo = (bits.get(4+i*3+2)   ? "1" : "0") + lo;
+                res =
+                    (   bits.get(4+i*3) && !bits.get(4+i*3+2) ? "X"
+                     : !bits.get(4+i*3) && !bits.get(4+i*3+2) ? "0"
+                     : !bits.get(4+i*3) &&  bits.get(4+i*3+2) ? "1"
+                     : "2")
+                    +res;
+                latched = (bits.get(4+i*3+1)   ? "0" : "1") + latched;
+            }
+            System.out.println("kesselsCounter: "+
+                               "s[1]="+hi+
+                               " s[3]="+lo+
+                               " latched="+latched +
+                               " res="+res+
+                               " do[ins]="+(bits.get(0) ? "1" : "0")+
+                               " dec="+(bits.get(1) ? "1" : "0")+
+                               " flag[D][set]="+(bits.get(2) ? "1" : "0")+
+                               " resetting="+(bits.get(3) ? "1" : "0")+
+                               ""
+                               );
             return (first+second);
         } else {
             BitVector odd = cc.getOutBits(REPORT_CHAIN+"."+OLC_PATH_ODD).bitReverse();
@@ -479,16 +530,23 @@ public class Marina {
         instrIn.setGeneralPurposeOutput(b);
     }
 
+    public void fillSouthProperStopper(Instruction i) {
+        instrIn.fill(i);
+    }
     public void fillSouthProperStopper(Instruction[] instructions) { fillSouthProperStopper(instructions, false); }
-    public void fillSouthProperStopper(Instruction[] instructions, boolean repeat) {
+    public void fillSouthProperStopper(Instruction[] instructions, boolean repeat) { fillSouthProperStopper(instructions, repeat, false); }
+    public void fillSouthProperStopper(Instruction[] instructions, boolean repeat, boolean leaveStopped) {
         enableInstructionSend(false);
         enableInstructionRecirculate(true);
         for(Instruction i : instructions)
-            if (i!=null)
+            if (i!=null) {
                 instrIn.fill(i);
+            } else {
+                instrIn.fillTorpedo();
+            }
         enableInstructionRecirculate(repeat);
         enableInstructionSend(true);
-        instrIn.run();
+        if (!leaveStopped) instrIn.run();
     }