/** InstructionStopper is a scaffold that lets us create a 36 bit propperStopper
* by using a 52 bit propperStopper and throwing away the unused bits. */
public class InstructionStopper extends ProperStopper {
+ public static final BitVector TORPEDO;
public static final int INSTR_SZ = 36;
public static final MarinaFleet MARINA = new MarinaFleet();
public static final Dock DOCK = MARINA.getOnlyInputDock();
+ static {
+ BitVector d = new BitVector(37, "token"); d.setFromLong(0);
+ BitVector t = new BitVector(1, "token"); t.setFromLong(0);
+ BitVector a = new BitVector(14, "addr"); a.setFromLong(0);
+ TORPEDO = d.cat(t).cat(a);
+ }
// Convert a Berkeley BitVector into a Sun BitVector
private BitVector berkToSun(edu.berkeley.fleet.api.BitVector berkBits) {
BitVector sunBits = new BitVector(INSTR_SZ, "instr");
ChainControl cc, ChipModel model,
Indenter indenter) {
super(propInst, controlChain, dataChain, reportChain, cc, model, indenter);
-
}
@Override
public void fill(BitVector instr) {
+ // allow user to pass in complete item: data + token + addr
+ if (instr.getNumBits()==(37+1+14)) {super.fill(instr); return;}
+
int n = instr.getNumBits();
fatal(n!=INSTR_SZ, "InstructionStopper.fill: wrong num bits: "+n+", expect: "+INSTR_SZ);
fatal(INSTR_SZ>37, "Instructions can't be more than 37 bits");
public static final int INSTR_SZ = 36;
public static final Dock DOCK = InstructionStopper.DOCK;
-
+ public static final Instruction.Set.FlagFunction CLEAR_FLAG
+ = Instruction.Set.FlagFunction.ZERO;
+ public static final Instruction.Set.FlagFunction SET_FLAG
+ = Instruction.Set.FlagFunction.ZERO.add(Predicate.FlagA)
+ .add(Predicate.NotFlagA);
+ public static final Instruction.Set.FlagFunction A_FLAG
+ = Instruction.Set.FlagFunction.ZERO.add(Predicate.FlagA);
+
+ public static final Instruction.Set.FlagFunction B_FLAG
+ = Instruction.Set.FlagFunction.ZERO.add(Predicate.FlagB);
+
// COLUMN_LATENCY is a delay that is larger than the latency through an Infinity column
private static final int COLUMN_LATENCY = 10; // nanoseconds
Instruction.Set.FlagFunction zero = Instruction.Set.FlagFunction.ZERO;
Instruction.Set.FlagFunction one = zero;
+
// we should be able to use any pair of FlagX+NotFlagX,
// but we toss them all in to maximize the chances of the
adjustIndent(-2);
prln("End testFlagAB");
}
+ private void sendTorpedo(IsolatedInDock inDock) {
+ prln("Begin sendTorpedo");
+ adjustIndent(2);
+
+ prln("OLC = 63");
+ inDock.instrIn.fill(new
+ Instruction.Set(DOCK,false,Predicate.IgnoreOLC,SetDest.OuterLoopCounter, 63));
+
+ int olc = inDock.getOLC();
+ fatal(olc!=63, "bad OLC: "+olc+" expected: 63");
+
+ prln("A=0, B=0");
+ inDock.instrIn.fill(new
+ Instruction.Set(DOCK,false,Predicate.IgnoreOLC, CLEAR_FLAG, CLEAR_FLAG));
+
+ fatal(inDock.getFlagA(), "bad A flag: true");
+ fatal(inDock.getFlagB(), "bad B flag: true");
+
+ prln("ILC = Infinity");
+ inDock.instrIn.fill(new
+ Instruction.Set(DOCK,false,Predicate.IgnoreOLC,SetDest.InnerLoopCounter, SetSource.Infinity));
+
+ prln("execute a move instruction that does nothing but loops until torpedo arrives");
+ inDock.instrIn.fill(
+ new Instruction.Move(DOCK,
+ false, /* requeueing */
+ Predicate.IgnoreOLC, /* predicate */
+ true, /* torpedoable */
+ null, /* path */
+ false, /* tokenIn */
+ false, /* dataIn */
+ false, /* latchData */
+ false, /* latchPath */
+ false, /* dataOut */
+ false /* tokenOut */
+ ));
+
+ prln("NOP This instruction can't predicate on OLC because of a hardware bug");
+ inDock.instrIn.fill(new
+ Instruction.Set(DOCK,false,Predicate.Default, CLEAR_FLAG, CLEAR_FLAG));
+
+ prln("A=1, B=1 This instruction should get torpedoed along with the Move");
+ inDock.instrIn.fill(new
+ Instruction.Set(DOCK,false,Predicate.Default, SET_FLAG, SET_FLAG));
+
+ prln("send torpedo. This should clear the OLC");
+ inDock.instrIn.fill(InstructionStopper.TORPEDO);
+
+ getCtrsFlags(inDock);
+
+ prln("A and B should remain false");
+ fatal(inDock.getFlagA(), "bad A flag: true");
+ fatal(inDock.getFlagB(), "bad B flag: true");
+
+ prln("OLC = 63. Reload OLC after torpedo");
+ inDock.instrIn.fill(new
+ Instruction.Set(DOCK,false,Predicate.IgnoreOLC,SetDest.OuterLoopCounter, 63));
+
+ olc = inDock.getOLC();
+ fatal(olc!=63, "bad OLC: "+olc+" expected: 63");
+
+ prln("A=1, B=1 This instruction should execute because OLC!=0");
+ inDock.instrIn.fill(new
+ Instruction.Set(DOCK,false,Predicate.Default, SET_FLAG, SET_FLAG));
+
+ prln("A and B should be true");
+ fatal(!inDock.getFlagA(), "bad A flag: false");
+ fatal(!inDock.getFlagB(), "bad B flag: false");
+
+ adjustIndent(-2);
+ prln("End sendTorpedo");
+ }
private void doOneTest(int testNum) {
prln("MarinaTest: performing test: "+testNum);
design.masterClear(tester);
case 1000: walkOneILC((IsolatedInDock)design); break;
case 1001: countIlc((IsolatedInDock)design); break;
case 1002: countOlc((IsolatedInDock)design); break;
+ case 1003: sendTorpedo((IsolatedInDock)design); break;
// Bill's tests begin with 2000
case 2000: break;