remove ugly FleetTwoFleet.getUniversalSource() method
authoradam <adam@megacz.com>
Thu, 26 Jun 2008 07:40:12 +0000 (08:40 +0100)
committeradam <adam@megacz.com>
Thu, 26 Jun 2008 07:40:12 +0000 (08:40 +0100)
src/edu/berkeley/fleet/assembler/Parser.java
src/edu/berkeley/fleet/fpga/Client.java
src/edu/berkeley/fleet/fpga/Fpga.java
src/edu/berkeley/fleet/interpreter/Interpreter.java
src/edu/berkeley/fleet/two/FleetTwoFleet.java

index fe981c6..9f374be 100644 (file)
@@ -79,13 +79,6 @@ public class Parser {
         CodeBag baseCodeBag = new CodeBag();
         CodeBag rootCodeBag = new CodeBag();
         skip = false;
-        Dock dock = null;
-        if (fleet instanceof Fpga) {
-            dock = ((Fpga)fleet).getUniversalSource();
-        } else {
-            dock = ((Interpreter)fleet).getUniversalSource();
-        }
-        //baseCodeBag.add(new Set(dock, false, IgnoreOLC, SetDest.DataLatch, (rootCodeBag.getFakeAddress())), true);
         Tree<String> parsed = (Tree<String>)parseIt(r);
         walk(parsed, rootCodeBag);
 
@@ -136,13 +129,6 @@ public class Parser {
         ArrayList<Instruction> ret = new ArrayList<Instruction>();
         Fleet fpga = fleet;
 
-        Dock us = null;
-        if (fleet instanceof Fpga) {
-            us = ((Fpga)fleet).getUniversalSource();
-        } else {
-            us = ((Interpreter)fleet).getUniversalSource();
-        }
-
         Dock inAddrWrite = null;
         Dock inDataWrite = null;
         Dock inCBD       = null;
@@ -164,19 +150,7 @@ public class Parser {
         }
 
         for(int i=0; i<instructions.length; i++) {
-            Instruction inst = instructions[i];
-            /*
-            if (i==0) {
-                long lit = ((Instruction.Set)inst).immediate;
-                long offset = (lit >> 6) & ~(-1L << 10);
-                long size   = (lit >> 0) & ~(-1L << 6);
-                //startcbd = (offset << 6) | size;
-                size = 0;
-                offset = 0;
-                continue;
-            }
-            */
-            long lit = ((Fpga)fpga).writeInstruction(instructions[i], us);
+            long lit = ((Fpga)fpga).writeInstruction(instructions[i], out);
             ret.add(discard(out));
             ret.add(new Instruction.Shift(inDataWrite, false, IgnoreOLC, new BitVector(fpga.getWordWidth()).set(getField(36, 19, lit))));
             ret.add(new Instruction.Shift(inDataWrite, false, IgnoreOLC, new BitVector(fpga.getWordWidth()).set(getField(18,  0, lit))));
index 793c987..709ce15 100644 (file)
@@ -56,7 +56,7 @@ public class Client extends FleetProcess {
 
         DataOutputStream dos = new DataOutputStream(os);
         for(Instruction inst : instructions)
-            fpga.writeInstruction(dos, fpga.getUniversalSource(), inst);
+            fpga.writeInstruction(dos, fpga.debugShip.getDock("in"), inst);
         dos.flush();
 
         final InputStream is = new BufferedInputStream(s.getInputStream());
index 06bf207..ff59f5b 100644 (file)
@@ -243,10 +243,9 @@ public class Fpga extends FleetTwoFleet {
     }
 
 
-    private Ship debugShip;
+    Ship debugShip;
 
 
-        public Dock getUniversalSource() { return debugShip.getDock("in"); }
         public long getDestAddr(Path path) {
             return ((FpgaPath)path).toLong();
         }
index 69fd939..729f6cd 100644 (file)
@@ -59,11 +59,6 @@ public class Interpreter extends FleetTwoFleet implements Parser.FleetWithDynami
 
     // Instruction Encoding /////////////////////////////////////////////////////////////////////////
 
-    public Dock getUniversalSource() {
-        // FIXME
-        return debugShip.getDock("in");
-    }
-
     public long getDestAddr(Path path) {
         // FIXME
         throw new RuntimeException();
index cce5067..2ec3680 100644 (file)
@@ -95,9 +95,6 @@ public abstract class FleetTwoFleet extends Fleet {
     // FIXME this should use a BitVector not a long!
     protected abstract Path getPathByAddr(Dock source, long dest);
 
-    /** FIXME: this is a hack for now */
-    protected abstract Dock getUniversalSource();
-
     /** read a machine-formatted instruction from a file (into a Java object) */
     public Instruction readInstruction(DataInputStream is, Dock dispatchFrom) throws IOException {
         long inst = 0;
@@ -115,7 +112,7 @@ public abstract class FleetTwoFleet extends Fleet {
     }
 
     public Instruction readInstruction(long inst, Dock dispatchFrom) {
-        Dock dock = getPathByAddr(getUniversalSource(), DISPATCH_PATH.getval(inst)).getDestination().getDock();
+        Dock dock = getPathByAddr(dispatchFrom, DISPATCH_PATH.getval(inst)).getDestination().getDock();
 
         if (TAIL.get(inst))   return new Tail(dock);
 
@@ -191,7 +188,7 @@ public abstract class FleetTwoFleet extends Fleet {
         long instr = 0;
 
         if (d.dock != null)
-            instr = DISPATCH_PATH.setval(instr, getDestAddr(getUniversalSource().getPath(d.dock.getInstructionDestination(),null)));
+            instr = DISPATCH_PATH.setval(instr, getDestAddr(dispatchFrom.getPath(d.dock.getInstructionDestination(),null)));
 
         boolean dl = false;
         Instruction pi = d;