1 package edu.berkeley.fleet.interpreter;
2 import edu.berkeley.fleet.doc.*;
3 import edu.berkeley.fleet.api.*;
4 import edu.berkeley.fleet.api.Pump;
7 /** anything that has a destination address on the switch fabric */
8 public abstract class InterpreterPump extends Pump {
10 private final String name;
11 private final InterpreterShip ship;
12 private final Destination[] ports;
13 private final int addr = max_addr++;
14 private PumpDescription bbd;
16 public void setDescription(PumpDescription bbd) {
19 public long resolveLiteral(String literal) {
20 return bbd.resolveLiteral(literal);
23 public InterpreterPump(InterpreterShip ship, String name, String[] ports) {
26 this.ports = new Destination[ports.length];
27 for(int i=0; i<ports.length; i++)
29 new InterpreterPumpDestination(ports[i]);
32 public Iterable<Destination> getDestinations() {
33 HashSet<Destination> ret = new HashSet<Destination>();
34 for(Destination d : ports) ret.add(d);
38 /** adds the included datum to the port from the switch fabric side */
39 public abstract void addDataFromFabric(Packet packet);
41 abstract void service();
43 abstract void shutdown();
45 public Ship getShip() { return ship; }
46 public Fleet getFleet() { return getShip().getFleet(); }
47 public String toString() { return ship+"."+name; }
48 public String getName() { return name; }
49 public int getInstructionFifoLength() { return 4; }
51 Interpreter getInterpreter() { return ((InterpreterShip)getShip()).getInterpreter(); }
53 public long getDestAddr() { return addr; }
55 private static int max_addr;
57 private class InterpreterPumpDestination extends InterpreterDestination {
59 public long addr = max_addr++;
60 public InterpreterPumpDestination(String name) { this.name = name; }
61 public String getDestinationName() { return name; }
62 public Ship getShip() { return InterpreterPump.this.getShip(); }
63 public void addDataFromFabric(Packet packet) { InterpreterPump.this.addDataFromFabric(packet); }
64 public String toString() { return getShip()+"."+getName(); }
65 public long getDestAddr() { return addr; }