import edu.berkeley.fleet.assembler.*;
import edu.berkeley.fleet.util.*;
-public class Interpreter extends FleetTwoFleet implements Parser.FleetWithDynamicShips {
+public class Interpreter extends FleetTwoFleet {
/** used to allocate serial numbers; see InterpreterDestination for further detail */
int maxAllocatedDestinationSerialNumber = 0;
private InterpreterShip debugShip = null;
private BlockingQueue<BitVector> debugStream = new LinkedBlockingQueue<BitVector>();
- private HashMap<String,InterpreterShip> ships = new HashMap<String,InterpreterShip>();
+ private LinkedHashMap<String,InterpreterShip> ships = new LinkedHashMap<String,InterpreterShip>();
public Iterator<Ship> iterator() { return (Iterator<Ship>)(Object)ships.values().iterator(); }
public Ship getShip(String type, int ordinal) {
for(Ship s : this)
}
/** do not use this; it is going to go away */
- public Interpreter() {
+ public Interpreter() { this(true); }
+ public Interpreter(boolean logging) {
+ this(new String[] {
+ "Debug",
+ "Memory",
+ "Memory",
+ "Memory",
+ "Alu",
+ "Alu",
+ "Alu",
+ "Alu",
+ "Alu",
+ "Alu",
+ "Alu",
+ "Fifo",
+ "Fifo",
+ "Counter",
+ "Counter",
+ "Counter",
+ "Counter",
+ "Counter",
+ "Counter",
+ "Counter",
+ "Counter",
+ "Counter",
+ "Counter",
+ "Counter",
+ "Counter",
+ "Counter",
+ "Counter",
+ "Lut3",
+ "CarrySaveAdder",
+ "Rotator",
+ }, logging);
}
public Interpreter(String[] ships, boolean logging) {
new Packet((InterpreterPath)path, new BitVector(getWordWidth()).set(il), false).send();
}
- /** do not use this; it is going to go away */
- public Ship createShip(String shipType, String shipname) {
+ private Ship createShip(String shipType, String shipname) {
try {
if (ships.get(shipname)!=null) return ships.get(shipname);
Class c = Class.forName("edu.berkeley.fleet.interpreter."+shipType);
private Instruction[] instructions;
public void flush() { }
public void sendWord(Destination d, BitVector word) {
- throw new RuntimeException("not implemented");
+ InterpreterPath path = (InterpreterPath)debugShip.getDock("in").getPath(d, new BitVector(1));
+ ((InterpreterDestination)d).
+ addDataFromFabric(new Packet(path, word, false));
+ }
+ public void sendToken(Destination d) {
+ InterpreterPath path = (InterpreterPath)debugShip.getDock("in").getPath(d, new BitVector(1));
+ ((InterpreterDestination)d).
+ addDataFromFabric(new Packet(path, new BitVector(getWordWidth()), true));
}
- public void sendToken(Destination d) { throw new RuntimeException("not implemented"); }
public InterpreterProcess(Instruction[] instructions) {
this.instructions = instructions;
for(Instruction i : instructions)