1 package edu.berkeley.fleet.marina;
3 import com.sun.electric.tool.simulation.test.*;
4 import edu.berkeley.fleet.api.Dock;
5 import edu.berkeley.fleet.api.Instruction;
6 import static edu.berkeley.fleet.marina.Marina.INSTRUCTION_LENGTH;
9 * InstructionStopper is a scaffold that lets us create a 36 bit propperStopper
10 * by using a 52 bit propperStopper and throwing away the unused bits.
12 public class InstructionStopper extends ProperStopper {
14 private static final int INSTRUCTION_SEND_NDX = 1;
15 private static final int INSTRUCTION_RECIRCULATE_NDX = 0;
16 private final String INSTR_RING_CONTROL_PATH;
18 public InstructionStopper(String propInst,
19 ChainControl controlChain,
20 ChainControl dataChain,
21 ChainControl reportChain,
25 super(propInst, controlChain, dataChain, reportChain, model, clockHack, indenter,
26 propInst+".instruct@0.cntScnTh@1.cntScnOn@1");
27 INSTR_RING_CONTROL_PATH = propInst+".tapStage@2";
30 /** put one Instruction into InstructionStopper */
31 public void fill(Instruction inst) {
32 MarinaPacket mp = new MarinaPacket(inst);
33 MarinaTest.indenter.prln(" inserting instruction: " +
34 inst.toString().substring(inst.toString().indexOf(':')+1)
39 /* put a torpedo into the InstructionStopper */
40 public void fillTorpedo() {
41 MarinaTest.indenter.prln(" inserting torpedo");
42 super.fill(new MarinaPacket(MarinaPacket.null_word, true, MarinaPacket.null_path));
45 public void fill(Instruction[] instructions) { fill(instructions, false); }
46 public void fill(Instruction[] instructions, boolean repeat) { fill(instructions, repeat, false); }
47 public void fill(Instruction[] instructions, boolean repeat, boolean leaveStopped) {
48 enableInstructionSend(false);
49 enableInstructionRecirculate(true);
50 for(Instruction i : instructions)
56 enableInstructionRecirculate(repeat);
57 enableInstructionSend(true);
58 if (!leaveStopped) run();
60 public void enableInstructionSend(boolean b) {
61 BitVector bv = controlChain.getInBits(Marina.CONTROL_CHAIN+"."+INSTR_RING_CONTROL_PATH);
62 bv.set(INSTRUCTION_SEND_NDX, b);
63 controlChain.setInBits(Marina.CONTROL_CHAIN+"."+INSTR_RING_CONTROL_PATH, bv);
64 controlChain.shift(Marina.CONTROL_CHAIN, false, true);
66 public void enableInstructionRecirculate(boolean b) {
67 BitVector bv = controlChain.getInBits(Marina.CONTROL_CHAIN+"."+INSTR_RING_CONTROL_PATH);
68 bv.set(INSTRUCTION_RECIRCULATE_NDX, b);
69 controlChain.setInBits(Marina.CONTROL_CHAIN+"."+INSTR_RING_CONTROL_PATH, bv);
70 controlChain.shift(Marina.CONTROL_CHAIN, false, true);