more fixes to bring things up to date with the new test/doc apis
[fleet.git] / src / edu / berkeley / fleet / interpreter / InterpreterBenkoBox.java
1 package edu.berkeley.fleet.interpreter;
2 import edu.berkeley.fleet.api.*;
3 import edu.berkeley.fleet.api.BenkoBox;
4
5 /** anything that has a destination address on the switch fabric */
6 public abstract class InterpreterBenkoBox extends BenkoBox {
7         
8     private final String name;
9     private final InterpreterShip ship;
10         
11     public InterpreterBenkoBox(InterpreterShip ship, String name) {
12         this.ship = ship;
13         this.name = name;
14         ship.addBenkoBox(name, this);
15     }
16
17     private static int default_addr;
18     private static int default_instr_addr;
19
20     public int bits;
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;
27     void service() { }
28     public boolean special() { return special; }
29     public boolean ihorn() { return ihorn; }
30     public boolean dhorn() { return dhorn; }
31         
32     /** adds one token to the port from the switch fabric side */
33     void addTokenFromFabric() { addDataFromFabric(0); }
34         
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!"); }
37
38     /** adds one token to the port from the ship side */
39     public void addTokenFromShip() { addDataFromShip(0); }
40         
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!"); }
43
44     public Ship getShip() { return ship; }
45
46     public Fleet getFleet() { return getShip().getFleet(); }
47
48     public String toString() { return ship+"."+name; }
49
50     abstract void shutdown();
51
52     public String getName() { return name; }
53
54     public int getInstructionFifoLength() { return 4; }
55
56 }