add FleetProcess.sendWord() that takes a signal
authorAdam Megacz <adam@megacz.com>
Fri, 31 Jul 2009 23:38:51 +0000 (16:38 -0700)
committerAdam Megacz <adam@megacz.com>
Fri, 31 Jul 2009 23:38:51 +0000 (16:38 -0700)
src/edu/berkeley/fleet/api/FleetProcess.java
src/edu/berkeley/fleet/fpga/Client.java
src/edu/berkeley/fleet/interpreter/Interpreter.java

index 1db837f..c232405 100644 (file)
@@ -23,9 +23,21 @@ public abstract class FleetProcess {
     /** dispatch a word to a given destination; may be buffered */
     public abstract void sendWord(Destination d, BitVector word);
 
+    /** dispatch a word to a given destination; may be buffered */
+    public abstract void sendWord(Destination d, BitVector word, BitVector signal);
+
+    /** convenience method: sends the word to d's data destination */
+    public void sendWord(Dock d, BitVector word) { sendWord(d.getDataDestination(), word); }
+
     /** dispatch a token to a given destination; may be buffered */
     public abstract void sendToken(Destination d);
 
+    /** convenience method: sends a token to d's data destination */
+    public void sendToken(Dock d) { sendToken(d.getDataDestination()); }
+
+    /** convenience method: sends a token to d's instruction destination */
+    public void sendTorpedo(Dock d) { sendToken(d.getInstructionDestination()); }
+
     /** flush all instructions, words, and tokens dispatched so far */
     public abstract void flush();
 
index 235e183..4c223fd 100644 (file)
@@ -106,15 +106,19 @@ public class Client extends FleetProcess {
         flush();
     }
 
-    public void sendToken(Destination d) { sendWord(d, new BitVector(fpga.getWordWidth()), true); }
-    public void sendWord(Destination d, BitVector word) { sendWord(d, word, false); }
-    private void sendWord(Destination d, BitVector word, boolean token) {
+    public void sendToken(Destination d) { sendWord(d, new BitVector(fpga.getWordWidth()), null, true); }
+    public void sendWord(Destination d, BitVector word) { sendWord(d, word, null, false); }
+    public void sendWord(Destination d, BitVector word, BitVector signal) { sendWord(d, word, signal, false); }
+    private void sendWord(Destination d, BitVector word, BitVector signal, boolean token) {
         try {
             Dock dispatchFrom = fpga.debugShip.getDock("in");
             long out = 0;
             out = fpga.PACKET_DATA.setval(out, word);
             out = fpga.PACKET_TOKEN.setval(out, token ? 1 : 0);
-            out = fpga.PACKET_SIGNAL.setval(out, 0);
+            if (signal==null)
+                out = fpga.PACKET_SIGNAL.setval(out, 0);
+            else 
+                out = fpga.PACKET_SIGNAL.setval(out, signal);
             out = fpga.PACKET_DEST.setval(out, ((FpgaPath)dispatchFrom.getPath(d, null)).toLong());
             synchronized(this) {
                 for(int i=9; i>=0; i--)
index e58eb3d..87b203e 100644 (file)
@@ -171,8 +171,9 @@ 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));
+        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);
             ((InterpreterDestination)d).
                 addDataFromFabric(new Packet(path, word, false));
         }