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,
24 Indenter indenter, String counterPath) {
25 super(propInst, controlChain, dataChain, reportChain, model, clockHack, indenter, counterPath);
26 INSTR_RING_CONTROL_PATH = propInst+".tapStage@2";
29 /** put one Instruction into InstructionStopper */
30 public void fill(Instruction inst) {
31 MarinaPacket mp = new MarinaPacket(inst);
32 MarinaTest.indenter.prln(" inserting instruction: " +
33 inst.toString().substring(inst.toString().indexOf(':')+1)
38 /* put a torpedo into the InstructionStopper */
39 public void fillTorpedo() {
40 MarinaTest.indenter.prln(" inserting torpedo");
41 super.fill(new MarinaPacket(MarinaPacket.null_word, true, MarinaPacket.null_path));
44 public void fill(Instruction[] instructions) { fill(instructions, false); }
45 public void fill(Instruction[] instructions, boolean repeat) { fill(instructions, repeat, false); }
46 public void fill(Instruction[] instructions, boolean repeat, boolean leaveStopped) {
47 enableInstructionSend(false);
48 enableInstructionRecirculate(true);
49 for(Instruction i : instructions)
55 enableInstructionRecirculate(repeat);
56 enableInstructionSend(true);
57 if (!leaveStopped) run();
59 public void enableInstructionSend(boolean b) {
60 BitVector bv = controlChain.getInBits(Marina.CONTROL_CHAIN+"."+INSTR_RING_CONTROL_PATH);
61 bv.set(INSTRUCTION_SEND_NDX, b);
62 controlChain.setInBits(Marina.CONTROL_CHAIN+"."+INSTR_RING_CONTROL_PATH, bv);
63 controlChain.shift(Marina.CONTROL_CHAIN, false, true);
65 public void enableInstructionRecirculate(boolean b) {
66 BitVector bv = controlChain.getInBits(Marina.CONTROL_CHAIN+"."+INSTR_RING_CONTROL_PATH);
67 bv.set(INSTRUCTION_RECIRCULATE_NDX, b);
68 controlChain.setInBits(Marina.CONTROL_CHAIN+"."+INSTR_RING_CONTROL_PATH, bv);
69 controlChain.shift(Marina.CONTROL_CHAIN, false, true);