Interpreter: use Packet.send() more often
[fleet.git] / src / edu / berkeley / fleet / interpreter / Interpreter.java
index e58eb3d..5f10626 100644 (file)
@@ -60,6 +60,7 @@ public class Interpreter extends FleetTwoFleet {
                 "Lut3",
                 "CarrySaveAdder",
                 "Rotator",
+                "Timer",
             }, logging);
     }
 
@@ -161,7 +162,9 @@ public class Interpreter extends FleetTwoFleet {
 
     public FleetProcess run(final Instruction[] instructions) {
         InterpreterProcess ip = initialize(instructions);
-        new Thread(ip).start();
+        Thread ipt = new Thread(ip);
+        ipt.setDaemon(true);
+        ipt.start();
         return ip;
     }
 
@@ -171,15 +174,14 @@ public class Interpreter extends FleetTwoFleet {
 
     public class InterpreterProcess extends FleetProcess implements Runnable {
         private Instruction[] instructions;
-        public synchronized void sendWord(Destination d, BitVector word) {
-            InterpreterPath path = (InterpreterPath)debugShip.getDock("in").getPath(d, new BitVector(1));
-            ((InterpreterDestination)d).
-                addDataFromFabric(new Packet(path, word, false));
+        public synchronized void sendWord(Destination d, BitVector word) { sendWord(d, word, null); }
+        public synchronized void sendWord(Destination d, BitVector word, BitVector signal) {
+            InterpreterPath path = (InterpreterPath)debugShip.getDock("in").getPath(d, signal==null?new BitVector(1):signal);
+            new Packet(path, word, false).send();
         }
         public synchronized 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));
+            new Packet(path, new BitVector(getWordWidth()), true).send();
         }
         public InterpreterProcess(Instruction[] instructions) {
             this.instructions = instructions;
@@ -188,7 +190,6 @@ public class Interpreter extends FleetTwoFleet {
         }
         public Fleet getFleet() { return Interpreter.this; }
         public synchronized void sendInstruction(Instruction i) {
-            Log.dispatch(i);
             long il = writeInstruction(i, debugShip.getDock("in"));
             Path path = debugShip.getDock("in").getPath(i.dock.getInstructionDestination(), null);
             new Packet((InterpreterPath)path, new BitVector(getWordWidth()).set(il), false).send();