1 package com.sun.vlsi.chips.marina.test;
2 /* -*- tab-width: 4 -*- */
3 import java.util.ArrayList;
6 import com.sun.async.test.BitVector;
7 import com.sun.async.test.ChainControl;
8 import com.sun.async.test.ChainG;
9 import com.sun.async.test.ChainTest;
10 import com.sun.async.test.ChipModel;
11 import com.sun.async.test.HP34401A;
12 import com.sun.async.test.Infrastructure;
13 import com.sun.async.test.JtagSubchainTesterModel;
14 import com.sun.async.test.JtagTester;
15 import com.sun.async.test.ManualPowerChannel;
16 import com.sun.async.test.NanosimModel;
17 import com.sun.async.test.HsimModel;
18 import com.sun.async.test.VerilogModel;
19 import com.sun.async.test.Netscan4;
20 import com.sun.async.test.PowerChannel;
21 import com.sun.async.test.Pst3202Channel;
22 import com.sun.async.test.SiliconChip;
23 import com.sun.async.test.SimulationModel;
24 import com.sun.async.test.VoltageReadable;
25 import com.sun.vlsi.chips.marina.test.Marina.Ilc;
26 import com.sun.vlsi.chips.marina.test.CmdArgs;
27 import com.sun.vlsi.chips.marina.test.CmdArgs.Mode;
29 import edu.berkeley.fleet.api.Dock;
30 import edu.berkeley.fleet.api.Instruction;
31 import edu.berkeley.fleet.api.Predicate;
32 import edu.berkeley.fleet.api.Instruction.Set.SetDest;
33 import edu.berkeley.fleet.api.Instruction.Set.SetSource;
34 import edu.berkeley.fleet.marina.MarinaFleet;
35 import edu.berkeley.fleet.marina.MarinaPath;
40 public class MarinaTest {
41 public static final MarinaFleet marinaFleet = new MarinaFleet();
42 public static final Dock dock = marinaFleet.getOnlyInputDock();
44 //-------------------------- constants -----------------------------------
45 private static final String SCAN_CHAIN_XML = "marina.xml";
46 private static final String NET_LIST = "marina.spi";
48 public static final int INSTR_SZ = 36;
51 public static final Instruction.Set.FlagFunction CLEAR_FLAG
52 = Instruction.Set.FlagFunction.ZERO;
53 public static final Instruction.Set.FlagFunction SET_FLAG
54 = Instruction.Set.FlagFunction.ZERO.add(Predicate.FlagA)
55 .add(Predicate.NotFlagA);
56 public static final Instruction.Set.FlagFunction A_FLAG
57 = Instruction.Set.FlagFunction.ZERO.add(Predicate.FlagA);
59 public static final Instruction.Set.FlagFunction B_FLAG
60 = Instruction.Set.FlagFunction.ZERO.add(Predicate.FlagB);
62 // COLUMN_LATENCY is a delay that is larger than the latency through an Infinity column
63 private static final int COLUMN_LATENCY = 10; // nanoseconds
66 // Officially, this should be the number of requeueing no-ops that
67 // can be inserted into an idle dock whose OLC is nonzero.
69 // Less formally, this is roughly the number of stages of
70 // buffering between the instruction insertion point and the
71 // instruction ring, plus the capacity of the instruction ring.
72 private static final int INSTRUCTION_IN_SATURATION_AMOUNT = 19;
74 // This is some number which is significantly greater than
75 // INSTRUCTION_IN_SATURATION_AMOUNT. Increasing it may slow the tests down, but
76 // will never cause them to operate incorrectly.
77 private static final int MORE_THAN_INSTRUCTION_IN_SATURATION_AMOUNT = 25;
79 // This is the number of items which can be in the instruction
80 // fifo ring WITHOUT causing it to stop circulating.
81 private static final int INSTRUCTION_RING_CAPACITY = 13;
83 // Officially, this should be the number of data items which can
84 // be sent from the dock while the "data" proper stopper is in
85 // the "stopped" state
87 // Less formally, this is roughly the number of stages of
88 // buffering between the dock's data successor and the "data"
91 FIXME: what is the correct value here?
92 private static final int DATA_OUT_SATURATION_AMOUNT = XXX;
95 // This is some number which is greater than
96 // DATA_OUT_SATURATION_AMOUNT, but less than the capacity of the
98 private static final int MORE_THAN_DATA_OUT_SATURATION_AMOUNT = 10;
100 // Nominal cycle time assuming 4 GHz throughput
101 public static double CYCLE_TIME_NS;
103 //-------------------------------- types ---------------------------------
105 //-------------------------- private data --------------------------------
106 private static long startTime;
108 public static Indenter indenter = new Indenter();
109 private Marina marina;
110 private ChipModel model;
111 //private ChainControl cc;
112 //private JtagTester tester;
113 private CmdArgs cmdArgs;
114 private PowerChannel corePowerSupply, padsPowerSupply;
115 private VoltageReadable coreVoltmeter, voltmeterForCurrent;
117 private ChainTest ctD, ctR, ctC, ct;
118 private ChainControl ccD, ccR, ccC, cc;
120 //-------------------------- private methods -----------------------------
121 /** @return true if simulation. Return false if we're testing silicon. */
122 private boolean sim() {return model instanceof SimulationModel;}
124 private void prln(String msg) {indenter.prln(msg);}
125 private void pr(String msg) {indenter.pr(msg);}
126 private void adjustIndent(int n) {indenter.adjustIndent(n);}
128 public static void fatal(boolean pred, String msg) { MarinaUtils.fatal(pred, msg); }
130 public static void fatalIfBitVectorsDoNotMatch(BitVector bv1, BitVector bv2) {
131 // FIXME: better error reporting needed here
133 fatal(bv1.getNumBits()!=bv2.getNumBits(), "lengths do not match");
135 boolean mismatch = false;
137 for(int i=0; i<bv1.getNumBits(); i++) {
138 if (bv1.get(i) != bv2.get(i)) {
143 fatal(mismatch, "bit vectors do not match on bits " + err + "\n "+bv1+"\n "+bv2);
146 private static void printTestTime() {
147 long endTime = System.currentTimeMillis();
148 System.out.println("Test took: "+(endTime-startTime)/1000.0+" sec");
151 // Tell user what we're about to do
152 private static void reportTask(CmdArgs args) {
153 System.out.println("Begin testing Marina");
155 case WHOLE_CHIP_SCHEMATIC_PARASITICS:
156 System.out.println(" Simulate whole chip, schematic parasitics");
158 case WHOLE_CHIP_LAYOUT_PARASITICS:
159 System.out.println(" Simulate whole chip, layout parasitics");
162 System.out.println(" Test silicon");
165 fatal(true, "unrecognized CmdArgs.Mode");
169 private void setUpSuppliesAndMeters(Station station) {
170 // set up power supplies and meters
172 prln("Testing station: "+station);
173 Infrastructure.gpibControllers = new int[] {0};
174 switch (cmdArgs.station) {
176 corePowerSupply = new Pst3202Channel("ch1", "HPST3202", 1);
177 padsPowerSupply = new Pst3202Channel("ch2", "HPST3202", 2);
180 corePowerSupply = new Pst3202Channel("ch1", "HPST3202B", 1);
181 padsPowerSupply = new Pst3202Channel("ch2", "HPST3202B", 2);
184 fatal(true, "Unrecognized station: "+cmdArgs.station);
186 corePowerSupply.setCurrent((float)1.7);
187 corePowerSupply.setVoltageWait((float)1.0);
189 padsPowerSupply.setCurrent((float)0.100);
190 padsPowerSupply.setVoltageWait((float)1.8);
192 coreVoltmeter = new HP34401A(station.coreVoltmeter);
193 voltmeterForCurrent = new HP34401A(station.currentVoltmenter);
197 private MarinaTest(String[] args) {
198 cmdArgs = new CmdArgs(args);
200 if (cmdArgs.mode==Mode.TEST_SILICON) doSilicon(); else doSim();
203 private void doSim() {
205 switch (cmdArgs.mode) {
206 case WHOLE_CHIP_SCHEMATIC_PARASITICS:
207 netListName = NET_LIST;
209 case WHOLE_CHIP_LAYOUT_PARASITICS:
210 netListName = "marina_pads_guts.spi";
213 fatal(true, "unrecognized CmdArgs.Mode");
216 model = cmdArgs.useVerilog
220 : new NanosimModel();
222 ((SimulationModel)model).setOptimizedDirectReadsWrites(true);
224 CYCLE_TIME_NS = cmdArgs.useVerilog ? (100*20) : 0.250;
225 int khz = model instanceof VerilogModel ? 100000 : cmdArgs.jtagShift ? 20000 : 1000000;
227 prln("constructing jtag controller");
228 JtagTester tester = ((SimulationModel)model).createJtagTester("TCK", "TMS", "TRSTb", "TDI", "TDO");
229 tester.printInfo = false;
231 ChainControls ccs = new ChainControls();
232 PowerChannel pc = new ManualPowerChannel("pc", false);
234 JtagTester testerD, testerR, testerC;
235 testerD = ((SimulationModel)model).createJtagSubchainTester("sid[1:9]", null);
236 testerR = ((SimulationModel)model).createJtagSubchainTester("sir[1:9]", null);
237 testerC = ((SimulationModel)model).createJtagSubchainTester("sic[1:9]", null);
238 testerD.printInfo = testerR.printInfo = testerC.printInfo = false;
240 ccD = new ChainControl(SCAN_CHAIN_XML, testerD, 1.8f, khz);
241 ccR = new ChainControl(SCAN_CHAIN_XML, testerR, 1.8f, khz);
242 ccC = new ChainControl(SCAN_CHAIN_XML, testerC, 1.8f, khz);
243 ccD.noTestSeverity = ccR.noTestSeverity = ccC.noTestSeverity = Infrastructure.SEVERITY_NOMESSAGE;
246 ctD = new ChainTest(ccD, pc);
247 ctR = new ChainTest(ccR, pc);
248 ctC = new ChainTest(ccC, pc);
251 ccs.addChain(Marina.DATA_CHAIN, ccD);
252 ccs.addChain(Marina.REPORT_CHAIN, ccR);
253 ccs.addChain(Marina.CONTROL_CHAIN, ccC);
256 cc = new ChainControl(SCAN_CHAIN_XML, tester, 1.8f, khz);
257 cc.noTestSeverity = Infrastructure.SEVERITY_NOMESSAGE;
258 ct = new ChainTest(cc, pc);
259 ccs.addChain(Marina.DATA_CHAIN, cc);
260 ccs.addChain(Marina.REPORT_CHAIN, cc);
261 ccs.addChain(Marina.CONTROL_CHAIN, cc);
263 marina = new Marina(ccs, model, !cmdArgs.jtagShift, indenter);
265 if (model instanceof VerilogModel)
266 ((SimulationModel)model).start("verilog", "marina.v", VerilogModel.DUMPVARS, !cmdArgs.jtagShift);
267 else if (model instanceof HsimModel)
268 ((SimulationModel)model).start("hsim64", netListName, 0, !cmdArgs.jtagShift);
270 ((SimulationModel)model).start("nanosim -c cfg", netListName, 0, !cmdArgs.jtagShift);
274 ccC.shift(Marina.CONTROL_CHAIN, false, true);
278 cc.shift(Marina.CONTROL_CHAIN, false, true);
280 doOneTest(cmdArgs.testNum);
282 ((SimulationModel)model).finish();
284 private void doSilicon() {
285 model = new SiliconChip();
286 String ip = cmdArgs.station.ipAddr;
287 JtagTester tester = new Netscan4(ip, cmdArgs.station.jtagChannel);
288 tester.printInfo = false;
290 ChainControl cc = new ChainControl("???", tester, 1.8f, khz);
291 cc.noTestSeverity = Infrastructure.SEVERITY_NOMESSAGE;
292 ChainControls ccs = new ChainControls();
293 ccs.addChain(Marina.DATA_CHAIN, cc);
294 ccs.addChain(Marina.REPORT_CHAIN, cc);
295 ccs.addChain(Marina.CONTROL_CHAIN, cc);
296 marina = new Marina(ccs, model, false, indenter);
297 PowerChannel pc = new ManualPowerChannel("pc", false);
298 ChainTest ct = new ChainTest(cc, pc);
299 ct.testAllChains("marina", Infrastructure.SEVERITY_WARNING);
300 doOneTest(cmdArgs.testNum);
301 setUpSuppliesAndMeters(cmdArgs.station);
304 /** In the absence of looping, the longest path through Infinity is 4 column delays */
305 private void waitUntilQuiescent() {
306 model.waitNS(4*COLUMN_LATENCY);
309 private double readCurrent() {
310 return voltmeterForCurrent.readVoltage() / cmdArgs.station.ammeterShuntResistance;
313 /** Generate List of BitVectors where Token=true, high 25 data bits
314 * are alternating ones and zeros, low 12 data bits increment from
315 * zero, and address is given by addr. */
316 private List<BitVector> makeIncrDataConstAdr(int num, int addr) {
317 List<BitVector> ans = new ArrayList<BitVector>();
318 BitVector dHi = new BitVector(25, "dataHi");
319 BitVector dLo = new BitVector(12, "dataLo");
320 BitVector t = new BitVector("1", "token");
321 BitVector a = new BitVector(14, "addr");
322 dHi.setFromLong(0x00aaaaa);
324 for (int i=0; i<num; i++) {
326 ans.add(dHi.cat(dLo).cat(t).cat(a));
331 private void stopToStop(ProperStopper s1, ProperStopper s2,
333 List<BitVector> din) {
334 prln("Begin stopToStop");
339 long ctrStart = ctr==null ? 0 : ctr.getCount();
342 waitUntilQuiescent();
344 List<BitVector> dout = s2.drainMany();
346 MarinaUtils.compareItemsOrdered(din, dout);
349 long ctrEnd = ctr.getCount();
350 long delta = ctrEnd - ctrStart;
351 long expect = din.size();
353 "counter delta wrong: expected delta: "+expect+
354 " counter before:"+ctrStart+" counter after:"+ctrEnd);
358 prln("End stopToStop");
360 /** Burst data from src to dst. gate is stopped while loading src. gate
361 * is then run to allow the burst to flow. */
362 private void stopToStopBurst(ProperStopper src, ProperStopper gate,
365 List<BitVector> din) {
366 prln("Begin stopToStopBurst test");
372 long ctrStart = ctr==null ? 0 : ctr.getCount();
375 waitUntilQuiescent();
377 // open the gate to start the burst
379 waitUntilQuiescent();
381 List<BitVector> dout = dst.drainMany();
383 MarinaUtils.compareItemsOrdered(din, dout);
386 long ctrEnd = ctr.getCount();
387 long delta = ctrEnd - ctrStart;
389 long expectA = din.size();
390 fatal(delta!=expectA,
391 "counter delta wrong: expected delta: "+expectA+
392 " counter before:"+ctrStart+" counter after:"+ctrEnd);
396 prln("End stopToStopBurst test");
399 private void stopToStopOne(ProperStopper s1, ProperStopper s2,
400 Counter ctr, int adr) {
401 prln("Begin stopToStopOne");
404 List<BitVector> din = makeIncrDataConstAdr(1, adr);
405 stopToStop(s1, s2, ctr, din);
408 prln("End stopToStopOne");
411 private void stopToStopThree(ProperStopper s1, ProperStopper s2,
412 Counter ctr, int adr) {
413 prln("Begin stopToStopOne");
416 List<BitVector> din = makeIncrDataConstAdr(3, adr);
417 stopToStop(s1, s2, ctr, din);
420 prln("End stopToStopOne");
423 private int indexOf(BitVector o, List<BitVector> dIn) {
424 for (int i=0; i<dIn.size(); i++) {
425 if (o.equals(dIn.get(i))) return i;
429 private String ringDump(List<BitVector> dIn, List<BitVector> dOut) {
430 StringBuffer sb = new StringBuffer();
431 sb.append(" ring dump: ");
432 for (BitVector o : dOut) {
433 sb.append(indexOf(o, dIn)+" ");
435 return sb.toString();
438 private int[][] makeIntArray2D(int a, int b) {
439 int[][] ans = new int[a][];
440 for (int i=0; i<a; i++) ans[i] = new int[b];
444 //=========================================================================
445 // Put top level tests here
447 private void testChains(Marina marina) {
449 prln("Testing control chain...");
450 ctC.testOneChain(Marina.CONTROL_CHAIN, Infrastructure.SEVERITY_WARNING);
452 ccC.shift(Marina.CONTROL_CHAIN, false, true);
456 prln("Testing data chain...");
457 ctD.testOneChain(Marina.DATA_CHAIN, Infrastructure.SEVERITY_WARNING);
459 //ccD.shift(Marina.DATA_CHAIN, false, true);
463 prln("Testing report chain...");
464 ctR.testOneChain(Marina.REPORT_CHAIN, Infrastructure.SEVERITY_WARNING);
466 //ccR.shift(Marina.REPORT_CHAIN, false, true);
470 prln("Testing control chain...");
471 ct.testOneChain(Marina.CONTROL_CHAIN, Infrastructure.SEVERITY_WARNING);
473 cc.shift(Marina.CONTROL_CHAIN, false, true);
474 prln("Testing data chain...");
475 ct.testOneChain(Marina.DATA_CHAIN, Infrastructure.SEVERITY_WARNING);
476 prln("Testing report chain...");
477 ct.testOneChain(Marina.REPORT_CHAIN, Infrastructure.SEVERITY_WARNING);
481 private void testProperStoppers(Marina marina) {
482 prln("Begin testProperStoppers");
485 for(ProperStopper ps : new ProperStopper[] { marina.data, marina.instrIn }) {
487 prln("testing " + (ps == marina.data ? "data" : "instruction") + " stopper");
490 prln("un-stopping stopper");
492 fatal( ps.getStopped(), "stopper should not have been stopped, but was");
494 prln("stopping stopper");
496 fatal( !ps.getStopped(), "stopper should have been stopped, but was not");
504 private void sendInstructions(Marina marina) {
505 prln("Begin sendInstructions");
508 List<BitVector> din = new ArrayList<BitVector>();
510 BitVector count = new BitVector(MarinaPacket.WORD_WIDTH,"count");
511 BitVector one = new BitVector(MarinaPacket.WORD_WIDTH, "one");
512 count.setFromLong(0);
514 for (int i=0; i<3; i++) {
516 count = count.add(one);
519 for(BitVector d : din)
520 marina.instrIn.fill(new MarinaPacket(d, false, MarinaPacket.null_path));
523 prln("End sendInstructions");
526 private void sendToken(Marina marina) {
527 prln("Begin sendToken");
530 //getCtrsFlags(marina);
532 int nbToks = marina.getNumTokens();
533 fatal(nbToks!=0, "Expected no tokens on initialization but got: "+nbToks+" tokens");
535 marina.instrIn.fill(setIlc(1));
536 marina.instrIn.fill(SEND_TOKEN);
537 nbToks = marina.getNumTokens();
538 fatal(nbToks!=1, "Expected one token to emerge but got: "+nbToks+" tokens");
541 prln("End sendToken");
544 private void sendData(Marina marina) {
545 prln("Begin sendData");
548 edu.berkeley.fleet.api.BitVector bv = new edu.berkeley.fleet.api.BitVector(13);
549 for(int i=0; i<bv.length(); i+=2) bv.set(i, false);
550 MarinaPath path = new MarinaPath((MarinaFleet)dock.getShip().getFleet(), bv);
552 marina.instrIn.fill(setIlc(1));
553 marina.instrIn.fill(SEND_DATA);
555 List<BitVector> dataItems = marina.data.drainMany();
556 fatal(dataItems.size()!=1, "Expected one data item to emerge but got: "+dataItems.size()+" data items");
558 MarinaPacket mp = new MarinaPacket(dataItems.get(0));
559 fatal(mp.tokenhood, "Expected tokenhood=data, but got tokenhood=token");
562 prln("End sendData");
565 private void sendDataIlcInfinite(Marina marina) {
566 prln("Begin sendDataIlcInfinite");
569 marina.fillSouthProperStopper(new Instruction[] {
570 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter,SetSource.Infinity),
576 List<BitVector> dataItems = marina.data.drainMany(howmany);
577 fatal(dataItems.size()!=howmany,
578 "Expected an unending supply of data items to emerge but only got got: "+dataItems.size());
581 prln("End sendDataIlcInfinite");
584 private Instruction setOlc(int olc) {
585 return new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter, olc);
587 private Instruction setOlcIfZero(int olc) {
588 return new Instruction.Set(dock,Predicate.Default,SetDest.OuterLoopCounter, olc);
590 private Instruction setIlc(int ilc) {
591 return new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, ilc);
594 private void testFlagD(Marina marina) {
595 prln("Begin testFlagD");
598 List<BitVector> toks;
600 Predicate only_if_olc_zero = Predicate.FlagD;
601 Predicate only_if_olc_nonzero = Predicate.Default;
603 marina.instrIn.fill(setIlc(1));
605 for(int olc : new int[] { 1, 0 }) {
606 for(boolean predicate_olc_nonzero : new boolean[] { true, false }) {
607 prln("Attempting send data item with "+
609 "predicate olc"+(predicate_olc_nonzero?"!=0":"==0"));
612 marina.fillSouthProperStopper(new Instruction[] {
614 new Instruction.Move(dock,
615 predicate_olc_nonzero // predicate
616 ? only_if_olc_nonzero
619 false, // torpedoable
629 expectNorthFifoExactly((predicate_olc_nonzero == (olc!=0)) ? 1 : 0);
631 for(int i=0; i<olc; i++)
632 marina.instrIn.fill(DEC);
638 prln("End testFlagD");
641 private void testPredicationOnAB(Marina marina) {
642 prln("Begin testPredicationOnAB");
645 List<BitVector> dItems;
647 marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter, 1));
648 marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, 1));
650 for(boolean flag_a : new boolean[] { false, true }) {
651 for(boolean flag_b : new boolean[] { false, true }) {
652 prln("Setting flags, a="+flag_a+" b="+flag_b);
653 marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,
655 ? Instruction.Set.FlagFunction.ONE
656 : Instruction.Set.FlagFunction.ZERO,
658 ? Instruction.Set.FlagFunction.ONE
659 : Instruction.Set.FlagFunction.ZERO
661 getCtrsFlags(marina);
664 for(Predicate predicate : new Predicate[] {
672 prln("Attempting send data with a="+flag_a+", b="+flag_b+", predicate="+predicate);
674 marina.instrIn.fill(new Instruction.Move(dock,
675 predicate, // predicate
676 false, // torpedoable
686 dItems = marina.data.drainMany();
687 int expected = predicate.evaluate(flag_a, flag_b, false, false) ? 1 : 0;
688 fatal(dItems.size()!=expected, "Expected "+expected+" data items to emerge but got: "+
689 dItems.size()+" items(s)");
695 prln("End testPredicationOnAB");
699 private void showOlc() {
700 prln("OLC=="+marina.getOLC());
702 private void expectOlc(int x) {
703 int olc = marina.getOLC();
704 fatal(x!=olc, "expected OLC=="+x+", but scanned out OLC=="+olc);
707 private void getCtrsFlags(Marina marina) {
708 prln("begin getCtrsFlags");
712 Ilc ilc = marina.getILC();
713 prln("ILC.done=="+ilc.getDone()+
714 " ILC.infinity=="+ilc.getInfinity()+
715 " ILC.count=="+ilc.getCount());
716 prln("flagA=="+marina.getFlagA());
717 prln("flagB=="+marina.getFlagB());
719 prln("end getCtrsFlags");
722 private void walkOneOLC(Marina marina) {
723 prln("Begin walkOneOLC");
725 for (int i=0; i<6; i++) {
727 if (marina.kesselsCounter) {
728 System.out.println("master-clearing...");
729 // master clear on each iteration; otherwise we'd need to "run down" the olc
730 marina.masterClear();
731 marina.enableInstructionSend(true);
734 int inOlc = i==-1 ? 0 : (1<<i);
735 marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter, inOlc));
737 model.waitNS(128 * CYCLE_TIME_NS);
740 prln("walkOneOLC: "+inOlc+" checks out");
743 prln("End walkOneOLC");
745 private void walkOneILC(Marina marina) {
746 prln("Begin walkOneILC");
748 for (int i=0; i<6; i++) {
749 // Mask off the "zero" bit position
751 prln("inIlc="+inIlc);
752 marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, inIlc));
753 Ilc ilc = marina.getILC();
754 int outIlc = ilc.getCount();
755 fatal(outIlc!=inIlc, "bad ILC count: "+outIlc+" expected: "+inIlc);
756 fatal(ilc.getInfinity(), "bad Infinity bit: true");
758 prln("Now test the infinity bit");
759 marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, SetSource.Infinity));
760 Ilc ilc = marina.getILC();
761 fatal(!ilc.getInfinity(), "bad Infinity bit: false");
763 prln("End walkOneILC");
765 private void countIlc(Marina marina) {
766 final int maxIlc = 63;
767 prln("Begin countIlc");
770 marina.instrIn.fill(new
771 Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, maxIlc));
773 int ilc = marina.getILC().getCount();
774 fatal(ilc!=maxIlc, "bad ILC count: "+ilc+" expected: "+maxIlc);
776 prln("execute a move instruction that does nothing except decrement the ILC to zero");
778 new Instruction.Move(dock,
779 Predicate.IgnoreFlagD, // predicate
780 false, // torpedoable
790 // wait for ILC to count from 63 to 0
791 model.waitNS(128 * CYCLE_TIME_NS);
792 //model.waitNS(10000);
794 prln("Check that ILC==0");
795 ilc = marina.getILC().getCount();
796 fatal(ilc!=0, "bad ILC count: "+ilc+" expected: "+0);
799 prln("End countIlc");
801 // Note: countOlc takes 44 minutes to run on nanosim
802 private void countOlc(Marina marina) {
804 prln("Begin countOlc");
807 marina.instrIn.fill(setOlc(maxOlc));
809 for (int i=maxOlc; i>=0; i--) {
810 model.waitNS(128 * CYCLE_TIME_NS);
811 prln("OLC should be: "+i);
813 marina.instrIn.fill(new
814 Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter, SetSource.Decrement));
818 prln("End countOlc");
820 private void loadEveryValueOLC(Marina marina) {
822 for (int i=0; i<(1<<6); i++) {
824 if (marina.kesselsCounter) {
825 System.out.println("master-clearing...");
826 // master clear on each iteration; otherwise we'd need to "run down" the olc
827 marina.masterClear();
828 marina.enableInstructionSend(true);
832 marina.fillSouthProperStopper(new Instruction[] {
834 // to ensure that instruction is bubble-limited
837 // the Set-OLC instruction
838 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter, inOlc),
840 // put a Set-ILC instruction right behind it with inverted bits to be sure we're
841 // not capturing the instruction-latch value too late in the cycle
842 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, (inOlc ^ (~(-1<<6)))),
846 model.waitNS(128 * CYCLE_TIME_NS);
847 marina.fillNorthProperStopper();
848 model.waitNS(128 * CYCLE_TIME_NS);
851 prln("loadEveryValueOLC: "+inOlc+" checks out");
856 private void saturateInstructionFifo(Marina marina, Instruction instruction, int quantity, boolean expect_it_to_jam_up) {
857 prln("Inserting "+quantity+" copies of \"" + instruction + "\"");
860 for(i=0; i<quantity; i++) {
861 prln("Inserting instruction " + (i+1) +"/"+ quantity);
862 marina.instrIn.fill(instruction);
863 boolean jammed = (marina.instrIn.getFillStateWire()==MarinaUtils.StateWireState.FULL);
864 if (jammed && expect_it_to_jam_up) {
865 prln("Stopper remained full after inserting instruction; this was expected; we are happy.");
869 fatal(jammed, "Instruction stopper did not drain after inserting " + (i+1) + " instructions; not good!");
871 fatal(expect_it_to_jam_up, "Expected instruction stopper to jam up, but it did not");
873 prln("Successfully inserted " + i + " instructions");
876 private static MarinaPath null_path = new MarinaPath((MarinaFleet)dock.getShip().getFleet(),
877 MarinaUtils.sunToBerk(MarinaPacket.null_path));
879 private static final Instruction DEC =
880 new Instruction.Set(dock,Predicate.Default,SetDest.OuterLoopCounter, SetSource.Decrement);
882 private static final Instruction FLAG_NOP =
883 new Instruction.Set(dock, Predicate.IgnoreFlagD,
884 CLEAR_FLAG.add(Predicate.FlagA),
885 CLEAR_FLAG.add(Predicate.FlagB));
887 private static final Instruction NOP =
888 new Instruction.Move(dock,
889 Predicate.IgnoreFlagD, /* predicate */
890 false, /* torpedoable */
894 false, /* latchData */
895 false, /* latchPath */
900 private static final Instruction SEND_DATA =
901 new Instruction.Move(dock,
902 Predicate.IgnoreFlagD, /* predicate */
903 false, /* torpedoable */
904 null_path, /* path */
907 false, /* latchData */
908 false, /* latchPath */
913 private static final Instruction SEND_DATA_IF_D_NOT_SET =
914 new Instruction.Move(dock,
915 Predicate.Default, /* predicate */
916 false, /* torpedoable */
917 null_path, /* path */
920 false, /* latchData */
921 false, /* latchPath */
926 private static final Instruction SEND_DATA_IF_D_SET =
927 new Instruction.Move(dock,
928 Predicate.FlagD, /* predicate */
929 false, /* torpedoable */
930 null_path, /* path */
933 false, /* latchData */
934 false, /* latchPath */
939 private static final Instruction TORPEDOABLE_RECV_DATA =
940 new Instruction.Move(dock,
941 Predicate.IgnoreFlagD, /* predicate */
942 true, /* torpedoable */
946 true, /* latchData */
947 false, /* latchPath */
952 private static final Instruction RECV_DATA =
953 new Instruction.Move(dock,
954 Predicate.IgnoreFlagD, /* predicate */
955 false, /* torpedoable */
959 true, /* latchData */
960 false, /* latchPath */
965 private static final Instruction SEND_TOKEN =
966 new Instruction.Move(dock,
967 Predicate.IgnoreFlagD, /* predicate */
968 false, /* torpedoable */
969 null_path, /* path */
972 false, /* latchData */
973 false, /* latchPath */
978 private static final Instruction RECV_TOKEN =
979 new Instruction.Move(dock,
980 Predicate.IgnoreFlagD, /* predicate */
981 false, /* torpedoable */
985 false, /* latchData */
986 false, /* latchPath */
992 private void expectNorthFifoNoMoreThan(int num) {
993 model.waitNS(128 * CYCLE_TIME_NS);
994 List<BitVector> dataItems = marina.data.drainMany(num+1);
995 fatal(dataItems.size()>num,
996 "Expected no more than "+num+
997 " data items to emerge but got at least: "+dataItems.size());
999 private void expectNorthFifoExactly(int num) {
1000 model.waitNS(128 * CYCLE_TIME_NS);
1001 List<BitVector> dataItems = marina.data.drainMany(num+1);
1002 fatal(dataItems.size()!=num,
1003 "Expected exactly "+num+
1004 " data items to emerge but got at least: "+dataItems.size());
1006 private void expectNorthFifoAtLeast(int num) {
1007 model.waitNS(128 * CYCLE_TIME_NS);
1008 List<BitVector> dataItems = marina.data.drainMany(num);
1009 fatal(dataItems.size()<num,
1010 "Expected at least "+num+
1011 " data items to emerge but got only: "+dataItems.size());
1013 private void expectTokensNoMoreThan(int num) {
1014 int x = marina.getNumTokens();
1015 List<BitVector> dataItems = marina.data.drainMany(num+1);
1017 "Expected no more than "+num+
1018 " tokens to emerge but got at least: "+x);
1020 private void expectTokensExactly(int num) {
1021 int x = marina.getNumTokens();
1023 "Expected exactly "+num+
1024 " tokens but got at least: "+x);
1027 private void testFlagDRecomputationTime(Marina marina) {
1028 marina.instrIn.fill(setIlc(1));
1029 marina.fillSouthProperStopper(new Instruction[] {
1031 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter,0),
1032 SEND_DATA_IF_D_NOT_SET
1034 marina.fillNorthProperStopper();
1035 expectNorthFifoNoMoreThan(0);
1037 marina.fillSouthProperStopper(new Instruction[] {
1039 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter,1),
1040 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter,SetSource.Decrement),
1041 SEND_DATA_IF_D_NOT_SET
1043 marina.fillNorthProperStopper();
1044 expectNorthFifoNoMoreThan(0);
1046 marina.fillSouthProperStopper(new Instruction[] {
1048 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter,2),
1049 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter,SetSource.Decrement),
1050 SEND_DATA_IF_D_NOT_SET
1052 marina.fillNorthProperStopper();
1053 expectNorthFifoExactly(1);
1054 marina.instrIn.fill(DEC);
1056 marina.fillSouthProperStopper(new Instruction[] {
1058 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter,0),
1059 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter,1),
1060 SEND_DATA_IF_D_NOT_SET
1062 marina.fillNorthProperStopper();
1063 expectNorthFifoExactly(1);
1066 private void testTailWaitsForHead(Marina marina) {
1067 marina.instrIn.fill(setIlc(1));
1068 marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter, 63));
1070 marina.enableInstructionSend(false);
1071 marina.enableInstructionRecirculate(true);
1073 marina.instrIn.fill(TORPEDOABLE_RECV_DATA);
1074 marina.instrIn.fill(new Instruction.Head(dock));
1075 marina.instrIn.fill(SEND_DATA);
1076 marina.instrIn.fill(TORPEDOABLE_RECV_DATA);
1077 marina.instrIn.fill(SEND_TOKEN);
1078 marina.instrIn.fill(TORPEDOABLE_RECV_DATA);
1079 marina.instrIn.fill(new Instruction.Tail(dock));
1080 marina.instrIn.fillTorpedo();
1082 marina.enableInstructionRecirculate(false);
1083 marina.enableInstructionSend(true);
1084 marina.instrIn.run();
1086 expectNorthFifoNoMoreThan(0);
1087 prln("inserting into north proper stopper");
1088 marina.fillNorthProperStopper();
1089 expectNorthFifoExactly(1);
1090 int nbToks = marina.getNumTokens();
1091 fatal(nbToks!=1, "Expected one token to emerge but got: "+nbToks+" tokens");
1095 marina.instrIn.fill(setIlc(1));
1096 marina.instrIn.fill(setOlc(1));
1098 // this makes the head wait for the torpedo
1099 marina.instrIn.fill(TORPEDOABLE_RECV_DATA);
1101 // the head should wait for the tail
1102 marina.instrIn.fill(new Instruction.Head(dock));
1103 marina.instrIn.fill(NOP);
1104 marina.instrIn.fill(SEND_DATA);
1105 marina.instrIn.fill(RECV_DATA);
1107 expectNorthFifoNoMoreThan(0);
1109 marina.instrIn.fillTorpedo();
1110 expectNorthFifoNoMoreThan(0);
1112 marina.instrIn.fill(new Instruction.Tail(dock));
1113 expectNorthFifoExactly(1);
1116 private void testTailWithoutHead(Marina marina) {
1117 marina.instrIn.fill(setIlc(1));
1118 marina.fillSouthProperStopper(new Instruction[] {
1119 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter, 63),
1120 new Instruction.Tail(dock),
1123 List<BitVector> dataItems = marina.data.drainMany(1);
1124 fatal(dataItems.size()!=0, "Expected exactly no data items to emerge but got at least: "+dataItems.size());
1127 private void testHeadWaitsForTail(Marina marina) {
1128 List<BitVector> dataItems;
1130 prln("Begin testHeadWaitsForTail");
1133 marina.instrIn.fill(setIlc(1));
1134 marina.fillSouthProperStopper(new Instruction[] {
1135 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter, 63),
1136 new Instruction.Head(dock),
1137 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter,1),
1141 expectNorthFifoExactly(0);
1142 marina.instrIn.fill(new Instruction.Tail(dock));
1143 expectNorthFifoAtLeast(1);
1146 prln("End testHeadWaitsForTail");
1149 private void testNonTorpedoableMoveDoesNotResetDFlag(Marina marina) {
1150 marina.instrIn.fill(setIlc(1));
1151 marina.fillSouthProperStopper(new Instruction[] {
1152 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter,63),
1153 new Instruction.Move(dock,
1154 Predicate.IgnoreFlagD, // predicate
1155 true, // torpedoable
1164 new Instruction.Move(dock,
1165 Predicate.FlagD, // predicate
1166 false, // torpedoable
1176 marina.instrIn.fillTorpedo();
1177 expectNorthFifoExactly(1);
1178 marina.fillSouthProperStopper(new Instruction[] {
1179 new Instruction.Move(dock,
1180 Predicate.Default, // predicate
1181 false, // torpedoable
1191 expectNorthFifoNoMoreThan(0);
1194 private void testAbort(Marina marina) {
1196 marina.instrIn.fill(setIlc(1));
1197 marina.fillSouthProperStopper(new Instruction[] {
1198 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.DataLatch,1),
1199 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter,2),
1200 SEND_DATA_IF_D_NOT_SET,
1201 new Instruction.Head(dock),
1202 SEND_DATA_IF_D_NOT_SET,
1203 new Instruction.Set(dock,Predicate.Default,SetDest.DataLatch,2),
1204 new Instruction.Abort(dock, Predicate.FlagD),
1205 new Instruction.Set(dock,Predicate.Default,SetDest.OuterLoopCounter,SetSource.Decrement),
1206 new Instruction.Tail(dock),
1209 for(int i=0; i<4; i++) {
1212 model.waitNS(128 * CYCLE_TIME_NS);
1213 bv = new MarinaPacket(marina.data.drain()).data.bitReverse();
1214 fatal(bv==null, "no data item found");
1215 prln("got " + bv.toLong());
1216 fatal(bv.toLong()!=1, "expected 1, got " + bv.toLong());
1218 model.waitNS(128 * CYCLE_TIME_NS);
1219 bv = new MarinaPacket(marina.data.drain()).data.bitReverse();
1220 fatal(bv==null, "no data item found");
1221 prln("got " + bv.toLong());
1222 fatal(bv.toLong()!=1, "expected 1, got " + bv.toLong());
1224 model.waitNS(128 * CYCLE_TIME_NS);
1225 bv = new MarinaPacket(marina.data.drain()).data.bitReverse();
1226 fatal(bv==null, "no data item found");
1227 prln("got " + bv.toLong());
1228 fatal(bv.toLong()!=2, "expected 2, got " + bv.toLong());
1233 private void testAbortOutsideOfLoop(Marina marina) {
1234 marina.instrIn.fill(setIlc(1));
1235 marina.fillSouthProperStopper(new Instruction[] {
1236 // ensure that an abort doesn't cause problems if no loop is in progress
1237 new Instruction.Abort(dock, Predicate.IgnoreFlagD),
1240 expectNorthFifoExactly(1);
1243 private void testFlagAB(Marina marina) {
1244 prln("Begin testFlagAB");
1247 Instruction.Set.FlagFunction zero = Instruction.Set.FlagFunction.ZERO;
1248 Instruction.Set.FlagFunction one = zero;
1251 // we should be able to use any pair of FlagX+NotFlagX,
1252 // but we toss them all in to maximize the chances of the
1253 // test passing (later we will try the individual
1254 // combinations to maximize the chances of failure).
1255 one = one.add(Predicate.FlagA);
1256 one = one.add(Predicate.NotFlagA);
1257 one = one.add(Predicate.FlagB);
1258 one = one.add(Predicate.NotFlagB);
1259 one = one.add(Predicate.FlagC);
1260 one = one.add(Predicate.NotFlagC);
1262 marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter,1));
1263 for(boolean fast : new boolean[] { true, false }) {
1264 // clear the flags to a known state, then check both 0->1 and 1->0 transitions
1265 for(boolean b : new boolean[] { false, true, false }) {
1266 prln("state: a="+marina.getFlagA()+", b="+marina.getFlagB());
1267 prln((b?"Setting":"Clearing")+" flags");
1269 Instruction inst = new Instruction.Set(dock,Predicate.IgnoreFlagD,
1274 marina.fillSouthProperStopper(new Instruction[] {
1279 model.waitNS(64 * CYCLE_TIME_NS);
1280 marina.fillNorthProperStopper();
1282 marina.instrIn.fill(inst);
1285 fatal(marina.getFlagA()!=b,
1286 "after "+(b?"setting":"clearing")+" FlagA, it was still "+(b?"clear":"set"));
1287 fatal(marina.getFlagB()!=b,
1288 "after "+(b?"setting":"clearing")+" FlagB, it was still "+(b?"clear":"set"));
1293 prln("End testFlagAB");
1297 * WARNING: this is a very, very, very long test case -- it goes
1298 * through 216 iterations.
1300 private void testFlagTruthTable(Marina marina) {
1301 prln("Begin testFlagTruthTable");
1304 marina.instrIn.fill(setIlc(1));
1305 Instruction.Set.FlagFunction zero = Instruction.Set.FlagFunction.ZERO;
1306 Instruction.Set.FlagFunction one = zero.add(Predicate.FlagA).add(Predicate.NotFlagA);
1308 for(Predicate a_input : new Predicate[] { null, Predicate.FlagA, Predicate.NotFlagA })
1309 for(Predicate b_input : new Predicate[] { null, Predicate.FlagB, Predicate.NotFlagB })
1310 for(Predicate c_input : new Predicate[] { null, Predicate.FlagC, Predicate.NotFlagC })
1311 for(boolean a_state : new boolean[] { false, true })
1312 for(boolean b_state : new boolean[] { false, true })
1313 for(boolean c_state : new boolean[] { false, true }) {
1314 for(boolean which : new boolean[] { false, true }) {
1316 prln("before instruction: a="+a_state+", b="+b_state+", c="+c_state);
1317 // set A,B flags to a_state and b_state
1318 marina.instrIn.fill(new
1319 Instruction.Set(dock,Predicate.IgnoreFlagD,
1320 a_state ? one : zero,
1321 b_state ? one : zero
1324 // set C flag to c_state
1325 BitVector data = new BitVector(37, "empty");
1326 BitVector addr = new BitVector(14, "empty");
1327 for(int i=0; i<data.getNumBits(); i++) data.set(i, false);
1328 for(int i=0; i<addr.getNumBits(); i++) addr.set(i, false);
1329 addr.set(Marina.INDEX_OF_ADDRESS_BIT_COPIED_TO_C_FLAG_WHEN_DC_EQUALS_ONE, c_state);
1330 marina.fillNorthProperStopper(new MarinaPacket(data, false, addr));
1331 marina.instrIn.fill(RECV_DATA);
1333 Instruction.Set.FlagFunction func = zero;
1334 if (a_input!=null) func = func.add(a_input);
1335 if (b_input!=null) func = func.add(b_input);
1336 if (c_input!=null) func = func.add(c_input);
1338 Instruction inst = new
1339 Instruction.Set(dock,Predicate.IgnoreFlagD,
1340 !which ? func : zero.add(Predicate.FlagA),
1341 which ? func : zero.add(Predicate.FlagB)
1344 marina.instrIn.fill(inst);
1346 boolean expected_a = !which ? func.evaluate(a_state, b_state, c_state, false) : a_state;
1347 boolean expected_b = which ? func.evaluate(a_state, b_state, c_state, false) : b_state;
1348 fatal(expected_a != marina.getFlagA(),
1349 "expected A="+expected_a+", but got "+marina.getFlagA());
1350 fatal(expected_b != marina.getFlagB(),
1351 "expected B="+expected_b+", but got "+marina.getFlagB());
1355 prln("End testFlagTruthTable");
1358 private void recvData(Marina marina) {
1359 prln("Begin recvData");
1362 marina.instrIn.fill(setIlc(1));
1363 marina.fillSouthProperStopper(new Instruction[] {
1364 new Instruction.Set(dock,Predicate.IgnoreFlagD, CLEAR_FLAG, CLEAR_FLAG),
1365 new Instruction.Move(dock,
1366 Predicate.IgnoreFlagD, // predicate
1367 false, // torpedoable
1376 new Instruction.Set(dock,Predicate.IgnoreFlagD, SET_FLAG, SET_FLAG),
1378 model.waitNS(64 * CYCLE_TIME_NS);
1380 prln("checking to confirm that A flag is cleared");
1381 fatal(marina.getFlagA(), "bad A flag: "+marina.getFlagA());
1383 prln("inserting data item in north fifo ring");
1384 BitVector data = new BitVector(37, "empty");
1385 BitVector addr = new BitVector(14, "empty");
1386 for(int i=0; i<data.getNumBits(); i++) data.set(i, false);
1387 for(int i=0; i<addr.getNumBits(); i++) addr.set(i, false);
1388 marina.fillNorthProperStopper(new MarinaPacket(data, false, addr));
1389 model.waitNS(64 * CYCLE_TIME_NS);
1391 prln("checking to see if A flag got set");
1392 fatal(!marina.getFlagA(), "bad A flag: "+marina.getFlagA());
1395 prln("End recvData");
1399 private void testRecvAndSendWalkingOne(Marina marina) {
1400 prln("Begin testRecvAndSendWalkingOne");
1403 marina.instrIn.fill(setIlc(1));
1405 List<BitVector> dataItems;
1406 for(int bit=0; bit<37; bit++) {
1408 BitVector data = new BitVector(37, "empty");
1409 BitVector addr = new BitVector(14, "empty");
1410 for(int i=0; i<data.getNumBits(); i++) data.set(i, false);
1411 for(int i=0; i<addr.getNumBits(); i++) addr.set(i, false);
1412 data.set(bit, true);
1413 prln("testing with bit pattern " + data);
1415 prln("inserting data item into north fifo ring");
1416 marina.fillNorthProperStopper(new MarinaPacket(data, false, addr));
1418 prln("stopping the north proper stopper");
1421 dataItems = marina.data.drainMany(1);
1422 fatal(dataItems.size()!=0,
1423 "found a data item waiting in the north proper stopper, but should not have");
1425 marina.instrIn.fill(new Instruction.Move(dock,
1426 Predicate.IgnoreFlagD, // predicate
1427 false, // torpedoable
1437 dataItems = marina.data.drainMany(2);
1438 fatal(dataItems.size()!=1,
1439 "found "+dataItems.size()+" data items in north fifo; expected one");
1440 MarinaPacket mp = new MarinaPacket(dataItems.get(0));
1441 fatalIfBitVectorsDoNotMatch(mp.data, data);
1445 prln("End testRecvAndSendWalkingOne");
1450 private void setOlcFromDataLatch(Marina marina) {
1451 prln("Begin setOlcFromDataLatch");
1454 marina.instrIn.fill(setIlc(1));
1456 // walk a bit from 0 to 5
1457 for(int bit=0; bit<6; bit++) {
1458 prln("inserting data item in north fifo ring");
1459 BitVector data = new BitVector(37, "empty");
1460 BitVector addr = new BitVector(14, "empty");
1461 for(int i=0; i<data.getNumBits(); i++) data.set(i, false);
1462 for(int i=0; i<addr.getNumBits(); i++) addr.set(i, false);
1463 data.set(bit, true);
1464 marina.fillNorthProperStopper(new MarinaPacket(data, false, addr));
1466 marina.fillSouthProperStopper(new Instruction[] {
1468 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter,SetSource.DataLatch),
1469 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.DataLatch,-1),
1472 model.waitNS(CYCLE_TIME_NS * 64);
1476 if (marina.kesselsCounter) {
1477 // master clear on each iteration; otherwise we'd need to "run down" the olc
1478 marina.masterClear();
1479 marina.enableInstructionSend(true);
1484 prln("End setOlcFromDataLatch");
1487 private void setIlcFromDataLatch(Marina marina) {
1488 prln("Begin setIlcFromDataLatch");
1491 marina.instrIn.fill(setIlc(1));
1493 // walk a bit from 0 to 5
1494 for(int bit=5; bit>=0; bit--) {
1495 prln("inserting data item in north fifo ring");
1496 BitVector data = new BitVector(37, "empty");
1497 BitVector addr = new BitVector(14, "empty");
1498 for(int i=0; i<data.getNumBits(); i++) data.set(i, false);
1499 for(int i=0; i<addr.getNumBits(); i++) addr.set(i, false);
1500 data.set(bit, true);
1501 marina.fillNorthProperStopper(new MarinaPacket(data, false, addr));
1503 marina.fillSouthProperStopper(new Instruction[] {
1504 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter,1),
1506 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter,SetSource.DataLatch),
1508 model.waitNS(CYCLE_TIME_NS * 64);
1510 int ilc = marina.getILC().getCount();
1511 fatal(ilc != (1<<bit), "expected ilc to be " + (1<<bit) + ", but got " + ilc);
1515 prln("End setIlcFromDataLatch");
1518 private void testSendAndRecvToken(Marina marina) {
1519 prln("Begin testSendAndRecvToken");
1522 marina.instrIn.fill(setIlc(1));
1523 marina.fillSouthProperStopper(new Instruction[] {
1528 expectNorthFifoExactly(1);
1531 prln("End testSendAndRecvToken");
1534 private void testSignExtendedLiteral(Marina marina) {
1535 prln("Begin testSignExtendedLiteral");
1538 marina.instrIn.fill(setIlc(1));
1539 for(long val : new long[] { (-1L << 14), -1, 0, 1 }) {
1541 marina.fillSouthProperStopper(new Instruction[] {
1542 new Instruction.Set(dock,Predicate.IgnoreFlagD,
1543 Instruction.Set.SetDest.DataLatch,
1547 model.waitNS(CYCLE_TIME_NS * 64);
1549 List<BitVector> dataItems = marina.data.drainMany(3);
1550 fatal(dataItems.size()!=1, "expected exactly one data item, got " + dataItems.size());
1552 MarinaPacket mp = new MarinaPacket(dataItems.get(0));
1553 BitVector bv = mp.data;
1554 prln("got back " + mp);
1556 boolean mismatch = false;
1558 for(int i=0; i<37; i++) {
1559 if (bv.get(i) != ( (val & (1L << i)) != 0 )) {
1564 fatal(mismatch, "data read back did not match inserted literal; mismatch on bits " + err);
1568 prln("End testSignExtendedLiteral");
1571 private void testShiftedLiteral(Marina marina) {
1572 prln("Begin testShiftedLiteral");
1575 marina.instrIn.fill(setIlc(1));
1576 marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,
1577 Instruction.Set.SetDest.DataLatch,
1580 BitVector dreg = new BitVector(37, "what we think is in the d-register");
1581 for(int i=0; i<37; i++) dreg.set(i, false);
1583 for(long val : new long[] { -1, 0, 1, (-1L << 18) }) {
1585 edu.berkeley.fleet.api.BitVector immediate =
1586 new edu.berkeley.fleet.api.BitVector(19);
1587 for(int i=0; i<immediate.length(); i++)
1588 immediate.set(i, (val & (1L << i)) != 0);
1590 // shift over 19 LSB's towards MSB
1591 for(int i=0; i<19; i++)
1592 if (i+19 <= 36) dreg.set(i+19, dreg.get(i));
1593 for(int i=0; i<19; i++)
1594 dreg.set(i, immediate.get(i));
1596 marina.fillSouthProperStopper(new Instruction[] {
1597 new Instruction.Shift(dock,Predicate.IgnoreFlagD,immediate),
1601 model.waitNS(CYCLE_TIME_NS * 64);
1602 List<BitVector> dataItems = marina.data.drainMany(3);
1603 fatal(dataItems.size()!=1, "expected exactly one data item, got " + dataItems.size());
1605 BitVector bv = new MarinaPacket(dataItems.get(0)).data;
1606 fatal(!bv.equals(dreg), "data read back did not match inserted literal.\n" +
1607 "got: "+bv.bitReverse().getState()+"\n"+
1608 "expected:"+dreg.bitReverse().getState());
1612 prln("End testShiftedLiteral");
1615 private void testFlagC(Marina marina) {
1616 prln("Begin testFlagC");
1624 // Dc=1 => sigS is copied into C-flag
1625 // Dc=0 => sigA is copied into C-flag
1627 marina.instrIn.fill(setIlc(1));
1628 for(boolean dc : new boolean[] { false, true }) {
1629 for(boolean c_flag : new boolean[] { true, false, true }) {
1632 prln("****** checking case where dc="+dc+", cflag="+c_flag);
1633 BitVector data = new BitVector(37, "empty");
1634 BitVector addr = new BitVector(14, "empty");
1635 for(int i=0; i<data.getNumBits(); i++) data.set(i, false);
1636 for(int i=0; i<addr.getNumBits(); i++) addr.set(i, false);
1639 ? Marina.INDEX_OF_ADDRESS_BIT_COPIED_TO_C_FLAG_WHEN_DC_EQUALS_ONE
1640 : Marina.INDEX_OF_ADDRESS_BIT_COPIED_TO_C_FLAG_WHEN_DC_EQUALS_ZERO;
1641 prln("setting addr["+whichbit+"] to "+(c_flag?"1":"0"));
1642 addr.set(whichbit, c_flag);
1644 prln("... and filling north fifo proper stopper");
1645 marina.fillNorthProperStopper(new MarinaPacket(data, false, addr));
1647 prln("clearing flags");
1648 prln("executing recv data with Dc="+dc);
1649 prln("copying c-flag to a-flag");
1650 marina.fillSouthProperStopper(new Instruction[] {
1651 new Instruction.Set(dock,Predicate.IgnoreFlagD, CLEAR_FLAG, CLEAR_FLAG),
1652 new Instruction.Move(dock,
1653 Predicate.IgnoreFlagD, /* predicate */
1654 true, /* torpedoable */
1656 false, /* tokenIn */
1659 false, /* latchPath */
1660 false, /* dataOut */
1661 false /* tokenOut */
1664 new Instruction.Set(dock,Predicate.IgnoreFlagD,
1665 Instruction.Set.FlagFunction.ZERO.add(Predicate.FlagC),
1670 model.waitNS(CYCLE_TIME_NS * 64);
1672 prln("checking to confirm that A flag is " + c_flag);
1673 fatal(marina.getFlagA()!=c_flag, "bad A flag: "+marina.getFlagA());
1677 prln("End testFlagC");
1680 private void sendDataWithPath(Marina marina) {
1681 prln("Begin sendDataWithPath");
1684 edu.berkeley.fleet.api.BitVector bv = new edu.berkeley.fleet.api.BitVector(13);
1685 marina.instrIn.fill(setIlc(1));
1687 // alternating ones and zeroes
1688 for(int i=0; i<bv.length(); i+=2)
1690 // and then ones in the lower four bits so it's not symmetric
1691 for(int i=0; i<4; i++)
1694 MarinaPath path = new MarinaPath((MarinaFleet)dock.getShip().getFleet(), bv);
1696 marina.fillSouthProperStopper(new Instruction[] {
1697 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter,1),
1698 new Instruction.Move(dock,
1699 Predicate.IgnoreFlagD, /* predicate */
1700 false, /* torpedoable */
1702 false, /* tokenIn */
1704 false, /* latchData */
1705 false, /* latchPath */
1707 false /* tokenOut */
1711 List<BitVector> dataItems;
1714 dataItems = marina.data.drainMany();
1715 fatal(dataItems.size()!=1, "Expected one data item to emerge but got: "+dataItems.size()+" data items");
1716 mp = new MarinaPacket(dataItems.get(0));
1718 // the 14th bit of the outbound address cannot be set by the
1719 // ship, so we don't care about it
1720 fatalIfBitVectorsDoNotMatch(MarinaUtils.berkToSun(bv), mp.path.get(0,13));
1722 prln("send data with no change to path");
1723 marina.instrIn.fill(new Instruction.Move(dock,
1724 Predicate.IgnoreFlagD, /* predicate */
1725 false, /* torpedoable */
1727 false, /* tokenIn */
1729 false, /* latchData */
1730 false, /* latchPath */
1732 false /* tokenOut */
1735 dataItems = marina.data.drainMany();
1736 fatal(dataItems.size()!=1, "Expected one data item to emerge but got: "+dataItems.size()+" data items");
1737 mp = new MarinaPacket(dataItems.get(0));
1739 // the 14th bit of the outbound address cannot be set by the
1740 // ship, so we don't care about it
1741 fatalIfBitVectorsDoNotMatch(MarinaUtils.berkToSun(bv), mp.path.get(0,13));
1744 prln("End sendDataWithPath");
1747 private void recvPath(Marina marina) {
1748 prln("Begin recvPath");
1751 marina.instrIn.fill(setIlc(1));
1752 for(int bit=0; bit<11; bit++) {
1753 BitVector packet_data = new BitVector(37, "inbound data item");
1754 for(int i=0; i<37; i++) packet_data.set(i, false);
1755 packet_data.set(27+bit, true);
1756 BitVector packet_path = new BitVector(14, "inbound data item");
1757 for(int i=0; i<14; i++) packet_path.set(i, false);
1759 marina.fillNorthProperStopper(new MarinaPacket(packet_data, false, packet_path));
1761 prln("recv path, send data (using recv'd path)");
1762 marina.instrIn.fill(new Instruction.Move(dock,
1763 Predicate.IgnoreFlagD, /* predicate */
1764 false, /* torpedoable */
1766 false, /* tokenIn */
1768 true, /* latchData */
1769 true, /* latchPath */
1771 false /* tokenOut */
1774 List<BitVector> dataItems = marina.data.drainMany();
1775 fatal(dataItems.size()!=1, "Expected one data item to emerge but got: "+dataItems.size()+" data items");
1776 MarinaPacket mp = new MarinaPacket(dataItems.get(0));
1778 fatalIfBitVectorsDoNotMatch(packet_data.get(25,11), mp.path.get(0,11));
1779 fatalIfBitVectorsDoNotMatch(packet_data, mp.data);
1783 prln("End recvPath");
1786 private void testILC(Marina marina) {
1787 prln("Begin testILC");
1790 for(int bit=0; bit<6; bit++) {
1791 int ilc = bit<0 ? 0 : (1<<bit);
1792 marina.fillSouthProperStopper(new Instruction[] {
1793 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter,ilc),
1796 List<BitVector> dataItems = marina.data.drainMany();
1797 fatal(dataItems.size()!=ilc, "Expected "+ilc+" data item(s) to emerge but got: "+dataItems.size()+" data items");
1801 prln("End testILC");
1804 private void testILCZero(Marina marina) {
1806 marina.fillSouthProperStopper(new Instruction[] {
1807 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter,0),
1811 expectNorthFifoNoMoreThan(0);
1812 expectTokensExactly(1);
1816 private void sendTorpedo(Marina marina) {
1817 prln("Begin sendTorpedo");
1819 marina.instrIn.fill(setIlc(1));
1820 marina.instrIn.fill(setOlc(63));
1822 model.waitNS(128 * CYCLE_TIME_NS);
1825 marina.instrIn.fill(new
1826 Instruction.Set(dock,Predicate.IgnoreFlagD, CLEAR_FLAG, CLEAR_FLAG));
1827 fatal(marina.getFlagA(), "bad A flag: true");
1828 fatal(marina.getFlagB(), "bad B flag: true");
1830 prln("execute a move instruction that does nothing but loops until torpedo arrives");
1831 prln("A=1, B=B This instruction should not execute because D-flag is set");
1832 prln("Set A=A, B=1 This instruction should execute because D-flag is set");
1834 model.waitNS(128 * CYCLE_TIME_NS);
1836 marina.fillSouthProperStopper(new Instruction[] {
1837 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, SetSource.Infinity),
1838 new Instruction.Move(dock,
1839 Predicate.IgnoreFlagD, // predicate
1840 true, // torpedoable
1849 new Instruction.Set(dock,Predicate.Default,
1851 Instruction.Set.FlagFunction.ZERO.add(Predicate.FlagB)
1853 new Instruction.Set(dock, Predicate.FlagD,
1854 Instruction.Set.FlagFunction.ZERO.add(Predicate.FlagA),
1859 model.waitNS(128 * CYCLE_TIME_NS);
1861 prln("send torpedo. This should clear the OLC");
1862 marina.instrIn.fillTorpedo();
1863 model.waitNS(128 * CYCLE_TIME_NS);
1865 model.waitNS(128 * CYCLE_TIME_NS);
1867 prln("A should remain false, B should be true");
1868 fatal(marina.getFlagA(), "bad A flag: true");
1869 fatal(!marina.getFlagB(), "bad B flag: false");
1871 model.waitNS(128 * CYCLE_TIME_NS);
1873 prln("Reload OLC after torpedo, clears D-flag");
1874 marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter, 63));
1876 // FIXME: find another way to test this
1877 model.waitNS(128 * CYCLE_TIME_NS);
1880 prln("Set A=1, B=1 This instruction should execute because OLC!=0");
1881 marina.instrIn.fill(new
1882 Instruction.Set(dock,Predicate.Default, SET_FLAG, SET_FLAG));
1884 prln("A and B should be true");
1885 fatal(!marina.getFlagA(), "bad A flag: false");
1886 fatal(!marina.getFlagB(), "bad B flag: false");
1889 prln("End sendTorpedo");
1892 private void testTorpedoOnAnInfinite(Marina marina) {
1893 prln("Begin testTorpedoOnAnInfinite");
1896 List<BitVector> dataItems;
1898 marina.instrIn.fill(setIlc(1));
1899 for(boolean torpedoable : new boolean[] { true, false }) {
1901 marina.fillSouthProperStopper(new Instruction[] {
1902 new Instruction.Move(dock,
1903 Predicate.IgnoreFlagD, // predicate
1904 false, // torpedoable
1913 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter,SetSource.Infinity),
1914 new Instruction.Move(dock,
1915 Predicate.IgnoreFlagD, // predicate
1916 torpedoable, // torpedoable
1925 // FIXME: this probably should be removed, unless Ivan doesn't want to change the behavior
1926 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter,1),
1931 // expect nothing to come out, because the NOP is executing
1932 dataItems = marina.data.drainMany(2);
1933 fatal(dataItems.size()!=0, "Expected no data item(s) to emerge but got at least: "+dataItems.size()+" data items");
1935 marina.instrIn.fillTorpedo();
1937 int expected = torpedoable?1:0;
1938 dataItems = marina.data.drainMany(2);
1939 fatal(dataItems.size()!=expected, "Expected "+expected+" item to emerge but got: "+dataItems.size()+" data items");
1941 fatal(!marina.getILC().getDone(), "Expected ilc=done, but got "+marina.getILC());
1945 prln("End testTorpedoOnAnInfinite");
1948 private void testDFlagWhenTorpedoLyingInWait(Marina marina) {
1949 marina.fillSouthProperStopper(new Instruction[] {
1951 TORPEDOABLE_RECV_DATA,
1952 marina.kesselsCounter ? null : FLAG_NOP,
1955 marina.instrIn.fillTorpedo();
1956 model.waitNS(64 * CYCLE_TIME_NS);
1957 marina.fillNorthProperStopper();
1958 model.waitNS(64 * CYCLE_TIME_NS);
1959 expectNorthFifoExactly(1);
1962 private void testSetOlcFollowedByDPredicated(Marina marina) {
1963 for(boolean d_set : new boolean[] { false, true }) {
1965 marina.fillSouthProperStopper(new Instruction[] {
1967 marina.kesselsCounter ? null : FLAG_NOP,
1968 d_set ? SEND_DATA_IF_D_SET : SEND_DATA_IF_D_NOT_SET,
1970 expectNorthFifoExactly(d_set ? 1 : 0);
1973 marina.fillSouthProperStopper(new Instruction[] {
1975 marina.kesselsCounter ? null : FLAG_NOP,
1976 d_set ? SEND_DATA_IF_D_SET : SEND_DATA_IF_D_NOT_SET,
1978 expectNorthFifoExactly(d_set ? 0 : 1);
1980 if (marina.kesselsCounter) {
1981 marina.masterClear();
1982 marina.enableInstructionSend(true);
1987 private void testOlcDecrementAtHighSpeed(Marina marina) {
1988 prln("Begin testOlcDecrementAtHighSpeed");
1991 List<BitVector> dataItems;
1993 // Each element of the following pair of arrays is one "test".
1994 // The OLC will be loaded with olcs[i] and then decremented
1995 // decr_amounts[i] times; after that has happened the zeroness
1996 // of the OLC will be checked by executing a MOVE with
1997 // [olc!=0] as the predicate.
1999 int[] olcs = new int[] { 3, 3, 3, 10, 41 };
2000 int[] decr_amounts = new int[] { 2, 3, 4, 9, 9 };
2002 for(int which=0; which<olcs.length; which++) {
2003 int olc = olcs[which];
2004 int decr_amount = decr_amounts[which];
2006 prln("inserting set olc="+olc);
2007 prln("inserting set ilc=1");
2008 marina.fillSouthProperStopper(new Instruction[] {
2009 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter,1),
2010 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter,olc),
2013 // commenting the following four lines causes this test to pass
2015 prln("inserting: "+decr_amount+" olc-- instructions");
2016 prln("inserting: [!d] send data");
2017 Instruction[] instructions = new Instruction[decr_amount+1];
2018 for(int i=0; i<decr_amount; i++)
2020 new Instruction.Set(dock,
2022 SetDest.OuterLoopCounter,
2023 SetSource.Decrement);
2024 instructions[instructions.length-1] =
2025 new Instruction.Move(dock,
2026 Predicate.Default, // predicate
2027 false, // torpedoable
2037 marina.fillSouthProperStopper(instructions);
2038 model.waitNS(64 * CYCLE_TIME_NS);
2040 int expected = decr_amount>=olc ? 0 : 1;
2041 dataItems = marina.data.drainMany(2);
2042 fatal(dataItems.size()!=expected, "Expected "+expected+" item to emerge but got: "+dataItems.size()+" data items");
2044 if (marina.kesselsCounter) {
2045 // master clear on each iteration; otherwise we'd need to "run down" the olc
2046 marina.masterClear();
2047 marina.enableInstructionSend(true);
2052 prln("End testOlcDecrementAtHighSpeed");
2055 private void flipIlcBit(Marina marina) {
2056 prln("Begin flipIlcBit");
2058 prln("Using the set ILC instruction, toggle a single bit between zero and one. \n" +
2059 "Check correct setting of the ILC zero bit");
2061 for (int i=0; i<6; i++) {
2064 prln("Then immediately set ILC="+notZero);
2065 marina.fillSouthProperStopper(new Instruction[] {
2066 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, 0),
2067 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, notZero),
2070 model.waitNS(64 * CYCLE_TIME_NS);
2072 prln("Verify ILC using scan chain");
2073 Ilc ilc = marina.getILC();
2074 int ilcCount = ilc.getCount();
2075 fatal(ilcCount!=notZero, "bad ILC count: "+ilcCount+" expected: "+notZero);
2076 fatal(ilc.getInfinity(), "bad ILC Infinity bit: true");
2078 marina.fillSouthProperStopper(new Instruction[] {
2079 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, notZero),
2080 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.InnerLoopCounter, 0),
2083 model.waitNS(64 * CYCLE_TIME_NS);
2085 prln("Verify ILC using scan chain");
2086 ilc = marina.getILC();
2087 ilcCount = ilc.getCount();
2088 fatal(ilcCount!=0, "bad ILC count: "+ilcCount+" expected: 0");
2089 fatal(ilc.getInfinity(), "bad ILC Infinity bit: true");
2093 prln("End flipIlcBit");
2095 private void flipOlcBit(Marina marina) {
2096 prln("Begin flipOlcBit");
2098 prln("Using the set OLC instruction, toggle a single bit between zero and one. \n" +
2099 "Check correct setting of the OLC zero bit");
2101 marina.instrIn.fill(new Instruction.Set(dock,Predicate.IgnoreFlagD, CLEAR_FLAG, CLEAR_FLAG));
2103 for (int i=0; i<6; i++) {
2104 int notZero = 32 >> i;
2106 if (marina.kesselsCounter) {
2107 // master clear on each iteration; otherwise we'd need to "run down" the olc
2108 marina.masterClear();
2109 marina.enableInstructionSend(true);
2114 prln("Then immediately set OLC="+notZero);
2115 marina.fillSouthProperStopper(new Instruction[] {
2116 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter, 0),
2117 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter, notZero),
2120 model.waitNS(64 * CYCLE_TIME_NS);
2121 prln("Verify OLC count using scan chain");
2124 if (!marina.kesselsCounter) {
2125 prln("Set OLC="+notZero);
2126 prln("Then immediately set OLC=0");
2127 marina.fillSouthProperStopper(new Instruction[] {
2128 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter, notZero),
2129 new Instruction.Set(dock,Predicate.IgnoreFlagD,SetDest.OuterLoopCounter, 0),
2132 model.waitNS(64 * CYCLE_TIME_NS);
2133 prln("Verify OLC count using scan chain");
2139 prln("End flipOlcBit");
2141 private void testSouthRecirculate(Marina marina, int AMOUNT) {
2142 prln("Begin testSouthRecirculate("+AMOUNT+")");
2145 marina.enableInstructionSend(false);
2146 marina.enableInstructionRecirculate(true);
2148 prln("Completely fill south ring");
2150 for (int i=0; i<AMOUNT; i++) {
2151 prln("inserting item " + (i+1) + " / " + AMOUNT);
2152 BitVector path = new BitVector(MarinaPacket.PATH_WIDTH, "path");
2153 BitVector data = new BitVector(MarinaPacket.WORD_WIDTH, "path");
2154 path.set(0, MarinaPacket.PATH_WIDTH, false);
2155 data.setFromLong(i+9);
2156 marina.instrIn.fill(new MarinaPacket(data, false, path));
2160 prln("Drain south ring and check contents");
2162 List<BitVector> out = marina.instrIn.drainMany();
2163 boolean bad = false;
2164 for (int i=0; i<AMOUNT; i++) {
2165 prln("extracting item " + (i+1) + " / " + AMOUNT);
2166 //int expect = (i+Marina.SOUTH_RING_CAPACITY-1) % Marina.SOUTH_RING_CAPACITY;
2168 long got = new MarinaPacket(out.get(i)).data.toLong();
2171 prln(" bad instruction: "+got+" expected: "+expect);
2173 prln(" good instruction.");
2176 fatal(bad, "data inserted does not match data retrieved");
2179 for (int i=0; i<5; i++) {}
2182 prln("End testSouthRecirculate("+AMOUNT+")");
2186 private void testOverfillTokens(Marina marina) {
2187 prln("Begin testOverfillTokens");
2190 for(int i=0; i<marina.TOKEN_FIFO_CAPACITY + 3; i++)
2191 marina.instrIn.fill(SEND_TOKEN);
2192 marina.instrIn.fill(SEND_DATA);
2193 expectNorthFifoExactly(0);
2196 prln("End testSouthRecirculate");
2201 private void doOneTest(int testNum) {
2203 prln("============================================================");
2204 prln("MarinaTest: performing test: "+testNum);
2207 marina.masterClear();
2208 marina.enableInstructionSend(true);
2215 // these tests run fairly quickly
2218 doOneTest(1); // passes extracted parasitics
2219 doOneTest(2); // passes extracted parasitics
2220 doOneTest(3); // passes extracted parasitics
2221 doOneTest(4); // passes extracted parasitics
2222 doOneTest(5); // passes extracted parasitics
2229 doOneTest(1000); // passes extracted parasitics
2230 doOneTest(1001); // passes extracted parasitics
2231 doOneTest(1003); // passes extracted parasitics
2232 doOneTest(3000); // passes extracted parasitics
2233 doOneTest(3001); // passes extracted parasitics
2234 doOneTest(3003); // passes extracted parasitics
2235 doOneTest(3004); // passes extracted parasitics
2236 doOneTest(3005); // passes extracted parasitics
2237 doOneTest(3006); // passes extracted parasitics
2238 doOneTest(3007); // passes extracted parasitics
2239 doOneTest(3008); // passes extracted parasitics
2240 doOneTest(3009); // passes extracted parasitics
2241 doOneTest(3010); // passes extracted parasitics
2242 doOneTest(3011); // passes extracted parasitics
2243 doOneTest(3012); // passes extracted parasitics
2244 doOneTest(3013); // passes extracted parasitics
2245 doOneTest(3014); // passes extracted parasitics
2246 doOneTest(3015); // passes extracted parasitics
2247 doOneTest(3019); // passes extracted parasitics
2248 doOneTest(3020); // passes extracted parasitics
2249 doOneTest(3022); // passes extracted parasitics
2250 doOneTest(3023); // passes extracted parasitics
2251 doOneTest(3026); // passes extracted parasitics
2252 doOneTest(3027); // passes extracted parasitics
2253 doOneTest(3028); // passes extracted parasitics
2255 // these tests take a while and usually pass
2266 // this takes an insanely long time
2270 case 1: testChains(marina); break; // passes, 24-Mar (+verilog)
2271 case 2: testProperStoppers(marina); break; // passes, 24-Mar (+verilog)
2272 case 3: testSouthRecirculate(marina, 1); break; // passes, 24-Mar (+verilog)
2273 case 4: getCtrsFlags(marina); break; // 20-Apr (+verilog)
2274 case 5: sendInstructions(marina); break; // passes, 24-Mar (+verilog)
2275 case 6: walkOneOLC(marina); break; // 21-Apr (+verilog)
2277 // Russell's tests begin with 1000
2278 case 1000: walkOneILC(marina); break; // 20-Apr (+verilog)
2279 case 1001: countIlc(marina); break; // 20-Apr (+verilog)
2280 case 1002: countOlc(marina); break; // 23-Apr (+verilog)
2282 case 1003: sendTorpedo(marina); break; // 23-Apr (+verilog) [with wor-hack]
2284 case 1004: flipIlcBit(marina); break; // 20-Apr (+verilog)
2285 case 1005: flipOlcBit(marina); break; // 21-Apr (+verilog)
2287 case 1006: testSouthRecirculate(marina, Marina.SOUTH_RING_CAPACITY-1); break; // passes, 24-Mar (+verilog)
2289 // Adam's tests begin with 3000
2290 case 3000: sendToken(marina); break; // passes, 24-Mar (+verilog)
2291 case 3001: testFlagAB(marina); break; // passes, 08-Apr (+verilog)
2292 case 3002: testPredicationOnAB(marina); break; // 22-Apr (+verilog)
2293 case 3003: testFlagC(marina); break; // 23-Apr (+verilog)
2294 case 3004: testFlagD(marina); break; // 23-Apr (+verilog)
2295 case 3005: testFlagDRecomputationTime(marina); break;
2297 case 3006: testTailWaitsForHead(marina); break;
2298 case 3007: testTailWithoutHead(marina); break;
2299 case 3008: testHeadWaitsForTail(marina); break; // 22-Apr (+verilog)
2300 case 3009: testAbort(marina); break; // 22-Apr (+verilog)
2302 case 3010: sendData(marina); break; // passes, 24-Mar (+verilog)
2303 case 3011: recvData(marina); break; // 21-Apr (+verilog)
2304 case 3012: sendDataWithPath(marina); break; // passes, 13-Apr (+verilog)
2306 case 3013: testSignExtendedLiteral(marina); break; // 20-Apr (+verilog)
2307 case 3014: testShiftedLiteral(marina); break; // 20-Apr (+verilog)
2308 case 3015: testSendAndRecvToken(marina); break; // 21-Apr (+verilog)
2310 case 3016: sendDataIlcInfinite(marina); break; // 22-Apr (+verilog)
2311 case 3017: testFlagTruthTable(marina); break; // 23-Apr (+verilog)
2313 case 3019: setOlcFromDataLatch(marina); break; // 23-Apr (+verilog)
2314 case 3020: setIlcFromDataLatch(marina); break; // 23-Apr (+verilog)
2315 case 3021: recvPath(marina); break; // 22-Apr (+verilog)
2316 case 3022: testILC(marina); break; // 23-Apr (+verilog)
2317 case 3023: testTorpedoOnAnInfinite(marina); break; // 23-Apr (+verilog)
2318 case 3024: testRecvAndSendWalkingOne(marina); break; // 21-Apr (+verilog)
2319 case 3025: testOlcDecrementAtHighSpeed(marina); break; // 23-Apr (+verilog)
2321 case 3026: testNonTorpedoableMoveDoesNotResetDFlag(marina); break; // 23-Apr (+verilog)
2322 case 3027: testILCZero(marina); break;
2323 case 3028: testAbortOutsideOfLoop(marina); break;
2326 fatal(true, "Test number: "+testNum+" doesn't exist.");
2329 // If we get here then test passed
2330 prln("Test Result: Passed");
2332 //Infrastructure.exit(0);
2333 } catch (MarinaUtils.FailureException fe) {
2334 System.out.println("******************************************************************************");
2335 System.out.println("******************************************************************************");
2336 System.out.println("******************************************************************************");
2337 System.out.println("******************************************************************************");
2338 fe.printStackTrace();
2343 //============================ for public use =============================
2346 * 0: test detected success
2347 * 2: test detected failure
2350 public static void main(String[] args) {
2351 startTime = System.currentTimeMillis();
2352 new MarinaTest(args);