1 package edu.berkeley.fleet.interpreter;
2 import edu.berkeley.fleet.api.*;
3 import edu.berkeley.fleet.api.Dock;
4 import edu.berkeley.fleet.two.*;
8 /** anything that has a destination address on the switch fabric */
9 public abstract class InterpreterDock extends FleetTwoDock {
11 private final InterpreterShip ship;
12 private final Destination[] ports;
13 private final int addr = max_addr++;
15 public InterpreterDock(InterpreterShip ship, String[] ports, DockDescription bbd) {
18 this.ports = new Destination[ports.length];
19 for(int i=0; i<ports.length; i++)
21 new InterpreterDockDestination(ports[i], this, false);
24 public Path getPath(Destination d, BitVector signal) {
25 throw new RuntimeException();
28 public Iterable<Destination> getDestinations() {
29 HashSet<Destination> ret = new HashSet<Destination>();
30 for(Destination d : ports) ret.add(d);
34 public Destination getInstructionDestination() {
37 public Destination getDataDestination() {
42 /** adds the included datum to the port from the switch fabric side */
43 public abstract void addDataFromFabric(Packet packet);
45 abstract void service();
47 abstract void shutdown();
49 public Ship getShip() { return ship; }
50 public Fleet getFleet() { return getShip().getFleet(); }
51 public String toString() { return ship+"."+getName(); }
52 public int getInstructionFifoSize() { return 4; }
54 Interpreter getInterpreter() { return ((InterpreterShip)getShip()).getInterpreter(); }
56 public long getDestAddr() { return addr; }
58 private static int max_addr;
59 private class InterpreterDockDestination extends InterpreterDestination {
61 public long addr = max_addr++;
62 public InterpreterDockDestination(String name, InterpreterDock id, boolean isInstructionDestination) {
63 super(id, isInstructionDestination);
66 public String getDestinationName() { return name; }
67 public Ship getShip() { return InterpreterDock.this.getShip(); }
68 public void addDataFromFabric(Packet packet) { InterpreterDock.this.addDataFromFabric(packet); }
69 public String toString() { return getShip()+"."+getName(); }
70 public long getDestAddr() { return addr; }