add tests 3013, 3014 (short and shifted literals)
authorAdam Megacz <adam.megacz@sun.com>
Sat, 22 Nov 2008 19:05:26 +0000 (19:05 +0000)
committerAdam Megacz <adam.megacz@sun.com>
Sat, 22 Nov 2008 19:05:26 +0000 (19:05 +0000)
testCode/com/sun/vlsi/chips/marina/test/Marina.java
testCode/com/sun/vlsi/chips/marina/test/MarinaTest.java

index a4d8b9f..bd96a5e 100644 (file)
@@ -162,6 +162,10 @@ public class Marina {
        shiftReport(true, false);
        return cc.getOutBits(REPORT_CHAIN+"."+FLAGS_PATH).get(B_FLAG_NDX);
     }
+    /** Get the D register */
+    public BitVector getDRegister() {
+        throw new RuntimeException("please implement this!");
+    }
     /** Fill the "North" Fifo ring */
     public void fillNorthProperStopper(BitVector data, boolean tokenhood, BitVector address) {
         int len = 37+1+14;
index b316f5e..d5b704c 100644 (file)
@@ -1064,7 +1064,6 @@ public class MarinaTest {
        prln("End testFlagAB");         
     }
 
-
     private void recvData(Marina marina) {
        prln("Begin recvData");
        adjustIndent(2);
@@ -1101,6 +1100,80 @@ public class MarinaTest {
        prln("End recvData");           
     }
 
+    private void testSignExtendedLiteral(Marina marina) {
+       prln("Begin testSignExtendedLiteral");
+       adjustIndent(2);
+
+        for(long val : new long[] { -1, 0, 1, (-1L << 14) }) {
+            prln("inserting Set Data Latch (sign-extended) 37'b" + Long.toString(val, 1));
+            marina.instrIn.fill(new Instruction.Set(DOCK,false,Predicate.IgnoreOLC,
+                                                    Instruction.Set.SetDest.DataLatch,
+                                                    val));
+
+            BitVector bv = marina.getDRegister();
+            prln("got back " + bv);
+
+            boolean mismatch = false;
+            String err = "";
+            for(int i=0; i<37; i++) {
+                if (bv.get(37-i) != ( (val & (1L << i)) != 0 )) {
+                    mismatch = true;
+                    err += ""+i+", ";
+                }
+            }
+            fatal(mismatch, "data read back did not match inserted literal; mismatch on bits " + err);
+        }
+                
+       adjustIndent(-2);
+       prln("End testSignExtendedLiteral");            
+    }
+
+    private void testShiftedLiteral(Marina marina) {
+       prln("Begin testShiftedLiteral");
+       adjustIndent(2);
+
+        prln("clearing the D register");
+        marina.instrIn.fill(new Instruction.Set(DOCK,false,Predicate.IgnoreOLC,
+                                                Instruction.Set.SetDest.DataLatch,
+                                                0));
+
+        BitVector dreg = new BitVector(37, "what we think is in the d-register");
+        for(int i=0; i<37; i++) dreg.set(i, false);
+
+        for(long val : new long[] { -1, 0, 1, (-1L << 18) }) {
+
+            prln("inserting Shift 19'b" + Long.toString(val, 1));
+            edu.berkeley.fleet.api.BitVector immediate =
+                new edu.berkeley.fleet.api.BitVector(19);
+            for(int i=0; i<immediate.length(); i++)
+                immediate.set(i, (val & (1L << i)) != 0);
+            marina.instrIn.fill(new Instruction.Shift(DOCK,false,Predicate.IgnoreOLC,immediate));
+
+            // shift over 19 LSB's towards MSB
+            for(int i=0; i<19; i++)
+                if (36-(i+19) >= 0)
+                    dreg.set(36-(i+19), dreg.get(36-i));
+            for(int i=0; i<19; i++)
+                dreg.set(36-i, immediate.get(i));
+
+            BitVector bv = marina.getDRegister();
+            prln("got back " + bv);
+
+            boolean mismatch = false;
+            String err = "";
+            for(int i=0; i<37; i++) {
+                if (bv.get(37-i) != ( (val & (1L << i)) != 0 )) {
+                    mismatch = true;
+                    err += ""+i+", ";
+                }
+            }
+            fatal(mismatch, "data read back did not match inserted literal; mismatch on bits " + err);
+        }
+                
+       adjustIndent(-2);
+       prln("End testShiftedLiteral");         
+    }
+
     private void testFlagC(Marina marina) {
        prln("Begin testFlagC");
        adjustIndent(2);
@@ -1361,6 +1434,8 @@ public class MarinaTest {
                case 3010: testRequeueStage0to2to3to0(marina); break;
                case 3011: recvData(marina); break;
                 case 3012: testFlagC(marina); break;
+                case 3013: testSignExtendedLiteral(marina); break;
+                case 3014: testShiftedLiteral(marina); break;
 
                default:
                        fatal(true, "Test number: "+testNum+" doesn't exist.");