From 00dd1007d6233b5973da95d22cf824e3aa29d293 Mon Sep 17 00:00:00 2001 From: Adam Megacz Date: Sat, 22 Nov 2008 19:05:26 +0000 Subject: [PATCH] add tests 3013, 3014 (short and shifted literals) --- .../com/sun/vlsi/chips/marina/test/Marina.java | 4 + .../com/sun/vlsi/chips/marina/test/MarinaTest.java | 77 +++++++++++++++++++- 2 files changed, 80 insertions(+), 1 deletion(-) diff --git a/testCode/com/sun/vlsi/chips/marina/test/Marina.java b/testCode/com/sun/vlsi/chips/marina/test/Marina.java index a4d8b9f..bd96a5e 100644 --- a/testCode/com/sun/vlsi/chips/marina/test/Marina.java +++ b/testCode/com/sun/vlsi/chips/marina/test/Marina.java @@ -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; diff --git a/testCode/com/sun/vlsi/chips/marina/test/MarinaTest.java b/testCode/com/sun/vlsi/chips/marina/test/MarinaTest.java index b316f5e..d5b704c 100644 --- a/testCode/com/sun/vlsi/chips/marina/test/MarinaTest.java +++ b/testCode/com/sun/vlsi/chips/marina/test/MarinaTest.java @@ -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= 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."); -- 1.7.10.4