make getDestAddr() return a BitVector
[fleet.git] / src / edu / berkeley / fleet / interpreter / InterpreterDock.java
index 400a968..d1c6968 100644 (file)
@@ -5,7 +5,6 @@ import edu.berkeley.fleet.two.*;
 import edu.berkeley.fleet.api.*;
 import edu.berkeley.fleet.api.Instruction;
 import static edu.berkeley.fleet.api.Predicate.*;
-import static edu.berkeley.fleet.two.FleetTwoFleet.SHIFT;
 
 /** anything that has a source (instruction horn) address on the switch fabric */
 class InterpreterDock extends FleetTwoDock {
@@ -71,8 +70,12 @@ class InterpreterDock extends FleetTwoDock {
     public final boolean readyForDataFromShip() { return readyForDataFromShip; }
 
     public long removeDataForShip() {
-        if (!dataReadyForShip) throw new RuntimeException();
+        long val = peekDataForShip();
         dataReadyForShip = false;
+        return val;
+    }
+    public long peekDataForShip() {
+        if (!dataReadyForShip) throw new RuntimeException();
         BitVector bv = dataLatch;
         long val = 0;
         for(int i=0; i<bv.length(); i++)
@@ -160,13 +163,16 @@ class InterpreterDock extends FleetTwoDock {
             instructions.add(executing);
 
         if (executing instanceof Instruction.Shift) {
+            /*
             Instruction.Shift shift = (Instruction.Shift)executing;
-            for(int i=dataLatch.length()-1; i>=SHIFT.valmaskwidth; i--)
-                dataLatch.set(i, dataLatch.get(i-SHIFT.valmaskwidth));
-            for(int i=SHIFT.valmaskwidth-1; i>=0; i--)
+            for(int i=dataLatch.length()-1; i>=getShip().getFleet().getShiftWidth(); i--)
+                dataLatch.set(i, dataLatch.get(i-getShip().getFleet().getShiftWidth()));
+            for(int i=getShip().getFleet().getShiftWidth()-1; i>=0; i--)
                 dataLatch.set(i, shift.immediate.get(i));
             executing = null;
             return;
+            */
+            throw new RuntimeException("FIXME");
         }
 
         if (executing instanceof Instruction.Set) {
@@ -182,7 +188,7 @@ class InterpreterDock extends FleetTwoDock {
                             break;
                         case DataLatch:
                             ilc = 0;
-                            for(int i=0; i<FleetTwoFleet.SET_ILC_FROM_IMMEDIATE.valmaskwidth-1; i++)
+                            for(int i=0; i<((FleetTwoFleet)getShip().getFleet()).SET_ILC_FROM_IMMEDIATE.valmaskwidth-1; i++)
                                 if (dataLatch.get(i))
                                     ilc |= (1 << i);
                             break;
@@ -201,7 +207,7 @@ class InterpreterDock extends FleetTwoDock {
                             break;
                         case DataLatch:
                             olc = 0;
-                            for(int i=0; i<FleetTwoFleet.SET_OLC_FROM_IMMEDIATE.valmaskwidth-1; i++)
+                            for(int i=0; i<((FleetTwoFleet)getShip().getFleet()).SET_OLC_FROM_IMMEDIATE.valmaskwidth-1; i++)
                                 if (dataLatch.get(i))
                                     olc |= (1 << i);
                             if (olc==0) hatchIsOpen = true;
@@ -273,7 +279,7 @@ class InterpreterDock extends FleetTwoDock {
             }
             if (move.latchData) dataLatch = bv;
             if (move.latchPath)
-                pathLatch = (InterpreterPath)getInterpreter().getPathByAddr(this, FleetTwoFleet.DISPATCH_PATH.getval(bv));
+                pathLatch = (InterpreterPath)getInterpreter().getPathByAddr(this, ((FleetTwoFleet)getShip().getFleet()).DISPATCH_PATH.getvalAsBitVector(bv.toLong()));
             // FIXME: c-flag at output docks
         }