5a6bad3e3664fc8cb23f76393fc936c458b57536
[fleet.git] / src / edu / berkeley / fleet / Port.java
1 package edu.berkeley.fleet;
2
3 /** anything that has a destination address on the switch fabric */
4 public abstract class Port {
5         
6     private final String name;
7     private final Ship ship;
8         
9     public Port(Ship ship, String name) {
10         this.ship = ship;
11         this.name = name;
12         ship.addPort(name, this);
13     }
14
15     protected boolean special = false;
16     protected boolean noInbox = false;
17     protected boolean noChannelDef = false;
18     void service() { }
19     public boolean special() { return special; }
20     public boolean noInbox() { return noInbox; }
21     public boolean noChannelDef() { return noChannelDef; }
22         
23     /** adds one token to the port from the switch fabric side */
24     void addTokenFromFabric() { /*throw new RuntimeException("this should never happen!");*/ addDataFromFabric(0); }
25         
26     /** adds the included datum to the port from the switch fabric  side */
27     void addDataFromFabric(int datum)  { throw new RuntimeException("this should never happen!"); }
28
29     /** adds one token to the port from the ship side */
30     public void addTokenFromShip() { /*throw new RuntimeException("this should never happen!");*/ addDataFromShip(0); }
31         
32     /** adds the included datum to the port from the switch fabric side */
33     public void addDataFromShip(int datum) { throw new RuntimeException("this should never happen!"); }
34
35     public Ship getShip() { return ship; }
36
37     public Fleet getFleet() { return getShip().getFleet(); }
38
39     public String toString() { return ship+"."+name; }
40
41     abstract void shutdown();
42
43     public String getName() { return name; }
44
45     int bits;
46     int addr;
47     int instr_bits;
48     int instr_addr;
49 }