1 package edu.berkeley.fleet.interpreter;
2 import edu.berkeley.fleet.api.*;
3 import edu.berkeley.fleet.api.BenkoBox;
5 /** anything that has a destination address on the switch fabric */
6 public abstract class InterpreterBenkoBox extends BenkoBox {
8 private final String name;
9 private final InterpreterShip ship;
11 public InterpreterBenkoBox(InterpreterShip ship, String name) {
14 ship.addBenkoBox(name, this);
17 private static int default_addr;
18 private static int default_instr_addr;
21 public int addr = (default_addr++);
22 public int instr_bits;
23 public int instr_addr = (default_instr_addr++);
24 protected boolean special = false;
25 protected boolean ihorn = false;
26 protected boolean dhorn = false;
28 public boolean special() { return special; }
29 public boolean ihorn() { return ihorn; }
30 public boolean dhorn() { return dhorn; }
32 /** adds one token to the port from the switch fabric side */
33 void addTokenFromFabric() { addDataFromFabric(0); }
35 /** adds the included datum to the port from the switch fabric side */
36 void addDataFromFabric(int datum) { throw new RuntimeException("this should never happen!"); }
38 /** adds one token to the port from the ship side */
39 public void addTokenFromShip() { addDataFromShip(0); }
41 /** adds the included datum to the port from the switch fabric side */
42 public void addDataFromShip(int datum) { throw new RuntimeException("this should never happen!"); }
44 public Ship getShip() { return ship; }
46 public Fleet getFleet() { return getShip().getFleet(); }
48 public String toString() { return ship+"."+name; }
50 abstract void shutdown();
52 public String getName() { return name; }
54 public int getInstructionFifoLength() { return 4; }