further cleanup of MarinaTest
[fleet.git] / src / edu / berkeley / fleet / marina / Marina.java
index 6da458e..5b74b5a 100644 (file)
@@ -3,18 +3,18 @@ import edu.berkeley.fleet.api.*;
 import com.sun.electric.tool.simulation.test.*;
 import com.sun.electric.tool.simulation.test.BitVector;
 
-public class Marina {
+public class Marina extends MarinaFleet {
 
     JtagLogicLevel mc0;
     JtagLogicLevel mc1;
     private final Indenter indenter;
+
     public final ChainControl controlChain;
     public final ChainControl dataChain;
     public final ChainControl dukeChain;
     public final ChainControl reportChain;
+
     private final ChipModel model;
-    public final ProperStopper data;
-    public final InstructionStopper instrIn;
     public final ProperStopper      northRing;
     public final InstructionStopper southRing;
     int northCount = 0;
@@ -33,22 +33,22 @@ public class Marina {
         this.reportChain = reportChain;
         this.model = model;
         this.indenter = indenter;
-        northRing = data = new ProperStopper(prefix+"northFif@1.fillDrai@1",
-                                 controlChain,
-                                 dataChain,
-                                 reportChain,
-                                 model,
-                                 clockHack,
-                                 indenter,
-                                 prefix+"northFif@1.fillDrai@1.instruct@0.cntScnTh@1.cntScnOn@1");
-        southRing = instrIn = new InstructionStopper(prefix+"southFif@1.tapPropS@1", 
-                                         controlChain,
-                                         dataChain,
-                                         reportChain,
-                                         model,
-                                         clockHack,
-                                         indenter,
-                                         prefix+"southFif@1.tapPropS@1.instruct@0.cntScnTh@1.cntScnOn@1");
+        northRing = new ProperStopper(prefix+"northFif@1.fillDrai@1",
+                                      controlChain,
+                                      dataChain,
+                                      reportChain,
+                                      model,
+                                      clockHack,
+                                      indenter,
+                                      prefix+"northFif@1.fillDrai@1.instruct@0.cntScnTh@1.cntScnOn@1");
+        southRing = new InstructionStopper(prefix+"southFif@1.tapPropS@1", 
+                                           controlChain,
+                                           dataChain,
+                                           reportChain,
+                                           model,
+                                           clockHack,
+                                           indenter,
+                                           prefix+"southFif@1.tapPropS@1.instruct@0.cntScnTh@1.cntScnOn@1");
     }
 
     public static final int INDEX_OF_ADDRESS_BIT_COPIED_TO_C_FLAG_WHEN_DC_EQUALS_ONE  = 5;
@@ -85,7 +85,7 @@ public class Marina {
         // value is bit reversed and complemented
         private int value;
         private Ilc() {
-            shiftReport(true, false);
+            reportChain.shift(REPORT_CHAIN, true, false);
             BitVector odd  = reportChain.getOutBits(REPORT_CHAIN+"."+ILC_PATH_ODD).bitReverse().not();
             BitVector even = reportChain.getOutBits(REPORT_CHAIN+"."+ILC_PATH_EVEN).bitReverse().not();
             BitVector ret  = new BitVector(8, "olc");
@@ -112,39 +112,19 @@ public class Marina {
         }
     }
         
-    /** Shift the report scan chain */
-    public void shiftReport(boolean readEnable, boolean writeEnable) {
-        reportChain.shift(REPORT_CHAIN, readEnable, writeEnable);
-    }
-    
-    /** Shift the report scan chain */
-    private void shiftControl(boolean readEnable, boolean writeEnable) {
-        controlChain.shift(CONTROL_CHAIN, readEnable, writeEnable);
-    }
-        
-    /** Shift the data scan chain */
-    private void shiftData(boolean readEnable, boolean writeEnable) {
-        dataChain.shift(DATA_CHAIN, readEnable, writeEnable);
-    }
-
-    /** Shift the data scan chain */
-    public void shiftDuke(boolean readEnable, boolean writeEnable) {
-        dukeChain.shift(DUKE_CHAIN, readEnable, writeEnable);
-    }
-
     public void stopAndResetCounters() {
-        instrIn.setCounterEnable(false);
-        data.setCounterEnable(false);
+        southRing.setCounterEnable(false);
+        northRing.setCounterEnable(false);
         dataChain.shift(DATA_CHAIN, true, false);        
-        northCount = data.getCounterValue();
-        southCount = instrIn.getCounterValue();
-        data.setCounterValue(0);
-        instrIn.setCounterValue(0);
+        northCount = northRing.getCounterValue();
+        southCount = southRing.getCounterValue();
+        northRing.setCounterValue(0);
+        southRing.setCounterValue(0);
     }
     public void startCounters() { startCounters(true, true); }
     public void startCounters(boolean south, boolean north) {
-        instrIn.setCounterEnable(south);
-        data.setCounterEnable(north);
+        southRing.setCounterEnable(south);
+        northRing.setCounterEnable(north);
     }
     public int getNorthCount() { return northCount; }
     public int getSouthCount() { return southCount; }
@@ -154,8 +134,8 @@ public class Marina {
         // Put a high going pulse on the internal chip master clear signal
         if (model instanceof VerilogModel) {
 
-            data.clear();
-            instrIn.clear();
+            northRing.clear();
+            southRing.clear();
 
             VerilogModel vm = (VerilogModel)model;
             //
@@ -248,8 +228,8 @@ public class Marina {
             // state, so under Verilog we need to force them to a
             // known state
 
-            data.idle();
-            instrIn.idle();
+            northRing.idle();
+            southRing.idle();
 
         } else if (model instanceof NanosimModel) {
             NanosimModel nModel = (NanosimModel) model;
@@ -277,37 +257,26 @@ public class Marina {
             model.waitNS(1000);
 
         }
-        resetAfterMasterClear();
-    }
 
-    private void resetAfterMasterClear() {
         // The following call to ChainControl.resetInBits() is vital!
         // If you forget, then the inBits member initializes 
-        // with random data. Then when you do your first write,
+        // with random northRing. Then when you do your first write,
         // some bits are written randomly.
+        controlChain.resetInBits();
         dataChain.resetInBits();
         dukeChain.resetInBits();
         reportChain.resetInBits();
-        controlChain.resetInBits();
 
-        // For reset, I want to clear all the stoppers simultaneously
-        data.clear();
-        //tokOut.clear();
-        instrIn.clear();
-        
-        data.stop();
-        //tokOut.stop();
-        instrIn.stop();
-        
-        data.resetAfterMasterClear();
-        //tokOut.resetAfterMasterClear();
-        instrIn.resetAfterMasterClear();
+        northRing.clear();
+        southRing.clear();
+        northRing.stop();
+        southRing.stop();
     }
 
 
     /** Get the 6 bit outer loop counter. */
     public int getOLC() {
-        shiftReport(true, false);
+        reportChain.shift(REPORT_CHAIN, true, false);
         if (omegaCounter) {
             BitVector bits = null;
             for(int i=0; i<4; i++) {
@@ -399,11 +368,11 @@ public class Marina {
     public boolean getILCDone() { return new Ilc().getDone(); }
     public int getILC() { return new Ilc().getCount(); }
     public boolean getFlagA() {
-        shiftReport(true, false);
+        reportChain.shift(REPORT_CHAIN, true, false);
         return reportChain.getOutBits(REPORT_CHAIN+"."+FLAGS_PATH).get(0);
     }
     public boolean getFlagB() {
-        shiftReport(true, false);
+        reportChain.shift(REPORT_CHAIN, true, false);
         return reportChain.getOutBits(REPORT_CHAIN+"."+FLAGS_PATH).get(1);
     }
     /** get the number of tokens in the token FIFO.
@@ -411,7 +380,7 @@ public class Marina {
      * and Token predecessor wire.
      * Master clear clears the token FIFO. */
     public int getNumTokens() {
-        shiftReport(true, false);
+        reportChain.shift(REPORT_CHAIN, true, false);
         // get the token successor and token FIFO wires
         BitVector bv = reportChain.getOutBits(REPORT_CHAIN+"."+TOK_FIFO_PATH);
         int sz = bv.getNumBits();