merge omegaCounter 40nm/90nm branches into chips/omegaCounter/
[fleet.git] / src / com / sun / vlsi / chips / marina / test / Marina.java
index 8c9cced..87a3c95 100644 (file)
@@ -18,11 +18,25 @@ public class Marina {
     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 final String DATA_CHAIN =    "marina.marina_data";      
-    public static final String CONTROL_CHAIN = "marina.marina_control";
-    public static final String REPORT_CHAIN =  "marina.marina_report";
-        
-    private static String prefix = "marinaGu@0.outDockW@3.marinaOu@1.";
+       
+    public static int TOKEN_FIFO_CAPACITY = 3;
+    
+    //public static boolean kesselsCounter = true;
+    public static boolean kesselsCounter = false;
+    public static 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";
+
+    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
@@ -181,13 +195,9 @@ public class Marina {
             vm.setNodeState(prefix+"northFif@1.upDown8w@2.weakStag@22.addr1in2@0.fire", 0);
             model.waitNS(1000);
 
-            vm.setNodeState("sid[9]", 1);
-            vm.setNodeState("sic[9]", 1);
-            vm.setNodeState("sir[9]", 1);
+            vm.setNodeState(MASTER_CLEAR, 1);
             model.waitNS(1000);
-            vm.setNodeState("sid[9]", 0);
-            vm.setNodeState("sic[9]", 0);
-            vm.setNodeState("sir[9]", 0);
+            vm.setNodeState(MASTER_CLEAR, 0);
             model.waitNS(1000);
 
             // pulse ilc[load] and olc[load]
@@ -241,7 +251,7 @@ public class Marina {
             data.idle();
             instrIn.idle();
 
-        } else {
+        } else if (model instanceof NanosimModel) {
             NanosimModel nModel = (NanosimModel) model;
             /*
             nModel.setNodeVoltage(prefix+"sid[9]",1.0);
@@ -253,10 +263,12 @@ public class Marina {
             nModel.setNodeVoltage(prefix+"sir[9]",0.0);
             nModel.waitNS(1);
             */
-            nModel.setNodeVoltage("mc",1.0);
+            nModel.setNodeVoltage(MASTER_CLEAR,1.0);
             nModel.waitNS(WIDTH);
-            nModel.setNodeVoltage("mc",0.0);
+            nModel.setNodeVoltage(MASTER_CLEAR,0.0);
             nModel.waitNS(1);
+        } else {
+            prln("FIXME!");
         }
         resetAfterMasterClear();
     }
@@ -280,12 +292,47 @@ public class Marina {
         //tokOut.resetAfterMasterClear();
         instrIn.resetAfterMasterClear();
     }
-    public static boolean kesselsCounter = true;
+
 
     /** Get the 6 bit outer loop counter. */
     public int getOLC() {
         shiftReport(true, false);
-        if (kesselsCounter) {
+        if (omegaCounter) {
+            BitVector bits = null;
+            for(int i=0; i<4; i++) {
+                BitVector x = cc.getOutBits(REPORT_CHAIN+"."+OLC_PATH_KESSEL+i);
+                //System.out.println("bits are: " + x);
+                bits = bits==null ? x : bits.cat(x);
+            }
+            System.out.print("  kesselsCounter = ");
+            int ret = 0;
+            boolean done = true;
+            boolean bad = false;
+            for(int bit=5; bit>=0; bit--) {
+                boolean zeroOrTwo  = bits.get(4+bit*3);
+                boolean zeroOrDone = bits.get(4+bit*3+1);
+                if      ( zeroOrTwo && !zeroOrDone) {
+                    ret += (2<<bit);
+                    System.out.print("2");
+                    done = false;
+                } else if (!zeroOrTwo && !zeroOrDone) {
+                    ret += (1<<bit);
+                    System.out.print("1");
+                    done = false;
+                } else if ( zeroOrTwo &&  zeroOrDone) {
+                    System.out.print("0");
+                    bad = true;
+                    done = false;
+                } else if (!zeroOrTwo &&  zeroOrDone) {
+                    System.out.print("_");
+                    if (!done) bad = true;
+                }
+                // FIXME: check for unreduced counter and warn about it
+            }
+            if (bad) System.out.print("  WARNING: UNREDUCED COUNTER VALUE!!!!!!");
+            System.out.println();
+            return ret;
+        } else if (kesselsCounter) {
             BitVector bits = null;
             for(int i=0; i<4; i++) {
                 BitVector x = cc.getOutBits(REPORT_CHAIN+"."+OLC_PATH_KESSEL+i);