package com.sun.vlsi.chips.marina.test;
/* -*- tab-width: 4 -*- */
-import com.sun.async.test.BitVector;
-import com.sun.async.test.ChainControl;
-import com.sun.async.test.ChipModel;
-import com.sun.async.test.JtagTester;
-import com.sun.async.test.NanosimModel;
-import com.sun.async.test.VerilogModel;
+import com.sun.electric.tool.simulation.test.*;
import edu.berkeley.fleet.api.Instruction;
import edu.berkeley.fleet.marina.MarinaPath;
public static int TOKEN_FIFO_CAPACITY = 3;
- public static boolean kesselsCounter = true;
- //public static boolean kesselsCounter = false;
+ //public static final boolean kesselsCounter = true;
+ public static final boolean kesselsCounter = false;
+ public static final boolean omegaCounter = false;
public static final String DATA_CHAIN = kesselsCounter ? "marina.marina_data" : "marina.ivan_data";
public static final String CONTROL_CHAIN = kesselsCounter ? "marina.marina_control" : "marina.ivan_control";
public static final String REPORT_CHAIN = kesselsCounter ? "marina.marina_report" : "marina.ivan_report";
+ public static final String DUKE_CHAIN = "marina.duke";
public static String prefix = "marinaGu@0.outDockW@"+(kesselsCounter?"3":"0")+".marinaOu@"+(kesselsCounter?"1":"0")+".";
public static String MASTER_CLEAR = "mc";
prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.olcWcont@0.scanEx3h@1"; // bits 2,4,6
private static final String OLC_PATH_ODD =
prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.olcWcont@0.scanEx3h@2"; // bits 1,3,5
- private static final String OLC_PATH_KESSEL =
+ public static final String OLC_PATH_KESSEL =
prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.counte@0.adamScan@1.scanEx6h@";
private static final String ILC_PATH_ODD =
prefix+"outputDo@0.outM1Pre@0.outDockP@0.outDockC@0.ilcMoveO@0.scanEx4h@0"; // bits 1,3,5,7
// The name of the scan chain
// The instance path, from the top cell of the netlist, of the instance of infinityWithCover
- private final ChainControls cc; // specifies the scan chain
+ public final ChainControls cc; // specifies the scan chain
private final ChipModel model;
public final ProperStopper data;
public final InstructionStopper instrIn;
private void pr(String msg) {indenter.pr(msg);}
/** Shift the report scan chain */
- private void shiftReport(boolean readEnable, boolean writeEnable) {
+ public void shiftReport(boolean readEnable, boolean writeEnable) {
cc.shift(REPORT_CHAIN, readEnable, writeEnable);
}
cc.shift(DATA_CHAIN, readEnable, writeEnable);
}
+ /** Shift the data scan chain */
+ public void shiftDuke(boolean readEnable, boolean writeEnable) {
+ cc.shift(DUKE_CHAIN, readEnable, writeEnable);
+ }
+
public Marina(ChainControls cc, ChipModel model, boolean clockHack, Indenter indenter) {
this.cc = cc;
this.model = model;
this.indenter = indenter;
data = new ProperStopper("north fifo",
prefix+"northFif@1.fillDrai@1.properSt@1",
- CONTROL_CHAIN,
- DATA_CHAIN,
- REPORT_CHAIN,
- cc, model, clockHack, indenter);
+ cc, model, clockHack, indenter,
+ prefix+"northFif@1.fillDrai@1.instruct@0.cntScnTh@1.cntScnOn@1");
instrIn = new InstructionStopper("south fifo",
prefix+"southFif@1.tapPropS@1.properSt@1",
- CONTROL_CHAIN,
- DATA_CHAIN,
- REPORT_CHAIN,
- cc, model, clockHack, indenter);
+ cc, model, clockHack, indenter,
+ prefix+"southFif@1.tapPropS@1.instruct@0.cntScnTh@1.cntScnOn@1");
+ }
+
+ int northCount = 0;
+ int southCount = 0;
+
+ public void stopAndResetCounters() {
+ instrIn.setCounterEnable(false);
+ data.setCounterEnable(false);
+ cc.shift(DATA_CHAIN, true, false);
+ northCount = data.getCounterValue();
+ southCount = instrIn.getCounterValue();
+ data.setCounterValue(0);
+ instrIn.setCounterValue(0);
+ }
+ public void startCounters() { startCounters(true, true); }
+ public void startCounters(boolean south, boolean north) {
+ instrIn.setCounterEnable(south);
+ data.setCounterEnable(north);
}
+ public int getNorthCount() { return northCount; }
+ public int getSouthCount() { return southCount; }
+
+
public void masterClear() {
final double WIDTH = 10; // ns
// Put a high going pulse on the internal chip master clear signal
nModel.setNodeVoltage(MASTER_CLEAR,0.0);
nModel.waitNS(1);
} else {
- prln("FIXME!");
+
+ mc0.setLogicState(true);
+ mc1.setLogicState(true);
+ model.waitNS(1000);
+ mc0.setLogicState(false);
+ mc1.setLogicState(false);
+ model.waitNS(1000);
+
}
resetAfterMasterClear();
}
+
+ JtagLogicLevel mc0;
+ JtagLogicLevel mc1;
+
private void resetAfterMasterClear() {
// The following call to ChainControl.resetInBits() is vital!
// If you forget, then the inBits member initializes
/** Get the 6 bit outer loop counter. */
public int getOLC() {
shiftReport(true, false);
- if (kesselsCounter) {
+ if (omegaCounter) {
+ BitVector bits = null;
+ for(int i=0; i<4; i++) {
+ BitVector x = cc.getOutBits(REPORT_CHAIN+"."+OLC_PATH_KESSEL+i);
+ //System.out.println("bits are: " + x);
+ bits = bits==null ? x : bits.cat(x);
+ }
+ System.out.print(" kesselsCounter = ");
+ int ret = 0;
+ boolean done = true;
+ boolean bad = false;
+ for(int bit=5; bit>=0; bit--) {
+ boolean zeroOrTwo = bits.get(4+bit*3);
+ boolean zeroOrDone = bits.get(4+bit*3+1);
+ if ( zeroOrTwo && !zeroOrDone) {
+ ret += (2<<bit);
+ System.out.print("2");
+ done = false;
+ } else if (!zeroOrTwo && !zeroOrDone) {
+ ret += (1<<bit);
+ System.out.print("1");
+ done = false;
+ } else if ( zeroOrTwo && zeroOrDone) {
+ System.out.print("0");
+ bad = true;
+ done = false;
+ } else if (!zeroOrTwo && zeroOrDone) {
+ System.out.print("_");
+ if (!done) bad = true;
+ }
+ // FIXME: check for unreduced counter and warn about it
+ }
+ if (bad) System.out.print(" WARNING: UNREDUCED COUNTER VALUE!!!!!!");
+ System.out.println();
+ return ret;
+ } else if (kesselsCounter) {
BitVector bits = null;
for(int i=0; i<4; i++) {
BitVector x = cc.getOutBits(REPORT_CHAIN+"."+OLC_PATH_KESSEL+i);
//System.out.println("kesselsCounter = " + bits);
int first = 0;
int second = 0;
- for(int i=0; i<6; i++) first |= bits.get(4+i*3) ? (1<<i) : 0;
- for(int i=0; i<6; i++) second |= bits.get(4+i*3+2) ? (1<<i) : 0;
+ String hi="";
+ String lo="";
+ String latched="";
+ String res="";
+ for(int i=0; i<6; i++) {
+ first |= bits.get(4+i*3) ? (1<<i) : 0;
+ second |= bits.get(4+i*3+2) ? (1<<i) : 0;
+ hi = (bits.get(4+i*3) ? "1" : "0") + hi;
+ lo = (bits.get(4+i*3+2) ? "1" : "0") + lo;
+ res =
+ ( bits.get(4+i*3) && !bits.get(4+i*3+2) ? "X"
+ : !bits.get(4+i*3) && !bits.get(4+i*3+2) ? "0"
+ : !bits.get(4+i*3) && bits.get(4+i*3+2) ? "1"
+ : "2")
+ +res;
+ latched = (bits.get(4+i*3+1) ? "0" : "1") + latched;
+ }
+ System.out.println("kesselsCounter: "+
+ "s[1]="+hi+
+ " s[3]="+lo+
+ " latched="+latched +
+ " res="+res+
+ " do[ins]="+(bits.get(0) ? "1" : "0")+
+ " dec="+(bits.get(1) ? "1" : "0")+
+ " flag[D][set]="+(bits.get(2) ? "1" : "0")+
+ " resetting="+(bits.get(3) ? "1" : "0")+
+ ""
+ );
return (first+second);
} else {
BitVector odd = cc.getOutBits(REPORT_CHAIN+"."+OLC_PATH_ODD).bitReverse();
instrIn.setGeneralPurposeOutput(b);
}
+ public void fillSouthProperStopper(Instruction i) {
+ instrIn.fill(i);
+ }
public void fillSouthProperStopper(Instruction[] instructions) { fillSouthProperStopper(instructions, false); }
- public void fillSouthProperStopper(Instruction[] instructions, boolean repeat) {
+ public void fillSouthProperStopper(Instruction[] instructions, boolean repeat) { fillSouthProperStopper(instructions, repeat, false); }
+ public void fillSouthProperStopper(Instruction[] instructions, boolean repeat, boolean leaveStopped) {
enableInstructionSend(false);
enableInstructionRecirculate(true);
for(Instruction i : instructions)
- if (i!=null)
+ if (i!=null) {
instrIn.fill(i);
+ } else {
+ instrIn.fillTorpedo();
+ }
enableInstructionRecirculate(repeat);
enableInstructionSend(true);
- instrIn.run();
+ if (!leaveStopped) instrIn.run();
}