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 {
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++)
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) {
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;
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;
}
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
}