remove chain name arguments from proper stopper constructors
[fleet.git] / src / com / sun / vlsi / chips / marina / test / Marina.java
index 87a3c95..134e4a0 100644 (file)
@@ -1,11 +1,6 @@
 package com.sun.vlsi.chips.marina.test;
 /* -*- tab-width: 4 -*- */
-import com.sun.async.test.BitVector;
-import com.sun.async.test.ChainControl;
-import com.sun.async.test.ChipModel;
-import com.sun.async.test.JtagTester;
-import com.sun.async.test.NanosimModel;
-import com.sun.async.test.VerilogModel;
+import com.sun.electric.tool.simulation.test.*;
 
 import edu.berkeley.fleet.api.Instruction;
 import edu.berkeley.fleet.marina.MarinaPath;
@@ -42,7 +37,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
@@ -109,7 +104,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;
@@ -118,7 +113,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);
     }
     
@@ -132,23 +127,45 @@ public class Marina {
         cc.shift(DATA_CHAIN, readEnable, writeEnable);
     }
 
+    /** Shift the data scan chain */
+    public void shiftDuke(boolean readEnable, boolean writeEnable) {
+        cc.shift(DUKE_CHAIN, readEnable, writeEnable);
+    }
+
     public Marina(ChainControls cc, ChipModel model, boolean clockHack, Indenter indenter) {
         this.cc = cc;
         this.model = model;
         this.indenter = indenter;
         data = new ProperStopper("north fifo",
                                  prefix+"northFif@1.fillDrai@1.properSt@1",
-                                 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
@@ -268,10 +285,21 @@ public class Marina {
             nModel.setNodeVoltage(MASTER_CLEAR,0.0);
             nModel.waitNS(1);
         } else {
-            prln("FIXME!");
+
+            mc0.setLogicState(true);
+            mc1.setLogicState(true);
+            model.waitNS(1000);
+            mc0.setLogicState(false);
+            mc1.setLogicState(false);
+            model.waitNS(1000);
+
         }
         resetAfterMasterClear();
     }
+
+    JtagLogicLevel mc0;
+    JtagLogicLevel mc1;
+
     private void resetAfterMasterClear() {
         // The following call to ChainControl.resetInBits() is vital!
         // If you forget, then the inBits member initializes 
@@ -342,8 +370,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();
@@ -469,16 +523,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();
     }