1 package edu.berkeley.fleet.marina;
3 import java.util.ArrayList;
6 import com.sun.electric.tool.simulation.test.*;
8 import edu.berkeley.fleet.api.Dock;
9 import edu.berkeley.fleet.api.Instruction;
10 import edu.berkeley.fleet.marina.MarinaFleet;
12 import static edu.berkeley.fleet.marina.Marina.INSTRUCTION_LENGTH;
15 * InstructionStopper is a scaffold that lets us create a 36 bit propperStopper
16 * by using a 52 bit propperStopper and throwing away the unused bits.
18 public class InstructionStopper extends ProperStopper {
20 private static final int INSTRUCTION_SEND_NDX = 1;
21 private static final int INSTRUCTION_RECIRCULATE_NDX = 0;
22 private final String INSTR_RING_CONTROL_PATH;
24 public InstructionStopper(String propInst,
25 ChainControl controlChain,
26 ChainControl dataChain,
27 ChainControl reportChain,
30 Indenter indenter, String counterPath) {
31 super(propInst, controlChain, dataChain, reportChain, model, clockHack, indenter, counterPath);
32 INSTR_RING_CONTROL_PATH = propInst+".tapStage@2";
35 /** put one Instruction into InstructionStopper */
36 public void fill(Instruction inst) {
37 MarinaPacket mp = new MarinaPacket(inst);
38 MarinaTest.indenter.prln(" inserting instruction: " +
39 inst.toString().substring(inst.toString().indexOf(':')+1)
44 /* put a torpedo into the InstructionStopper */
45 public void fillTorpedo() {
46 MarinaTest.indenter.prln(" inserting torpedo");
47 super.fill(new MarinaPacket(MarinaPacket.null_word, true, MarinaPacket.null_path));
50 public void fill(Instruction[] instructions) { fill(instructions, false); }
51 public void fill(Instruction[] instructions, boolean repeat) { fill(instructions, repeat, false); }
52 public void fill(Instruction[] instructions, boolean repeat, boolean leaveStopped) {
53 enableInstructionSend(false);
54 enableInstructionRecirculate(true);
55 for(Instruction i : instructions)
61 enableInstructionRecirculate(repeat);
62 enableInstructionSend(true);
63 if (!leaveStopped) run();
65 public void enableInstructionSend(boolean b) {
66 BitVector bv = controlChain.getInBits(Marina.CONTROL_CHAIN+"."+INSTR_RING_CONTROL_PATH);
67 bv.set(INSTRUCTION_SEND_NDX, b);
68 controlChain.setInBits(Marina.CONTROL_CHAIN+"."+INSTR_RING_CONTROL_PATH, bv);
69 controlChain.shift(Marina.CONTROL_CHAIN, false, true);
71 public void enableInstructionRecirculate(boolean b) {
72 BitVector bv = controlChain.getInBits(Marina.CONTROL_CHAIN+"."+INSTR_RING_CONTROL_PATH);
73 bv.set(INSTRUCTION_RECIRCULATE_NDX, b);
74 controlChain.setInBits(Marina.CONTROL_CHAIN+"."+INSTR_RING_CONTROL_PATH, bv);
75 controlChain.shift(Marina.CONTROL_CHAIN, false, true);