putMemoryShipInDispatchMode() now puts both out and inCBD in infinite-recieve mode
[fleet.git] / src / edu / berkeley / fleet / loops / MemoryUtils.java
index bfbd26a..f8c5163 100644 (file)
@@ -114,6 +114,28 @@ public class MemoryUtils {
         return bv;
     }
 
+    public static void putMemoryShipInDispatchMode(FleetProcess fp, Ship memoryShip) {
+        Context ctx = new Context(fp.getFleet());
+        LoopFactory lf;
+
+        lf = new LoopFactory(ctx, memoryShip.getDock("out"), 0);
+        lf.abortLoopIfTorpedoPresent();
+        lf.collectPacket();
+        lf.sendWord(null);
+
+        lf = new LoopFactory(ctx, memoryShip.getDock("inCBD"), 0);
+        lf.abortLoopIfTorpedoPresent();
+        lf.recvWord();
+        lf.deliver();
+
+        ctx.dispatch(fp);
+    }
+
+    public static void removeMemoryShipFromDispatchMode(FleetProcess fp, Ship memoryShip) {
+        fp.sendToken(memoryShip.getDock("out").getInstructionDestination());
+        fp.sendToken(memoryShip.getDock("inCBD").getInstructionDestination());
+    }
+
     public static void main(String[] s) throws Exception {
         Random random = new Random(System.currentTimeMillis());
         Fleet fleet = new Fpga();