cleanup of Marina test code
authorAdam Megacz <adam@megacz.com>
Fri, 20 Nov 2009 06:05:35 +0000 (22:05 -0800)
committerAdam Megacz <adam@megacz.com>
Fri, 20 Nov 2009 06:05:35 +0000 (22:05 -0800)
src/edu/berkeley/fleet/marina/InstructionStopper.java
src/edu/berkeley/fleet/marina/Marina.java
src/edu/berkeley/fleet/marina/MarinaTest.java
src/edu/berkeley/fleet/marina/ProperStopper.java

index f88d0c4..530724f 100644 (file)
@@ -17,15 +17,19 @@ import static edu.berkeley.fleet.marina.Marina.INSTRUCTION_LENGTH;
  */
 public class InstructionStopper extends ProperStopper {
 
-    public InstructionStopper(String name,
-                              String propInst,
+    private static final int INSTRUCTION_SEND_NDX = 1;
+    private static final int INSTRUCTION_RECIRCULATE_NDX = 0;
+    private final String INSTR_RING_CONTROL_PATH;
+
+    public InstructionStopper(String propInst,
                               ChainControl controlChain,
                               ChainControl dataChain,
                               ChainControl reportChain,
                               ChipModel model,
                               boolean clockHack,
                               Indenter indenter, String counterPath) {
-        super(name, propInst, controlChain, dataChain, reportChain, model, clockHack, indenter, counterPath);
+        super(propInst, controlChain, dataChain, reportChain, model, clockHack, indenter, counterPath);
+        INSTR_RING_CONTROL_PATH = propInst+".tapStage@2";
     }
 
     /** put one Instruction into InstructionStopper */
@@ -42,4 +46,32 @@ public class InstructionStopper extends ProperStopper {
         MarinaTest.indenter.prln("  inserting torpedo");
         super.fill(new MarinaPacket(MarinaPacket.null_word, true, MarinaPacket.null_path));
     }
+
+    public void fill(Instruction[] instructions) { fill(instructions, false); }
+    public void fill(Instruction[] instructions, boolean repeat) { fill(instructions, repeat, false); }
+    public void fill(Instruction[] instructions, boolean repeat, boolean leaveStopped) {
+        enableInstructionSend(false);
+        enableInstructionRecirculate(true);
+        for(Instruction i : instructions)
+            if (i!=null) {
+                fill(i);
+            } else {
+                fillTorpedo();
+            }
+        enableInstructionRecirculate(repeat);
+        enableInstructionSend(true);
+        if (!leaveStopped) run();
+    }
+    public void enableInstructionSend(boolean b) {
+        BitVector bv = controlChain.getInBits(Marina.CONTROL_CHAIN+"."+INSTR_RING_CONTROL_PATH);
+        bv.set(INSTRUCTION_SEND_NDX, b);
+        controlChain.setInBits(Marina.CONTROL_CHAIN+"."+INSTR_RING_CONTROL_PATH, bv); 
+        controlChain.shift(Marina.CONTROL_CHAIN, false, true);
+    } 
+    public void enableInstructionRecirculate(boolean b) {
+        BitVector bv = controlChain.getInBits(Marina.CONTROL_CHAIN+"."+INSTR_RING_CONTROL_PATH);
+        bv.set(INSTRUCTION_RECIRCULATE_NDX, b);
+        controlChain.setInBits(Marina.CONTROL_CHAIN+"."+INSTR_RING_CONTROL_PATH, bv); 
+        controlChain.shift(Marina.CONTROL_CHAIN, false, true);
+    }
 }
index 28e293c..6da458e 100644 (file)
@@ -1,25 +1,65 @@
 package edu.berkeley.fleet.marina;
-/* -*- tab-width: 4 -*- */
+import edu.berkeley.fleet.api.*;
 import com.sun.electric.tool.simulation.test.*;
+import com.sun.electric.tool.simulation.test.BitVector;
 
-import edu.berkeley.fleet.api.Instruction;
-import edu.berkeley.fleet.marina.MarinaPath;
-
-/** The Marina object will eventually represent the Marina test chip.  
- * Right now, it doesn't do much of anything. It just helps me exercise
- * my test infrastructure. */
 public class Marina {
 
+    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;
+    int southCount = 0;
+
+    public Marina(ChainControl controlChain,
+                  ChainControl dataChain,
+                  ChainControl dukeChain,
+                  ChainControl reportChain,
+                  ChipModel model,
+                  boolean clockHack,
+                  Indenter indenter) {
+        this.controlChain = controlChain;
+        this.dataChain = dataChain;
+        this.dukeChain = dukeChain;
+        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");
+    }
+
     public static final int INDEX_OF_ADDRESS_BIT_COPIED_TO_C_FLAG_WHEN_DC_EQUALS_ONE  = 5;
     public static final int INDEX_OF_ADDRESS_BIT_COPIED_TO_C_FLAG_WHEN_DC_EQUALS_ZERO = MarinaPath.SIGNAL_BIT_INDEX;
-
        
-    public static int TOKEN_FIFO_CAPACITY = 3;
-    
-    //public static final boolean kesselsCounter = true;
+    private static final int COUNTER_LENGTH = 34;
+    public static final int INSTRUCTION_LENGTH = 36;
+    public static final int SOUTH_RING_CAPACITY = 11;
+    public static final int TOKEN_FIFO_CAPACITY = 3;
     public static final boolean kesselsCounter = false;
     public static final boolean omegaCounter = false;
-
     public static final String DATA_CHAIN =    kesselsCounter ? "marina.marina_data" : "marina.ivan_data";      
     public static final String CONTROL_CHAIN = kesselsCounter ? "marina.marina_control" : "marina.ivan_control";
     public static final String REPORT_CHAIN =  kesselsCounter ? "marina.marina_report" : "marina.ivan_report";
@@ -28,49 +68,20 @@ public class Marina {
     public static String prefix = "marinaGu@0.outDockW@"+(kesselsCounter?"3":"0")+".marinaOu@"+(kesselsCounter?"1":"0")+".";
     public static String MASTER_CLEAR = "mc";
 
-
-    /*
-    private static String prefix = "outDockW@"+(kesselsCounter?"3":"0")+".marinaOu@1.";
-    private static String MASTER_CLEAR = "EXTmasterClear";
-    */
-
-    private static final String OLC_PATH_EVEN = 
-        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
-    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
-    private static final String ILC_PATH_EVEN = 
-        prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.ilcMoveO@0.scanEx4h@1"; // bits 2,4,6,8
-    private static final String FLAGS_PATH = 
-        prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.flags@0.scanEx3h@0";
-
-    private static final String INSTR_RING_CONTROL_PATH = 
-        prefix+"southFif@1.tapPropS@1.tapStage@2";
-    private static final String TOK_FIFO_PATH =
-        prefix+"tokenFIF@1";
-    private static final String INSTRUCTION_COUNTER_PATH =
-        prefix+"southFif@1.tapPropS@1.instruct@0";
-    private static final String DATA_COUNTER_PATH =
-        prefix+"northFif@1.fillDrai@1.instruct@0";
-    private static final String TOK_PRED_PATH =
-        prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.ilcMoveO@0.scanEx2h@0.scanCell@10";
-
-    private static final int COUNTER_LENGTH = 34;
-    private static final int INSTRUCTION_SEND_NDX = 1;
-    private static final int INSTRUCTION_RECIRCULATE_NDX = 0;
-
-    public static final int INSTRUCTION_LENGTH = 36;
-        
-    private static final int A_FLAG_NDX = 0;
-    private static final int B_FLAG_NDX = 1;
-        
-    public static final int SOUTH_RING_CAPACITY = 11;
+    private static final String CENTER_PATH = prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0";
+    private static final String OLC_PATH_EVEN = CENTER_PATH+".olcWcont@0.scanEx3h@1"; // bits 2,4,6
+    private static final String OLC_PATH_ODD = CENTER_PATH+".olcWcont@0.scanEx3h@2"; // bits 1,3,5
+    private static final String OLC_PATH_KESSEL = CENTER_PATH+".counte@0.adamScan@1.scanEx6h@";
+    private static final String ILC_PATH_ODD = CENTER_PATH+".ilcMoveO@0.scanEx4h@0"; // bits 1,3,5,7
+    private static final String ILC_PATH_EVEN = CENTER_PATH+".ilcMoveO@0.scanEx4h@1"; // bits 2,4,6,8
+    private static final String FLAGS_PATH = CENTER_PATH+".flags@0.scanEx3h@0";
+    private static final String TOK_FIFO_PATH = prefix+"tokenFIF@1";
+    private static final String INSTRUCTION_COUNTER_PATH = prefix+"southFif@1.tapPropS@1.instruct@0";
+    private static final String DATA_COUNTER_PATH =prefix+"northFif@1.fillDrai@1.instruct@0";
+    private static final String TOK_PRED_PATH = CENTER_PATH+".ilcMoveO@0.scanEx2h@0.scanCell@10";
         
     // ILC appears in scan chain as "count[1:6], zLo, i, dLo"
-    public class Ilc {
+    private class Ilc {
         // value is bit reversed and complemented
         private int value;
         private Ilc() {
@@ -101,22 +112,6 @@ public class Marina {
         }
     }
         
-    private final Indenter indenter;
-
-    // The name of the scan chain
-    // The instance path, from the top cell of the netlist, of the instance of infinityWithCover 
-    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;
-    
-    private void prln(String msg) {indenter.prln(msg);}
-    private void pr(String msg) {indenter.pr(msg);}
-    
     /** Shift the report scan chain */
     public void shiftReport(boolean readEnable, boolean writeEnable) {
         reportChain.shift(REPORT_CHAIN, readEnable, writeEnable);
@@ -137,36 +132,6 @@ public class Marina {
         dukeChain.shift(DUKE_CHAIN, readEnable, writeEnable);
     }
 
-    public Marina(ChainControl controlChain,
-                  ChainControl dataChain,
-                  ChainControl dukeChain,
-                  ChainControl reportChain,
-                  ChipModel model, boolean clockHack, Indenter indenter) {
-        this.controlChain = controlChain;
-        this.dataChain = dataChain;
-        this.dukeChain = dukeChain;
-        this.reportChain = reportChain;
-        this.model = model;
-        this.indenter = indenter;
-        data = new ProperStopper("north fifo",
-                                 prefix+"northFif@1.fillDrai@1.properSt@1",
-                                 controlChain,
-                                 dataChain,
-                                 reportChain,
-                                 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", 
-                                         controlChain,
-                                         dataChain,
-                                         reportChain,
-                                         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);
@@ -184,7 +149,6 @@ public class Marina {
     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
@@ -199,16 +163,16 @@ public class Marina {
             // value.  In verilog we need to prevent the X'es from
             // propagating, so we force the flags to a known value
             //
-            vm.setNodeState(prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.flag_A__set_", 0);
-            vm.setNodeState(prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.flag_A__clr_", 1);
-            vm.setNodeState(prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.flag_B__set_", 0);
-            vm.setNodeState(prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.flag_B__clr_", 1);
+            vm.setNodeState(CENTER_PATH+".flag_A__set_", 0);
+            vm.setNodeState(CENTER_PATH+".flag_A__clr_", 1);
+            vm.setNodeState(CENTER_PATH+".flag_B__set_", 0);
+            vm.setNodeState(CENTER_PATH+".flag_B__clr_", 1);
 
-            vm.setNodeState(prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.flag_D__set_", 1);
-            vm.setNodeState(prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.flag_D__clr_", 0);
+            vm.setNodeState(CENTER_PATH+".flag_D__set_", 1);
+            vm.setNodeState(CENTER_PATH+".flag_D__clr_", 0);
 
-            vm.setNodeState(prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.flags@0.aFlag@0.net_50", 0);       // A
-            vm.setNodeState(prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.flags@0.aFlag@1.net_50", 0);       // B
+            vm.setNodeState(CENTER_PATH+".flags@0.aFlag@0.net_50", 0);       // A
+            vm.setNodeState(CENTER_PATH+".flags@0.aFlag@1.net_50", 0);       // B
             vm.setNodeState(prefix+"outputDo@0.outM1Pre@0.litDandP@0.latch2in@0.hi2inLat@0.latchKee@0.out_B_", 0); // C
 
             // possible C-flag inputs
@@ -218,12 +182,12 @@ public class Marina {
             // force the OLC to zero
             if (!kesselsCounter)
                 for(int i=1; i<=6; i++)
-                    vm.setNodeState(prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.olcWcont@0.olc@0.inLO["+i+"]", (i==1)?0:1);
+                    vm.setNodeState(CENTER_PATH+".olcWcont@0.olc@0.inLO["+i+"]", (i==1)?0:1);
 
             // set the ILC input to 1
             for(int i=1; i<=8; i++) {
                 if (i!=7)
-                    vm.setNodeState(prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.ilcMoveO@0.ilc@0.\\inLO["+i+"]", (i==1)?0:1);
+                    vm.setNodeState(CENTER_PATH+".ilcMoveO@0.ilc@0.\\inLO["+i+"]", (i==1)?0:1);
             }
 
             vm.setNodeState(prefix+"northFif@1.upDown8w@2.weakStag@22.addr1in2@0.fire", 1);
@@ -237,29 +201,29 @@ public class Marina {
             model.waitNS(1000);
 
             // pulse ilc[load] and olc[load]
-            vm.setNodeState(prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.ilcMoveO@0.ilc@0.ilc_load_", 1);
-            vm.setNodeState(prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.ilcMoveO@0.ilc@0.ilc_decLO_", 1);
-            vm.setNodeState(prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.ilcMoveO@0.ilc@0.ilc_torpLO_", 1);
+            vm.setNodeState(CENTER_PATH+".ilcMoveO@0.ilc@0.ilc_load_", 1);
+            vm.setNodeState(CENTER_PATH+".ilcMoveO@0.ilc@0.ilc_decLO_", 1);
+            vm.setNodeState(CENTER_PATH+".ilcMoveO@0.ilc@0.ilc_torpLO_", 1);
             if (!kesselsCounter)
-                vm.setNodeState(prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.olcWcont@0.olc@0.olc_load_", 1);
+                vm.setNodeState(CENTER_PATH+".olcWcont@0.olc@0.olc_load_", 1);
             model.waitNS(100);
             model.waitNS(1);
-            vm.releaseNode(prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.ilcMoveO@0.ilc@0.ilc_load_");
-            vm.releaseNode(prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.ilcMoveO@0.ilc@0.ilc_decLO_");
-            vm.releaseNode(prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.ilcMoveO@0.ilc@0.ilc_torpLO_");
+            vm.releaseNode(CENTER_PATH+".ilcMoveO@0.ilc@0.ilc_load_");
+            vm.releaseNode(CENTER_PATH+".ilcMoveO@0.ilc@0.ilc_decLO_");
+            vm.releaseNode(CENTER_PATH+".ilcMoveO@0.ilc@0.ilc_torpLO_");
             if (!kesselsCounter)
-                vm.releaseNode(prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.olcWcont@0.olc@0.olc_load_");
+                vm.releaseNode(CENTER_PATH+".olcWcont@0.olc@0.olc_load_");
 
-            vm.releaseNode(prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.flag_A__set_");
-            vm.releaseNode(prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.flag_A__clr_");
-            vm.releaseNode(prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.flag_B__set_");
-            vm.releaseNode(prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.flag_B__clr_");
+            vm.releaseNode(CENTER_PATH+".flag_A__set_");
+            vm.releaseNode(CENTER_PATH+".flag_A__clr_");
+            vm.releaseNode(CENTER_PATH+".flag_B__set_");
+            vm.releaseNode(CENTER_PATH+".flag_B__clr_");
 
-            vm.releaseNode(prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.flag_D__set_");
-            vm.releaseNode(prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.flag_D__clr_");
+            vm.releaseNode(CENTER_PATH+".flag_D__set_");
+            vm.releaseNode(CENTER_PATH+".flag_D__clr_");
 
-            vm.releaseNode(prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.flags@0.aFlag@0.net_50");
-            vm.releaseNode(prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.flags@0.aFlag@1.net_50");
+            vm.releaseNode(CENTER_PATH+".flags@0.aFlag@0.net_50");
+            vm.releaseNode(CENTER_PATH+".flags@0.aFlag@1.net_50");
 
             // Every move instruction, even those with Ti=0,Di=0,
             // loads the C-flag.  It will get loaded with an "X",
@@ -272,13 +236,13 @@ public class Marina {
 
             for(int i=1; i<=8; i++) {
                 if (i!=7)
-                    vm.releaseNode(prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.ilcMoveO@0.ilc@0.\\inLO["+i+"] ");
+                    vm.releaseNode(CENTER_PATH+".ilcMoveO@0.ilc@0.\\inLO["+i+"] ");
             }
             model.waitNS(1000);
 
             if (!kesselsCounter)
                 for(int i=1; i<=6; i++)
-                    vm.releaseNode(prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.olcWcont@0.olc@0.inLO["+i+"]");
+                    vm.releaseNode(CENTER_PATH+".olcWcont@0.olc@0.inLO["+i+"]");
 
             // the proper stopper states come up in an undefined ("X")
             // state, so under Verilog we need to force them to a
@@ -316,9 +280,6 @@ public class Marina {
         resetAfterMasterClear();
     }
 
-    JtagLogicLevel mc0;
-    JtagLogicLevel mc1;
-
     private void resetAfterMasterClear() {
         // The following call to ChainControl.resetInBits() is vital!
         // If you forget, then the inBits member initializes 
@@ -434,72 +395,16 @@ public class Marina {
             return (int)bv.toLong();
         }
     }
-    /** Get the 7 bit inner loop counter. The MSB is the zero bit.
-     * The low order 6 bits are the count */
-    public Ilc getILC() {
-        return new Ilc();
-    }
-    /** Get the A flag */
+    public boolean getILCInfinity() { return new Ilc().getInfinity(); }
+    public boolean getILCDone() { return new Ilc().getDone(); }
+    public int getILC() { return new Ilc().getCount(); }
     public boolean getFlagA() {
         shiftReport(true, false);
-        return reportChain.getOutBits(REPORT_CHAIN+"."+FLAGS_PATH).get(A_FLAG_NDX);
+        return reportChain.getOutBits(REPORT_CHAIN+"."+FLAGS_PATH).get(0);
     }
-    /** Get the B flag */
     public boolean getFlagB() {
         shiftReport(true, false);
-        return reportChain.getOutBits(REPORT_CHAIN+"."+FLAGS_PATH).get(B_FLAG_NDX);
-    }
-    /** return value of instruction counter. Instruction counter counts 
-     * the instructions flowing through 1/2 of alternating FIFO.
-     * Caution: instruction counter is written by all scans, 
-     * regardless of readEnable or writeEnable! */
-    public long getInstructionCounter() {
-        shiftData(true, false);
-        BitVector count = dataChain.getOutBits(DATA_CHAIN+"."+INSTRUCTION_COUNTER_PATH);
-        int sz = count.getNumBits(); 
-        MarinaTest.fatal(sz!=COUNTER_LENGTH, "wrong number of counter bits: "+sz+
-                         " expected: "+COUNTER_LENGTH);
-        return count.bitReverse().toLong();
-    }
-    /** return value of data counter. Data counter counts items flowing
-     * through drain stage of data proper stopper. 
-     * Caution: data counter is written by all scans, 
-     * regardless of readEnable or writeEnable! */
-    public long getDataCounter() {
-        shiftData(true, false);
-        BitVector count = dataChain.getOutBits(DATA_CHAIN+"."+DATA_COUNTER_PATH);
-        int sz = count.getNumBits(); 
-        MarinaTest.fatal(sz!=COUNTER_LENGTH, "wrong number of counter bits: "+sz+
-                         " expected: "+COUNTER_LENGTH);
-        return count.bitReverse().toLong();
-    }
-    /** Fill the "North" Fifo ring */
-    public void fillNorthProperStopper() {
-        BitVector data = new BitVector(37, "empty");
-        BitVector addr = new BitVector(14, "empty");
-        for(int i=0; i<data.getNumBits(); i++) data.set(i, false);
-        for(int i=0; i<addr.getNumBits(); i++) addr.set(i, false);
-        fillNorthProperStopper(new MarinaPacket(data, false, addr));
-    }
-    /** Fill the "North" Fifo ring */
-    public void fillNorthProperStopper(MarinaPacket mp) {
-        prln("inserting into north: " + mp);
-        this.data.fill(mp.toSingleBitVector());
-    }
-    /** Enable the transmission of instructions from the instruction
-     * ring test structure to the EPI FIFO. */
-    public void enableInstructionSend(boolean b) {
-        BitVector bv = controlChain.getInBits(CONTROL_CHAIN+"."+INSTR_RING_CONTROL_PATH);
-        bv.set(INSTRUCTION_SEND_NDX, b);
-        controlChain.setInBits(CONTROL_CHAIN+"."+INSTR_RING_CONTROL_PATH, bv); 
-        shiftControl(false, true);
-    } 
-    /** Enable the recirculation of instructions within the South FIFO */
-    public void enableInstructionRecirculate(boolean b) {
-        BitVector bv = controlChain.getInBits(CONTROL_CHAIN+"."+INSTR_RING_CONTROL_PATH);
-        bv.set(INSTRUCTION_RECIRCULATE_NDX, b);
-        controlChain.setInBits(CONTROL_CHAIN+"."+INSTR_RING_CONTROL_PATH, bv); 
-        shiftControl(false, true);
+        return reportChain.getOutBits(REPORT_CHAIN+"."+FLAGS_PATH).get(1);
     }
     /** get the number of tokens in the token FIFO.
      * This includes the Token successor wire, the token FIFO wires,
@@ -520,49 +425,9 @@ public class Marina {
         // concatenate them
         bv = bv.cat(pred);
         sz = bv.getNumBits();
-        prln("Token state wires: "+bv.getState());
         
         int nbTok = 0;
         for (int i=0; i<sz; i++) if (bv.get(i)) nbTok++;
         return nbTok;
     }
-    /** Configure the test probe so it measures the throughput of
-     * the north data FIFO. The test probe frequency is 8192 
-     * times slower than the FIFO throughput. This control has
-     * highest priority. */
-    public void probeDataCounter(Boolean b) {
-        data.setGeneralPurposeOutput(b);
-    }
-    /** Configure the test probe so it measures the throughput of
-     * the alternating instruction FIFO. The test probe frequency is
-     * 1/16384 of the FIFO throughput. This control has second
-     * highest priority. Thus the following two calls probe the
-     * instruction counter: 
-     *      probeDataCounter(false);
-     *      probeInstructionCounter(true)
-     */
-    public void enableInstructionCounter(Boolean b) {
-        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) { fillSouthProperStopper(instructions, repeat, false); }
-    public void fillSouthProperStopper(Instruction[] instructions, boolean repeat, boolean leaveStopped) {
-        enableInstructionSend(false);
-        enableInstructionRecirculate(true);
-        for(Instruction i : instructions)
-            if (i!=null) {
-                instrIn.fill(i);
-            } else {
-                instrIn.fillTorpedo();
-            }
-        enableInstructionRecirculate(repeat);
-        enableInstructionSend(true);
-        if (!leaveStopped) instrIn.run();
-    }
-
-    
 }
index 1d279aa..ae4c569 100644 (file)
@@ -4,7 +4,6 @@ import java.util.ArrayList;
 import java.util.List;
 
 import com.sun.electric.tool.simulation.test.*;
-import edu.berkeley.fleet.marina.Marina.Ilc;
 import edu.berkeley.fleet.marina.CmdArgs;
 import edu.berkeley.fleet.marina.CmdArgs.Mode;
 
@@ -563,7 +562,7 @@ public class MarinaTest {
         prln("Begin sendDataIlcInfinite");
         adjustIndent(2);
         
-        marina.fillSouthProperStopper(new Instruction[] {
+        marina.southRing.fill(new Instruction[] {
                 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter,SetSource.Infinity),
                 SEND_DATA,
             });
@@ -606,7 +605,7 @@ public class MarinaTest {
                      "predicate olc"+(predicate_olc_nonzero?"!=0":"==0"));
                 adjustIndent(2);
 
-                marina.fillSouthProperStopper(new Instruction[] {
+                marina.southRing.fill(new Instruction[] {
                         setOlc(olc),
                         new Instruction.Move(dock,
                                              predicate_olc_nonzero  // predicate   
@@ -706,10 +705,9 @@ public class MarinaTest {
         adjustIndent(2);
         
         showOlc();
-        Ilc ilc = marina.getILC();
-        prln("ILC.done=="+ilc.getDone()+
-             " ILC.infinity=="+ilc.getInfinity()+
-             " ILC.count=="+ilc.getCount());
+        prln("ILC.done=="+marina.getILCDone()+
+             " ILC.infinity=="+marina.getILCInfinity()+
+             " ILC.count=="+marina.getILC());
         prln("flagA=="+marina.getFlagA());
         prln("flagB=="+marina.getFlagB());
         adjustIndent(-2);
@@ -718,10 +716,10 @@ public class MarinaTest {
 
     private void walkOneOLC(Marina marina) {
         prln("Begin walkOneOLC");
-        adjustIndent(2);
         /*
+        adjustIndent(2);
         //for (int i=-1; i<6; i++) {
-        marina.fillSouthProperStopper(new Instruction[] {
+        marina.southRing.fill(new Instruction[] {
 
         new Instruction.Head(dock),
 
@@ -739,7 +737,7 @@ public class MarinaTest {
                 
         new Instruction.Tail(dock),
         });
-        marina.fillSouthProperStopper(new Instruction[] {
+        marina.southRing.fill(new Instruction[] {
         null,
         },
         true);
@@ -761,7 +759,7 @@ public class MarinaTest {
                   System.out.println("master-clearing...");
                   // master clear on each iteration; otherwise we'd need to "run down" the olc
                   marina.masterClear();
-                  marina.enableInstructionSend(true);
+                  marina.southRing.enableInstructionSend(true);
                   }
 
                   expectTokensExactly(0);
@@ -792,15 +790,13 @@ public class MarinaTest {
             int inIlc = 1 << i;
             prln("inIlc="+inIlc);
             marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, inIlc));
-            Ilc ilc = marina.getILC();
-            int outIlc = ilc.getCount();
+            int outIlc = marina.getILC();
             fatal(outIlc!=inIlc, "bad ILC count: "+outIlc+" expected: "+inIlc);
-            fatal(ilc.getInfinity(), "bad Infinity bit: true");
+            fatal(marina.getILCInfinity(), "bad Infinity bit: true");
         }
         prln("Now test the infinity bit");
         marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, SetSource.Infinity));
-        Ilc ilc = marina.getILC();
-        fatal(!ilc.getInfinity(), "bad Infinity bit: false");
+        fatal(!marina.getILCInfinity(), "bad Infinity bit: false");
         adjustIndent(-2);
         prln("End walkOneILC");
     }
@@ -812,7 +808,7 @@ public class MarinaTest {
         marina.instrIn.fill(new 
                             Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, maxIlc));
 
-        int ilc = marina.getILC().getCount();
+        int ilc = marina.getILC();
         fatal(ilc!=maxIlc, "bad ILC count: "+ilc+" expected: "+maxIlc);
                 
         prln("execute a move instruction that does nothing except decrement the ILC to zero");
@@ -834,7 +830,7 @@ public class MarinaTest {
         //model.waitNS(10000);
 
         prln("Check that ILC==0");
-        ilc = marina.getILC().getCount();
+        ilc = marina.getILC();
         fatal(ilc!=0, "bad ILC count: "+ilc+" expected: "+0);
         
         adjustIndent(-2);
@@ -868,11 +864,11 @@ public class MarinaTest {
                 System.out.println("master-clearing...");
                 // master clear on each iteration; otherwise we'd need to "run down" the olc
                 marina.masterClear();
-                marina.enableInstructionSend(true);
+                marina.southRing.enableInstructionSend(true);
             }
 
             int inOlc = i;
-            marina.fillSouthProperStopper(new Instruction[] {
+            marina.southRing.fill(new Instruction[] {
 
                     setIlc(1),
 
@@ -889,7 +885,7 @@ public class MarinaTest {
                 });
 
             model.waitNS(128 * CYCLE_TIME_NS);
-            marina.fillNorthProperStopper();
+            marina.northRing.fill();
             model.waitNS(128 * CYCLE_TIME_NS);
 
             expectOlc(inOlc);
@@ -1115,40 +1111,40 @@ public class MarinaTest {
 
     private void testFlagDRecomputationTime(Marina marina) {
         marina.instrIn.fill(setIlc(1));
-        marina.fillSouthProperStopper(new Instruction[] {
+        marina.southRing.fill(new Instruction[] {
                 RECV_DATA,
                 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter,0),
                 SEND_DATA_IF_D_NOT_SET
             });
-        marina.fillNorthProperStopper();
+        marina.northRing.fill();
         expectNorthFifoNoMoreThan(0);
 
-        marina.fillSouthProperStopper(new Instruction[] {
+        marina.southRing.fill(new Instruction[] {
                 RECV_DATA,
                 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter,1),
                 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter,SetSource.Decrement),
                 SEND_DATA_IF_D_NOT_SET
             });
-        marina.fillNorthProperStopper();
+        marina.northRing.fill();
         expectNorthFifoNoMoreThan(0);
 
-        marina.fillSouthProperStopper(new Instruction[] {
+        marina.southRing.fill(new Instruction[] {
                 RECV_DATA,
                 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter,2),
                 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter,SetSource.Decrement),
                 SEND_DATA_IF_D_NOT_SET
             });
-        marina.fillNorthProperStopper();
+        marina.northRing.fill();
         expectNorthFifoExactly(1);
         marina.instrIn.fill(DEC);
 
-        marina.fillSouthProperStopper(new Instruction[] {
+        marina.southRing.fill(new Instruction[] {
                 RECV_DATA,
                 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter,0),
                 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter,1),
                 SEND_DATA_IF_D_NOT_SET
             });
-        marina.fillNorthProperStopper();
+        marina.northRing.fill();
         expectNorthFifoExactly(1);
     }
 
@@ -1156,8 +1152,8 @@ public class MarinaTest {
         marina.instrIn.fill(setIlc(1));
         marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter, 63));
         
-        marina.enableInstructionSend(false);
-        marina.enableInstructionRecirculate(true);
+        marina.southRing.enableInstructionSend(false);
+        marina.southRing.enableInstructionRecirculate(true);
         
         marina.instrIn.fill(TORPEDOABLE_RECV_DATA);
         marina.instrIn.fill(new Instruction.Head(dock));
@@ -1168,13 +1164,13 @@ public class MarinaTest {
         marina.instrIn.fill(new Instruction.Tail(dock));
         marina.instrIn.fillTorpedo();
         
-        marina.enableInstructionRecirculate(false);
-        marina.enableInstructionSend(true);
+        marina.southRing.enableInstructionRecirculate(false);
+        marina.southRing.enableInstructionSend(true);
         marina.instrIn.run();
         
         expectNorthFifoNoMoreThan(0);
         prln("inserting into north proper stopper");
-        marina.fillNorthProperStopper();
+        marina.northRing.fill();
         expectNorthFifoExactly(1);
         int nbToks = marina.getNumTokens();
         fatal(nbToks!=1, "Expected one token to emerge but got: "+nbToks+" tokens");
@@ -1204,7 +1200,7 @@ public class MarinaTest {
 
     private void testTailWithoutHead(Marina marina) {
         marina.instrIn.fill(setIlc(1));
-        marina.fillSouthProperStopper(new Instruction[] {
+        marina.southRing.fill(new Instruction[] {
                 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter, 63),
                 new Instruction.Tail(dock),
                 SEND_DATA,
@@ -1220,7 +1216,7 @@ public class MarinaTest {
         adjustIndent(2);
 
         marina.instrIn.fill(setIlc(1));
-        marina.fillSouthProperStopper(new Instruction[] {
+        marina.southRing.fill(new Instruction[] {
                 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter, 63),
                 new Instruction.Head(dock),
                 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter,1),
@@ -1237,7 +1233,7 @@ public class MarinaTest {
 
     private void testNonTorpedoableMoveDoesNotResetDFlag(Marina marina) {
         marina.instrIn.fill(setIlc(1));
-        marina.fillSouthProperStopper(new Instruction[] {
+        marina.southRing.fill(new Instruction[] {
                 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter,63),
                 new Instruction.Move(dock,
                                      Predicate.IgnoreFlagD, // predicate   
@@ -1264,7 +1260,7 @@ public class MarinaTest {
             });
         marina.instrIn.fillTorpedo();
         expectNorthFifoExactly(1);
-        marina.fillSouthProperStopper(new Instruction[] {
+        marina.southRing.fill(new Instruction[] {
                 new Instruction.Move(dock,
                                      Predicate.Default,     // predicate   
                                      false,                 // torpedoable 
@@ -1283,7 +1279,7 @@ public class MarinaTest {
     private void testAbort(Marina marina) {
         
         marina.instrIn.fill(setIlc(1));
-        marina.fillSouthProperStopper(new Instruction[] {
+        marina.southRing.fill(new Instruction[] {
                 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.DataLatch,1),
                 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter,2),
                 SEND_DATA_IF_D_NOT_SET,
@@ -1321,7 +1317,7 @@ public class MarinaTest {
 
     private void testAbortOutsideOfLoop(Marina marina) {
         marina.instrIn.fill(setIlc(1));
-        marina.fillSouthProperStopper(new Instruction[] {
+        marina.southRing.fill(new Instruction[] {
                 // ensure that an abort doesn't cause problems if no loop is in progress
                 new Instruction.Abort(dock, Predicate.IgnoreFlagD),
                 SEND_DATA,
@@ -1360,13 +1356,13 @@ public class MarinaTest {
                                                        b ? one : zero
                                                        );
                 if (fast) {
-                    marina.fillSouthProperStopper(new Instruction[] {
+                    marina.southRing.fill(new Instruction[] {
                             RECV_DATA,
                             inst,
                             NOP,
                         });
                     model.waitNS(64 * CYCLE_TIME_NS);
-                    marina.fillNorthProperStopper();
+                    marina.northRing.fill();
                 } else {
                     marina.instrIn.fill(inst);
                 }
@@ -1416,7 +1412,7 @@ public class MarinaTest {
                                     for(int i=0; i<data.getNumBits(); i++) data.set(i, false);
                                     for(int i=0; i<addr.getNumBits(); i++) addr.set(i, false);
                                     addr.set(Marina.INDEX_OF_ADDRESS_BIT_COPIED_TO_C_FLAG_WHEN_DC_EQUALS_ONE, c_state);
-                                    marina.fillNorthProperStopper(new MarinaPacket(data, false, addr));
+                                    marina.northRing.fill(new MarinaPacket(data, false, addr));
                                     marina.instrIn.fill(RECV_DATA);
                                     
                                     Instruction.Set.FlagFunction func = zero;
@@ -1449,7 +1445,7 @@ public class MarinaTest {
         adjustIndent(2);
 
         marina.instrIn.fill(setIlc(1));
-        marina.fillSouthProperStopper(new Instruction[] {
+        marina.southRing.fill(new Instruction[] {
                 new Instruction.Set(dock,Predicate.IgnoreFlagD, CLEAR_FLAG, CLEAR_FLAG),
                 new Instruction.Move(dock,
                                      Predicate.IgnoreFlagD, // predicate   
@@ -1474,7 +1470,7 @@ public class MarinaTest {
         BitVector addr = new BitVector(14, "empty");
         for(int i=0; i<data.getNumBits(); i++) data.set(i, false);
         for(int i=0; i<addr.getNumBits(); i++) addr.set(i, false);
-        marina.fillNorthProperStopper(new MarinaPacket(data, false, addr));
+        marina.northRing.fill(new MarinaPacket(data, false, addr));
         model.waitNS(64 * CYCLE_TIME_NS);
 
         prln("checking to see if A flag got set");
@@ -1502,7 +1498,7 @@ public class MarinaTest {
             prln("testing with bit pattern " + data);
 
             prln("inserting data item into north fifo ring");
-            marina.fillNorthProperStopper(new MarinaPacket(data, false, addr));
+            marina.northRing.fill(new MarinaPacket(data, false, addr));
 
             prln("stopping the north proper stopper");
             marina.data.stop();
@@ -1550,9 +1546,9 @@ public class MarinaTest {
             for(int i=0; i<data.getNumBits(); i++) data.set(i, false);
             for(int i=0; i<addr.getNumBits(); i++) addr.set(i, false);
             data.set(bit, true);
-            marina.fillNorthProperStopper(new MarinaPacket(data, false, addr));
+            marina.northRing.fill(new MarinaPacket(data, false, addr));
 
-            marina.fillSouthProperStopper(new Instruction[] {
+            marina.southRing.fill(new Instruction[] {
                     RECV_DATA,
                     new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter,SetSource.DataLatch),
                     new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.DataLatch,-1),
@@ -1565,7 +1561,7 @@ public class MarinaTest {
             if (marina.kesselsCounter) {
                 // master clear on each iteration; otherwise we'd need to "run down" the olc
                 marina.masterClear();
-                marina.enableInstructionSend(true);
+                marina.southRing.enableInstructionSend(true);
             }
         }
 
@@ -1587,16 +1583,16 @@ public class MarinaTest {
             for(int i=0; i<data.getNumBits(); i++) data.set(i, false);
             for(int i=0; i<addr.getNumBits(); i++) addr.set(i, false);
             data.set(bit, true);
-            marina.fillNorthProperStopper(new MarinaPacket(data, false, addr));
+            marina.northRing.fill(new MarinaPacket(data, false, addr));
 
-            marina.fillSouthProperStopper(new Instruction[] {
+            marina.southRing.fill(new Instruction[] {
                     new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter,1),
                     RECV_DATA,
                     new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter,SetSource.DataLatch),
                 });
             model.waitNS(CYCLE_TIME_NS * 64);
 
-            int ilc = marina.getILC().getCount();
+            int ilc = marina.getILC();
             fatal(ilc != (1<<bit), "expected ilc to be " + (1<<bit) + ", but got " + ilc); 
         }
 
@@ -1609,7 +1605,7 @@ public class MarinaTest {
         adjustIndent(2);
 
         marina.instrIn.fill(setIlc(1));
-        marina.fillSouthProperStopper(new Instruction[] {
+        marina.southRing.fill(new Instruction[] {
                 SEND_TOKEN,
                 RECV_TOKEN,
                 SEND_DATA,
@@ -1627,7 +1623,7 @@ public class MarinaTest {
         marina.instrIn.fill(setIlc(1));
         for(long val : new long[] { (-1L << 14), -1, 0, 1 }) {
 
-            marina.fillSouthProperStopper(new Instruction[] {
+            marina.southRing.fill(new Instruction[] {
                     new Instruction.Set(dock,Predicate.IgnoreFlagD,
                                         Instruction.Set.SetDest.DataLatch,
                                         val),
@@ -1682,7 +1678,7 @@ public class MarinaTest {
             for(int i=0; i<19; i++)
                 dreg.set(i, immediate.get(i));
 
-            marina.fillSouthProperStopper(new Instruction[] {
+            marina.southRing.fill(new Instruction[] {
                     new Instruction.Shift(dock,Predicate.IgnoreFlagD,immediate),
                     SEND_DATA,
                 });
@@ -1731,12 +1727,12 @@ public class MarinaTest {
                 addr.set(whichbit, c_flag);
 
                 prln("... and filling north fifo proper stopper");
-                marina.fillNorthProperStopper(new MarinaPacket(data, false, addr));
+                marina.northRing.fill(new MarinaPacket(data, false, addr));
                 
                 prln("clearing flags");
                 prln("executing recv data with Dc="+dc);
                 prln("copying c-flag to a-flag");
-                marina.fillSouthProperStopper(new Instruction[] {
+                marina.southRing.fill(new Instruction[] {
                         new Instruction.Set(dock,Predicate.IgnoreFlagD, CLEAR_FLAG, CLEAR_FLAG),
                         new Instruction.Move(dock,
                                              Predicate.IgnoreFlagD,   /* predicate   */
@@ -1782,7 +1778,7 @@ public class MarinaTest {
 
         MarinaPath path = new MarinaPath((MarinaFleet)dock.getShip().getFleet(), bv);
 
-        marina.fillSouthProperStopper(new Instruction[] {
+        marina.southRing.fill(new Instruction[] {
                 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter,1),
                 new Instruction.Move(dock,
                                      Predicate.IgnoreFlagD, /* predicate   */
@@ -1845,7 +1841,7 @@ public class MarinaTest {
             BitVector packet_path = new BitVector(14, "inbound data item");
             for(int i=0; i<14; i++) packet_path.set(i, false);
 
-            marina.fillNorthProperStopper(new MarinaPacket(packet_data, false, packet_path));
+            marina.northRing.fill(new MarinaPacket(packet_data, false, packet_path));
                                            
             prln("recv path, send data (using recv'd path)");
             marina.instrIn.fill(new Instruction.Move(dock,
@@ -1878,7 +1874,7 @@ public class MarinaTest {
 
         for(int bit=0; bit<6; bit++) {
             int ilc = bit<0 ? 0 : (1<<bit);
-            marina.fillSouthProperStopper(new Instruction[] {
+            marina.southRing.fill(new Instruction[] {
                     new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter,ilc),
                     SEND_DATA,
                 });
@@ -1892,7 +1888,7 @@ public class MarinaTest {
 
     private void testILCZero(Marina marina) {
         adjustIndent(2);
-        marina.fillSouthProperStopper(new Instruction[] {
+        marina.southRing.fill(new Instruction[] {
                 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter,0),
                 SEND_DATA,
                 SEND_TOKEN,
@@ -1922,7 +1918,7 @@ public class MarinaTest {
 
         model.waitNS(128 * CYCLE_TIME_NS);
 
-        marina.fillSouthProperStopper(new Instruction[] {
+        marina.southRing.fill(new Instruction[] {
                 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, SetSource.Infinity),
                 new Instruction.Move(dock,
                                      Predicate.IgnoreFlagD, // predicate   
@@ -1987,7 +1983,7 @@ public class MarinaTest {
         marina.instrIn.fill(setIlc(1));
         for(boolean torpedoable : new boolean[] { true, false }) {
             
-            marina.fillSouthProperStopper(new Instruction[] {
+            marina.southRing.fill(new Instruction[] {
                     new Instruction.Move(dock,
                                          Predicate.IgnoreFlagD, // predicate   
                                          false,                 // torpedoable 
@@ -2027,7 +2023,7 @@ public class MarinaTest {
             dataItems = marina.data.drainMany(2);
             fatal(dataItems.size()!=expected, "Expected "+expected+" item to emerge but got: "+dataItems.size()+" data items");
 
-            fatal(!marina.getILC().getDone(), "Expected ilc=done, but got "+marina.getILC());
+            fatal(!marina.getILCDone(), "Expected ilc=done, but got "+marina.getILC());
         }
 
         adjustIndent(-2);
@@ -2035,7 +2031,7 @@ public class MarinaTest {
     }
 
     private void testDFlagWhenTorpedoLyingInWait(Marina marina) {
-        marina.fillSouthProperStopper(new Instruction[] {
+        marina.southRing.fill(new Instruction[] {
                 setOlc(1),
                 RECV_DATA,
                 TORPEDOABLE_RECV_DATA,
@@ -2048,7 +2044,7 @@ public class MarinaTest {
         expectTokensExactly(0);
 
         // changing the order of these lines should work, but it does not
-        marina.fillNorthProperStopper();
+        marina.northRing.fill();
         marina.instrIn.fillTorpedo();
 
         expectTokensExactly(1);
@@ -2057,7 +2053,7 @@ public class MarinaTest {
     private void testSetOlcFollowedByDPredicated(Marina marina) {
         for(boolean d_set : new boolean[] { false, true }) {
             prln("");
-            marina.fillSouthProperStopper(new Instruction[] {
+            marina.southRing.fill(new Instruction[] {
                     setOlc(0),
                     marina.kesselsCounter ? null : FLAG_NOP,
                     d_set ? SEND_DATA_IF_D_SET : SEND_DATA_IF_D_NOT_SET,
@@ -2065,7 +2061,7 @@ public class MarinaTest {
             expectNorthFifoExactly(d_set ? 1 : 0);
 
             prln("");
-            marina.fillSouthProperStopper(new Instruction[] {
+            marina.southRing.fill(new Instruction[] {
                     setOlc(32),
                     marina.kesselsCounter ? null : FLAG_NOP,
                     d_set ? SEND_DATA_IF_D_SET : SEND_DATA_IF_D_NOT_SET,
@@ -2074,7 +2070,7 @@ public class MarinaTest {
 
             if (marina.kesselsCounter) {
                 marina.masterClear();
-                marina.enableInstructionSend(true);
+                marina.southRing.enableInstructionSend(true);
             }
         }
     }
@@ -2100,7 +2096,7 @@ public class MarinaTest {
 
             prln("inserting set olc="+olc);
             prln("inserting set ilc=1");
-            marina.fillSouthProperStopper(new Instruction[] {
+            marina.southRing.fill(new Instruction[] {
                     new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter,1),
                     new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter,olc),
                 });
@@ -2129,7 +2125,7 @@ public class MarinaTest {
                                      false                  // tokenOut    
                                      );
 
-            marina.fillSouthProperStopper(instructions);
+            marina.southRing.fill(instructions);
             model.waitNS(64 * CYCLE_TIME_NS);
 
             int expected = decr_amount>=olc ? 0 : 1;
@@ -2140,7 +2136,7 @@ public class MarinaTest {
             if (marina.kesselsCounter) {
                 // master clear on each iteration; otherwise we'd need to "run down" the olc
                 marina.masterClear();
-                marina.enableInstructionSend(true);
+                marina.southRing.enableInstructionSend(true);
             }
         }
 
@@ -2158,7 +2154,7 @@ public class MarinaTest {
             int notZero = 1<<i;
 
             prln("Then immediately set ILC="+notZero);
-            marina.fillSouthProperStopper(new Instruction[] {
+            marina.southRing.fill(new Instruction[] {
                     new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, 0),
                     new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, notZero),
                 });
@@ -2166,12 +2162,11 @@ public class MarinaTest {
             model.waitNS(64 * CYCLE_TIME_NS);
 
             prln("Verify ILC using scan chain");
-            Ilc ilc = marina.getILC();
-            int ilcCount = ilc.getCount();
+            int ilcCount = marina.getILC();
             fatal(ilcCount!=notZero, "bad ILC count: "+ilcCount+" expected: "+notZero);
-            fatal(ilc.getInfinity(), "bad ILC Infinity bit: true");
+            fatal(marina.getILCInfinity(), "bad ILC Infinity bit: true");
                    
-            marina.fillSouthProperStopper(new Instruction[] {     
+            marina.southRing.fill(new Instruction[] {     
                     new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, notZero),
                     new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, 0),
                 });
@@ -2179,10 +2174,9 @@ public class MarinaTest {
             model.waitNS(64 * CYCLE_TIME_NS);
                         
             prln("Verify ILC using scan chain");
-            ilc = marina.getILC();
-            ilcCount = ilc.getCount();
+            ilcCount = marina.getILC();
             fatal(ilcCount!=0, "bad ILC count: "+ilcCount+" expected: 0");
-            fatal(ilc.getInfinity(), "bad ILC Infinity bit: true");
+            fatal(marina.getILCInfinity(), "bad ILC Infinity bit: true");
         }
 
         adjustIndent(-2);
@@ -2202,13 +2196,13 @@ public class MarinaTest {
             if (marina.kesselsCounter) {
                 // master clear on each iteration; otherwise we'd need to "run down" the olc
                 marina.masterClear();
-                marina.enableInstructionSend(true);
+                marina.southRing.enableInstructionSend(true);
             }
 
             int outOlc;
             prln("Set OLC=0");
             prln("Then immediately set OLC="+notZero);
-            marina.fillSouthProperStopper(new Instruction[] {
+            marina.southRing.fill(new Instruction[] {
                     new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter, 0),
                     new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter, notZero),
                 });
@@ -2220,7 +2214,7 @@ public class MarinaTest {
             if (!marina.kesselsCounter) {
                 prln("Set OLC="+notZero);
                 prln("Then immediately set OLC=0");
-                marina.fillSouthProperStopper(new Instruction[] {
+                marina.southRing.fill(new Instruction[] {
                         new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter, notZero),
                         new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter, 0),
                     });
@@ -2238,8 +2232,8 @@ public class MarinaTest {
         prln("Begin testSouthRecirculate("+AMOUNT+")");
         adjustIndent(2);
 
-        marina.enableInstructionSend(false);
-        marina.enableInstructionRecirculate(true);
+        marina.southRing.enableInstructionSend(false);
+        marina.southRing.enableInstructionRecirculate(true);
         
         prln("Completely fill south ring");
         adjustIndent(2);
@@ -2303,6 +2297,7 @@ public class MarinaTest {
             System.out.println("******************************************************************************");
             System.out.println("******************************************************************************");
             fe.printStackTrace();
+            System.exit(-1);
         }
     }
 
@@ -2337,7 +2332,7 @@ public class MarinaTest {
 
         if (testNum!=0) {
             marina.masterClear();
-            marina.enableInstructionSend(true);
+            marina.southRing.enableInstructionSend(true);
         }
 
         MarinaUtils.testnum = testNum;
@@ -2494,14 +2489,14 @@ public class MarinaTest {
                 marina.data.sink();
                 marina.stopAndResetCounters();
                     
-                marina.enableInstructionSend(true);
-                marina.fillSouthProperStopper(new Instruction.Set(dock,Predicate.IgnoreFlagD,
+                marina.southRing.enableInstructionSend(true);
+                marina.southRing.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,
                                                                   Instruction.Set.FlagFunction.ZERO
                                                                   .add(Predicate.FlagA).add(Predicate.NotFlagA),
                                                                   Instruction.Set.FlagFunction.ZERO));
                 //int xx = 63;      // 1.802ms
                 //int xx = 1;         // 0.207ms  =>  24.3ns for 62 counts => 390ps cycle time => 2.5Ghz
-                marina.fillSouthProperStopper(new Instruction[] {
+                marina.southRing.fill(new Instruction[] {
                         new Instruction.Head(dock),
                         setOlc(xx),
                         FLAG_NOP,
@@ -2513,7 +2508,7 @@ public class MarinaTest {
                         new Instruction.Tail(dock),
                     }, false, false);
 
-                marina.fillSouthProperStopper(new Instruction[] {
+                marina.southRing.fill(new Instruction[] {
                         /*
                           new Instruction.Set(dock,Predicate.FlagD,
                           Instruction.Set.FlagFunction.ZERO.add(Predicate.NotFlagA),
@@ -2581,12 +2576,12 @@ public class MarinaTest {
                             marina.data.sink();
                             marina.stopAndResetCounters();
                                 
-                            marina.enableInstructionSend(true);
-                            marina.fillSouthProperStopper(setOlc(1));
-                            marina.fillSouthProperStopper(new Instruction.Head(dock));
+                            marina.southRing.enableInstructionSend(true);
+                            marina.southRing.fill(setOlc(1));
+                            marina.southRing.fill(new Instruction.Head(dock));
                             for(int i=0; i<toks; i++)
-                                marina.fillSouthProperStopper(/*SEND_DATA*/NOP);
-                            marina.fillSouthProperStopper(new Instruction[] {
+                                marina.southRing.fill(/*SEND_DATA*/NOP);
+                            marina.southRing.fill(new Instruction[] {
                                     new Instruction.Tail(dock),
                                 }, false, true);
                                 
@@ -2653,19 +2648,19 @@ public class MarinaTest {
                         marina.data.sink();
                         marina.stopAndResetCounters();
                             
-                        marina.enableInstructionSend(true);
-                        marina.fillSouthProperStopper(setOlc(1));
-                        marina.fillSouthProperStopper(new Instruction.Set(dock,Predicate.IgnoreFlagD,
+                        marina.southRing.enableInstructionSend(true);
+                        marina.southRing.fill(setOlc(1));
+                        marina.southRing.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,
                                                                           Instruction.Set.FlagFunction.ZERO,
                                                                           Instruction.Set.FlagFunction.ZERO));
-                        marina.fillSouthProperStopper(new Instruction.Head(dock));
-                        //marina.fillSouthProperStopper(setIlc(31));
-                        marina.fillSouthProperStopper(SEND_DATA);
+                        marina.southRing.fill(new Instruction.Head(dock));
+                        //marina.southRing.fill(setIlc(31));
+                        marina.southRing.fill(SEND_DATA);
                         for(int i=0; i<toks+1; i++) {
-                            //marina.fillSouthProperStopper(FLAG_NOP_IF_FLAG_A);
-                            marina.fillSouthProperStopper(FLAG_NOP);
+                            //marina.southRing.fill(FLAG_NOP_IF_FLAG_A);
+                            marina.southRing.fill(FLAG_NOP);
                         }
-                        marina.fillSouthProperStopper(new Instruction[] {
+                        marina.southRing.fill(new Instruction[] {
                                 new Instruction.Tail(dock),
                             }, false, true);
                         marina.startCounters();
index b97d491..3f47881 100644 (file)
@@ -19,7 +19,6 @@ public class ProperStopper {
     private static final int FILL_STATE_IN_NDX = 2;
     private static final int STOPPED_IN_NDX = 3;
         
-    private final String name;
     //private final String captureClockRelPath = "fillStag@1.gaspFill@0.fillScan@1";
     private final String captureClockRelPath = "fillStag@1";
     // test library direct write mode doesn't understand per register write 
@@ -35,9 +34,9 @@ public class ProperStopper {
     private boolean traceDrain = false;
         
     private final String controlPath, dataPath, reportPath;
-    private final ChainControl controlChain;
-    private final ChainControl dataChain;
-    private final ChainControl reportChain;
+    protected final ChainControl controlChain;
+    protected final ChainControl dataChain;
+    protected final ChainControl reportChain;
     private final String captureClock;
     private final ChipModel model;
     private final Indenter indenter;
@@ -146,7 +145,7 @@ public class ProperStopper {
         setFillDrainControl(CommandCodes.IDLE);
     }
     /** Put stopper in FILL state */
-    public void fill() {
+    private void fillMode() {
         setFillDrainControl(CommandCodes.FILL);
     }
     /** Put stopper in BLOCK state */
@@ -231,8 +230,7 @@ public class ProperStopper {
     }
 
     /** construct a ProperStopper */
-    public ProperStopper(String name,
-                         String propInst,
+    public ProperStopper(String propInst,
                          ChainControl controlChain,
                          ChainControl dataChain,
                          ChainControl reportChain,
@@ -240,7 +238,7 @@ public class ProperStopper {
                          boolean clockHack,
                          Indenter indenter,
                          String pathToCounter) {
-        this.name = name;
+        propInst += ".properSt@1";
         this.controlPath = Marina.CONTROL_CHAIN+'.'+propInst;
         this.dataPath = Marina.DATA_CHAIN+'.'+propInst;
         this.reportPath = Marina.REPORT_CHAIN+'.'+propInst;
@@ -287,7 +285,7 @@ public class ProperStopper {
         dataChain.setInBits(dataPath, wrEn.cat(dta));
         shiftData(false, true);
         
-        fill();                                 // fill = 1
+        fillMode();                                 // fill = 1
         idle();                                 // fill = 0
         block();                                // go = 1
         //      idle();
@@ -305,14 +303,22 @@ public class ProperStopper {
         if (traceFill) prln("End fill");
     }
 
+    public void fill() {
+        BitVector data = new BitVector(37, "empty");
+        BitVector addr = new BitVector(14, "empty");
+        for(int i=0; i<data.getNumBits(); i++) data.set(i, false);
+        for(int i=0; i<addr.getNumBits(); i++) addr.set(i, false);
+        fill(new MarinaPacket(data, false, addr));
+    }
+
     public void fill(BitVector dat) {
-        if (traceFill) prln("Begin fill. stopper="+name);
+        if (traceFill) prln("Begin fill.");
         if (traceFill) prln("writing data: "+new MarinaPacket(dat));
         fill_(dat);
     }
 
     public void fill(MarinaPacket mp) {
-        if (traceFill) prln("Begin fill. stopper="+name);
+        if (traceFill) prln("Begin fill.");
         if (traceFill) prln("writing data: "+mp);
         fill_(mp.toSingleBitVector());
     }
@@ -321,7 +327,7 @@ public class ProperStopper {
      * You must stop stopper before calling fillMany()
      * exit state: block */
     public void fillMany(List<BitVector> data) {
-        prln("Begin fillMany. stopper="+name+" numWords="+data.size());
+        prln("Begin fillMany. numWords="+data.size());
         adjustIndent(2);
         int cnt = 0;
         for (BitVector bv : data) {
@@ -361,7 +367,7 @@ public class ProperStopper {
         idle();                                 // clear = 0
         stop();                                 // block = 0
 
-        if (traceDrain) prln("drain stopper="+name+" data="+new MarinaPacket(ans));
+        if (traceDrain) prln("drain  data="+new MarinaPacket(ans));
         return ans;
     }