X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=testCode%2Fcom%2Fsun%2Fvlsi%2Fchips%2Fmarina%2Ftest%2FProperStopper.java;h=484ac8ed01411fa00c9a211c11fcdc59b17db26e;hb=f13693939481283ab8ccab807792ba04cfa9bb04;hp=bc08c7e87ba258fca36e73bb8f5faba9533d7c0e;hpb=00a24804a149f806f1c9113bff11fd2f555e5c8a;p=fleet.git diff --git a/testCode/com/sun/vlsi/chips/marina/test/ProperStopper.java b/testCode/com/sun/vlsi/chips/marina/test/ProperStopper.java index bc08c7e..484ac8e 100644 --- a/testCode/com/sun/vlsi/chips/marina/test/ProperStopper.java +++ b/testCode/com/sun/vlsi/chips/marina/test/ProperStopper.java @@ -7,234 +7,241 @@ import com.sun.async.test.ChainControl; import com.sun.async.test.ChipModel; import com.sun.async.test.Infrastructure; import com.sun.async.test.NanosimModel; +import com.sun.async.test.VerilogModel; import com.sun.vlsi.chips.marina.test.MarinaUtils.StateWireState; public class ProperStopper { - // position of strobes in the control chain - private static final int BLOCK_STROBE_NDX = 0; - private static final int FILL_STROBE_NDX = 1; - private static final int GO_STROBE_NDX = 2; - private static final int SILENT_STROBE_NDX = 3; - private static final int CLEAR_STROBE_NDX = 4; - private static final int GENERAL_PURPOSE_STROBE_NDX = 5; - - // position of inputs in report chain - private static final int PREV_STATE_IN_NDX = 0; - private static final int FILL_STROBE_IN_NDX = 1; - private static final int FILL_STATE_IN_NDX = 2; - private static final int STOPPED_IN_NDX = 3; - - private final String name; - private final String captureClockRelPath = "fillStag@1.gaspFill@0.fillScan@1"; + // position of strobes in the control chain + private static final int BLOCK_STROBE_NDX = 0; + private static final int FILL_STROBE_NDX = 1; + private static final int GO_STROBE_NDX = 2; + private static final int SILENT_STROBE_NDX = 3; + private static final int CLEAR_STROBE_NDX = 4; + private static final int GENERAL_PURPOSE_STROBE_NDX = 5; + + // position of inputs in report chain + private static final int PREV_STATE_IN_NDX = 0; + private static final int FILL_STROBE_IN_NDX = 1; + private static final int FILL_STATE_IN_NDX = 2; + private static final int STOPPED_IN_NDX = 3; + + private final String name; + //private final String captureClockRelPath = "fillStag@1.gaspFill@0.fillScan@1"; + private final String captureClockRelPath = "fillStag@1"; // test library direct write mode doesn't understand per register write // enables. We get simulation to work by toggling write clock. private final boolean clockHack; - private final String captureClockName = "si[4]"; + private final String captureClockName = "sx[4]"; + /* private boolean traceFill = true; - private boolean traceDrain = true; - + private boolean traceDrain = true; + */ + private boolean traceFill = false; + private boolean traceDrain = false; + private final String controlChain, controlPath, - dataChain, dataPath, - reportChain, reportPath; + dataChain, dataPath, + reportChain, reportPath; private final String captureClock; private final ChainControls cc; private final ChipModel model; - private final Indenter indenter; - - protected static void fatal(boolean pred, String msg) { - if (pred) Infrastructure.fatal(msg); - } - private void prln(String msg) {indenter.prln(msg);} - private void adjustIndent(int n) {indenter.adjustIndent(n);} - - /** NanosimModel.setNodeState() requires special path names. - * Each instance name in the path must begin with the character 'x'. - * Return a path with the added X's. */ - private String prefixInstNamesInPathWithX(String path) { - StringBuffer sb = new StringBuffer(); - sb.append('x'); - for (int i=0; i data) { - prln("Begin fillMany. stopper="+name+" numWords="+data.size()); - adjustIndent(2); - int cnt = 0; - for (BitVector bv : data) { - if (traceFill) prln("fillStopperMany: writing word number: "+cnt++); - fill(bv); - } - adjustIndent(-2); - prln("end fillMany"); + prln("Begin fillMany. stopper="+name+" numWords="+data.size()); + adjustIndent(2); + int cnt = 0; + for (BitVector bv : data) { + if (traceFill) prln("fillStopperMany: writing word number: "+cnt++); + fill(bv); + } + adjustIndent(-2); + prln("end fillMany"); } + /** Remove one item from fill stage. Return that item. * An item must be available. * drain() will stop cleanly. * exit state: stop */ public BitVector drain() { - stop(); // all zero, block = 0, go = 0 - - // make sure an item is available - StateWireState myState=getFillStateWire(); - fatal(myState==StateWireState.EMPTY, "drain: fill stage empty"); + stop(); // all zero, block = 0, go = 0 + + // make sure an item is available + StateWireState myState=getFillStateWire(); + fatal(myState==StateWireState.EMPTY, "drain: fill stage empty"); - return drainNoCheck(); + return drainNoCheck(); } + /** Remove one item from fill stage. Return that item. * Assume that an item is available. * entry state: stop * exit state: stop */ private BitVector drainNoCheck() { - shiftData(true, false); - BitVector ans = getDatTokAdr(); + shiftData(true, false); - idle(); // block = 1 - clear(); // clear = 1 - idle(); // clear = 0 - stop(); // block = 0 + // strip the two write enable bits + BitVector ans = cc.getOutBits(dataPath).get(2, 52); - if (traceDrain) prln("drain stopper="+name+" data="+formatDataTokAddr(ans)); - return ans; + idle(); // block = 1 + clear(); // clear = 1 + idle(); // clear = 0 + stop(); // block = 0 + + if (traceDrain) prln("drain stopper="+name+" data="+new MarinaPacket(ans)); + return ans; } + /** Remove as many items as possible from the fill stage. * drainStopperMany() will stop cleanly. * exit state: stop */ public List drainMany() { - return drainMany(Integer.MAX_VALUE); + return drainMany(Integer.MAX_VALUE); } /** Remove up to maxNbItems items from the fill stage. * drainStopperMany() will stop cleanly. * exit state: stop */ public List drainMany(int maxNbItems) { - prln("begin drainMany. stopper="+name); - adjustIndent(2); - - stop(); - - List ans = new ArrayList(); - - int cnt = 0; - while (true) { - StateWireState myState=getFillStateWire(); - - // debugging - if (traceDrain) prln(getReportString()); - - if (myState==StateWireState.EMPTY || cnt>=maxNbItems) break; - - if (traceDrain) prln("drainMany: reading word number: "+cnt++); - - BitVector d = drainNoCheck(); - - ans.add(d); - } - - adjustIndent(-2); - prln("end drainMany, got "+ans.size()+" items"); - - return ans; + adjustIndent(2); + + stop(); + + List ans = new ArrayList(); + + int cnt = 0; + while (true) { + StateWireState myState=getFillStateWire(); + + // debugging + if (traceDrain) prln(getReportString()); + + if (myState==StateWireState.EMPTY || cnt>=maxNbItems) break; + + cnt++; + indenter.pr(" drain"+(maxNbItems==0?"":"Many")+ + ": reading word"+(maxNbItems==0?":":" number "+cnt+ + "/"+(maxNbItems==Integer.MAX_VALUE + ?"unlimited":("at-most-"+maxNbItems))+": ")); + + BitVector d = drainNoCheck(); + if (maxNbItems>1) + prln(" got "+new MarinaPacket(d)); + + ans.add(d); + } + + prln("end drainMany, got "+ans.size()+" items"); + adjustIndent(-2); + + return ans; } + /** + * (Note by Bill and Adam: Ivan has struck again!) + * As of 05 March 2009 the new bits are: + * Block Extra Fill Go Clear Silent + * => Note: "Extra" gets fed to the mux in the counter + * that selects the frequency output that goes off-chip + * + * Caution: Ivan changes the order of the ProperStopper control bits + * from chip to chip. Here is the current order for Marina + * as of 14 Aug 2008: + * Block, Fill, Go, Silent, Clear + * + * The old bit order for Infinity was: Fill, Block, Clear, Silent, Go + */ + private static enum CommandCodes { + RUN ("000100"), + IDLE ("100000"), + FILL ("101000"), + BLOCK ("100100"), + STOP ("000000"), + CLEAR ("100010"), + SOURCE ("001100"), + STOPSOURCE ("001000"), + SINK ("000101"), + STOPSINK ("000001"); + private BitVector scanBits; + CommandCodes(String bits) { + scanBits = new BitVector(bits,"CommandCodes"); + } + public BitVector bits() {return scanBits;} + } }