added fleet api classes
[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     int bits;
18     int addr;
19     int instr_bits;
20     int instr_addr;
21     protected boolean special = false;
22     protected boolean noInbox = false;
23     protected boolean noChannelDef = false;
24     void service() { }
25     public boolean special() { return special; }
26     public boolean noInbox() { return noInbox; }
27     public boolean noChannelDef() { return noChannelDef; }
28         
29     /** adds one token to the port from the switch fabric side */
30     void addTokenFromFabric() { addDataFromFabric(0); }
31         
32     /** adds the included datum to the port from the switch fabric  side */
33     void addDataFromFabric(int datum)  { throw new RuntimeException("this should never happen!"); }
34
35     /** adds one token to the port from the ship side */
36     public void addTokenFromShip() { addDataFromShip(0); }
37         
38     /** adds the included datum to the port from the switch fabric side */
39     public void addDataFromShip(int datum) { throw new RuntimeException("this should never happen!"); }
40
41     public Ship getShip() { return ship; }
42
43     public Fleet getFleet() { return getShip().getFleet(); }
44
45     public String toString() { return ship+"."+name; }
46
47     abstract void shutdown();
48
49     public String getName() { return name; }
50
51     public int getInstructionFifoLength() { return 4; }
52
53 }