change readWord()/dispatchXX() to recvWord()/sendXX() in FleetProcess
authoradam <adam@megacz.com>
Mon, 3 Nov 2008 09:55:07 +0000 (10:55 +0100)
committeradam <adam@megacz.com>
Mon, 3 Nov 2008 09:55:07 +0000 (10:55 +0100)
src/edu/berkeley/fleet/Main.java
src/edu/berkeley/fleet/api/FleetProcess.java
src/edu/berkeley/fleet/demo/Test.java
src/edu/berkeley/fleet/demo/Test2.java
src/edu/berkeley/fleet/demo/Test3.java
src/edu/berkeley/fleet/fpga/Client.java
src/edu/berkeley/fleet/interpreter/Interpreter.java
src/edu/berkeley/fleet/ir/New.java

index c1e8952..e1eaed0 100644 (file)
@@ -117,7 +117,7 @@ public class Main {
                 if (failed) break;
                 if (expect.size() == 0) break;
                 //if (now!=0) { System.err.println(); System.err.println(System.currentTimeMillis()-now); now=0;}
-                long l = unBitSet(fp.readWord());
+                long l = unBitSet(fp.recvWord());
                 long l2 = expect.remove(0);
 
                 // FIXME, this is ugly and not size-independent
@@ -165,7 +165,7 @@ public class Main {
     public static void run(Fleet fleet, Instruction[] instructions) throws IOException {
         FleetProcess client = fleet.run(instructions);
         while(true) {
-            long result = unBitSet(client.readWord());
+            long result = unBitSet(client.recvWord());
             System.err.print(result);
             System.err.print(" 0x");
             System.err.print(Long.toString(result, 16));
index 80d9f6c..1db837f 100644 (file)
@@ -17,17 +17,23 @@ public abstract class FleetProcess {
 
     private boolean terminated = false;
 
-    /** dispatch an instruction */
-    public abstract void dispatchInstruction(Instruction i);
-    public abstract void dispatchWord(Destination d, BitVector word);
-    public void dispatchToken(Destination d) { throw new RuntimeException("not implemented"); }
-    public void flush() { }
+    /** dispatch an instruction; may be buffered */
+    public abstract void sendInstruction(Instruction i);
+
+    /** dispatch a word to a given destination; may be buffered */
+    public abstract void sendWord(Destination d, BitVector word);
+
+    /** dispatch a token to a given destination; may be buffered */
+    public abstract void sendToken(Destination d);
+
+    /** flush all instructions, words, and tokens dispatched so far */
+    public abstract void flush();
 
     /** the dock used to read back data from the slave */
     public abstract Dock getDebugInputDock();
 
     /** returns the next word delivered at the dock specified by <tt>getDebugInputDock()</tt> */
-    public abstract BitVector readWord();
+    public abstract BitVector recvWord();
 
     /** Terminate the process; subclasses may be assured that this will be called exactly once. */
     protected abstract void _terminate();
index 7722131..1d5849a 100644 (file)
@@ -33,7 +33,7 @@ public class Test {
         };
 
         FleetProcess fp = fleet.run(instructions);
-        BitVector bv = fp.readWord();
+        BitVector bv = fp.recvWord();
         System.out.println(bv.toLong());
         fp.terminate();
     }
index 0bf28e6..00cd082 100644 (file)
@@ -46,7 +46,7 @@ public class Test2 {
         };
 
         FleetProcess fp = fleet.run(instructions);
-        BitVector bv = fp.readWord();
+        BitVector bv = fp.recvWord();
         System.out.println(bv.toLong());
         fp.terminate();
     }
index 242e3eb..86d2581 100644 (file)
@@ -101,7 +101,7 @@ public class Test3 {
 
         FleetProcess fp = fleet.run(instructions.toArray(new Instruction[0]));
         for(int i=0; i<8; i++)
-            System.out.println(fp.readWord().toLong());
+            System.out.println(fp.recvWord().toLong());
         fp.terminate();
     }
 
index de8564e..6b71a76 100644 (file)
@@ -28,7 +28,7 @@ public class Client extends FleetProcess {
     public Dock getDebugInputDock() {
         return fpga.getShip("Debug",0).getDock("in");
     }
-    public BitVector readWord() {
+    public BitVector recvWord() {
         if (isTerminated())
             throw new RuntimeException("this fleet has been terminated");
         try {
@@ -65,7 +65,7 @@ public class Client extends FleetProcess {
 
         this.dos = new DataOutputStream(os);
         for(Instruction inst : instructions)
-            dispatchInstruction(inst);
+            sendInstruction(inst);
         flush();
 
         final InputStream is = new BufferedInputStream(s.getInputStream());
@@ -97,9 +97,9 @@ public class Client extends FleetProcess {
         t.start();
     }
 
-    public void dispatchToken(Destination d) { dispatchWord(d, new BitVector(fpga.getWordWidth()), true); }
-    public void dispatchWord(Destination d, BitVector word) { dispatchWord(d, word, false); }
-    private void dispatchWord(Destination d, BitVector word, boolean token) {
+    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) {
         try {
             Dock dispatchFrom = fpga.debugShip.getDock("in");
             long out = 0;
@@ -115,10 +115,10 @@ public class Client extends FleetProcess {
             throw new RuntimeException(e);
         }
     }
-    public void dispatchInstruction(Instruction inst) {
+    public void sendInstruction(Instruction inst) {
         Dock dispatchFrom = fpga.debugShip.getDock("in");
-        dispatchWord(inst.dock.getInstructionDestination(),
-                     new BitVector(fpga.getWordWidth()).set(fpga.writeInstruction(inst, dispatchFrom)));
+        sendWord(inst.dock.getInstructionDestination(),
+                 new BitVector(fpga.getWordWidth()).set(fpga.writeInstruction(inst, dispatchFrom)));
     }
 
     private static Move discard(Dock dock)           { return new Move(dock, false, IgnoreOLC, false, null, false, true,  false, false, false, false); }
index 3cd2558..670897b 100644 (file)
@@ -137,18 +137,20 @@ public class Interpreter extends FleetTwoFleet implements Parser.FleetWithDynami
 
     private class InterpreterProcess extends FleetProcess implements Runnable {
         private Instruction[] instructions;
-        public void dispatchWord(Destination d, BitVector word) {
+        public void flush() { }
+        public void sendWord(Destination d, BitVector word) {
             throw new RuntimeException("not implemented");
         }
+        public void sendToken(Destination d) { throw new RuntimeException("not implemented"); }
         public InterpreterProcess(Instruction[] instructions) {
             this.instructions = instructions;
             for(Instruction i : instructions)
-                dispatchInstruction(i);
+                sendInstruction(i);
         }
         public Fleet getFleet() { return Interpreter.this; }
-        public void dispatchInstruction(Instruction i) { dispatch(i); }
+        public void sendInstruction(Instruction i) { dispatch(i); }
         public Dock getDebugInputDock() { return debugShip.getDock("in"); }
-        public BitVector readWord() {
+        public BitVector recvWord() {
             try {
                 return debugStream.take();
             } catch (Exception e) { throw new RuntimeException(e); }
index 44aa964..db520ab 100644 (file)
@@ -406,7 +406,7 @@ public class New {
         
         FleetProcess fp = n.fleet.run((Instruction[])al.toArray(new Instruction[0]));
         System.out.println("launching...");
-        while(true) System.out.println(fp.readWord().toLong());
+        while(true) System.out.println(fp.recvWord().toLong());
     }
 
     private void recvSendTokenDeliver(Dock dock, Destination dest) {