Update proper stoppers
authorAdam Megacz <adam.megacz@sun.com>
Mon, 13 Apr 2009 23:19:03 +0000 (23:19 +0000)
committerAdam Megacz <adam.megacz@sun.com>
Mon, 13 Apr 2009 23:19:03 +0000 (23:19 +0000)
testCode/com/sun/vlsi/chips/marina/test/InstructionStopper.java
testCode/com/sun/vlsi/chips/marina/test/MarinaPacket.java
testCode/com/sun/vlsi/chips/marina/test/ProperStopper.java

index a3ec9c5..2e9ede2 100644 (file)
@@ -28,20 +28,6 @@ public class InstructionStopper extends ProperStopper {
         super(propInst, controlChain, dataChain, reportChain, cc, model, clockHack, indenter);
     }
 
-    public void fill(BitVector instr) {
-        if (instr.getNumBits()==MarinaPacket.PACKET_WIDTH) {
-            super.fill(instr);
-        } else {
-            MarinaUtils.expectLength(instr, MarinaPacket.WORD_WIDTH);
-            /*
-            MarinaUtils.expectLength(instr, INSTRUCTION_LENGTH);
-            BitVector pad = new BitVector(MarinaPacket.WORD_WIDTH-INSTRUCTION_LENGTH, "pad");
-            pad.setFromLong(0);
-            */
-            super.fill(new MarinaPacket(instr /*.cat(pad)*/, false));
-        }
-    }
-
     // FIXME: I really don't like this --Adam
     public BitVector drainNoCheck() {
         BitVector dta = super.drainNoCheck();
@@ -49,8 +35,8 @@ public class InstructionStopper extends ProperStopper {
     }
 
     /** put one Instruction into InstructionStopper */
-    public void fill(Instruction instr) {
-        fill(MarinaUtils.berkToSun(MarinaTest.marinaFleet.encodeInstruction(MarinaTest.marinaFleet.getOnlyInputDock(), instr)));
+    public void fill(Instruction inst) {
+        super.fill(new MarinaPacket(inst));
     }
 
     /* put a torpedo into the InstructionStopper */
index 217dc7e..04cc40c 100644 (file)
@@ -5,6 +5,9 @@ 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 edu.berkeley.fleet.api.Dock;
+import edu.berkeley.fleet.api.Instruction;
+import edu.berkeley.fleet.marina.MarinaFleet;
 
 /**
  * This class encapsulates a "packet" -- a data item in flight plus
@@ -22,6 +25,7 @@ public class MarinaPacket {
     public final BitVector data;
     public final boolean tokenhood;
     public final BitVector path;
+    private final boolean is_instruction;
 
     private static final BitVector null_path = new BitVector(PATH_WIDTH, "null_path");
     static {
@@ -34,6 +38,7 @@ public class MarinaPacket {
         this.data = new BitVector(WORD_WIDTH, "marina packet data");
         this.path = new BitVector(PATH_WIDTH, "marina packet path");
         this.tokenhood = !singleBitVector.get(0);
+        this.is_instruction = false;
         for(int i=0; i<PATH_WIDTH; i++) path.set(i, singleBitVector.get(i+1));
         for(int i=0; i<WORD_WIDTH; i++) data.set(i, singleBitVector.get(i+PATH_WIDTH+1));
     }
@@ -45,11 +50,27 @@ public class MarinaPacket {
         this.data = data;
         this.tokenhood = tokenhood;
         this.path = path;
+        this.is_instruction = false;
     }
 
     /** another constructor which uses an all-zeroes path, for convenience */
-    public MarinaPacket(BitVector data, boolean tokenhood) {
-        this(data, tokenhood, null_path);
+    public MarinaPacket(Instruction inst) {
+        BitVector instr =
+            MarinaUtils.berkToSun(MarinaTest.marinaFleet.encodeInstruction(MarinaTest.marinaFleet.getOnlyInputDock(), inst));
+        MarinaUtils.expectLength(instr, MarinaPacket.WORD_WIDTH);
+        
+        //
+        // Due to what Ivan calls "geometric inconvenience", incoming
+        // bit 19 is dropped, and all the higher bits are shifted
+        // downward by one position.  So we have to compensate for
+        // this by inserting a bogus bit at position #19.
+        //
+        BitVector pad = new BitVector(1, "pad");
+        pad.setFromLong(0);
+        this.data = instr.get(0, 18).cat(pad).cat(instr.get(18,18));
+        this.path = null_path;
+        this.tokenhood = false;
+        this.is_instruction = true;
     }
 
     /** convert a packet into a single BitVector, suitable for insertion in the north proper stopper */
@@ -65,6 +86,9 @@ public class MarinaPacket {
         return
             "tokenhood="+(tokenhood ? "token" : "data")
             + ", path["+PATH_WIDTH+":1]=" + path.bitReverse().getState()
-            + ", data["+WORD_WIDTH+":1]=" + data.bitReverse().getState();
+            + ", data["+WORD_WIDTH+":1]=" +
+            (is_instruction
+             ? (data.get(19,18).bitReverse().getState()+"_"+data.get(0,18).bitReverse().getState())
+             : data.bitReverse().getState());
     }
 }
\ No newline at end of file
index 2b21551..db4e0ee 100644 (file)
@@ -229,8 +229,7 @@ public class ProperStopper {
      * Fill stage must be empty. 
      * You must stop stopper before calling fill.
      * exit state: block */
-    public void fill(BitVector dta) {
-        if (traceFill) prln("Begin fill. stopper="+name);
+    private void fill_(BitVector dta) {
         adjustIndent(2);
         
         int n = dta.getNumBits();
@@ -240,8 +239,6 @@ public class ProperStopper {
         StateWireState myState = getFillStateWire();
         fatal(myState!=StateWireState.EMPTY, "fill: fill stage already full");
         
-        if (traceFill) prln("writing data: "+new MarinaPacket(dta));
-        
         idle();                                 // block = 1, go = 0
 
         BitVector wrEn = new BitVector(2, "write enable");
@@ -267,8 +264,16 @@ public class ProperStopper {
         if (traceFill) prln("End fill");
     }
 
+    public void fill(BitVector dat) {
+        if (traceFill) prln("Begin fill. stopper="+name);
+        if (traceFill) prln("writing data: "+new MarinaPacket(dat));
+        fill_(dat);
+    }
+
     public void fill(MarinaPacket mp) {
-        fill(mp.toSingleBitVector());
+        if (traceFill) prln("Begin fill. stopper="+name);
+        if (traceFill) prln("writing data: "+mp);
+        fill_(mp.toSingleBitVector());
     }
 
     /** Insert items from a list, one by one.