package edu.berkeley.fleet.interpreter;
import edu.berkeley.sbp.util.ANSI;
import edu.berkeley.fleet.api.*;
+import edu.berkeley.fleet.ies44.*;
+import edu.berkeley.sbp.util.*;
+import edu.berkeley.fleet.util.*;
+import static edu.berkeley.fleet.util.BitManipulations.*;
import edu.berkeley.fleet.api.Instruction;
-public class Outbox extends InstructionBenkoBox {
+public class Outbox extends InstructionPump {
/** are we ready to accept another item from the ship? */
private boolean readyForDataFromShip = false;
public Outbox(InterpreterShip ship, String name) { this(ship, name, new String[] { "" }); }
public Outbox(InterpreterShip ship, String name, String[] ports) { super(ship, name, ports); }
- protected final boolean service(Instruction.Executable instruction) {
+ protected void setDataLatch(long value) { register = value; }
+ protected long peekDataLatch() { return register; }
+
+ protected final boolean service(Instruction.Executable instruction_) {
+ if (clogged>0) return false;
+ if (instruction_ instanceof Instruction.Clog) { clogged++; return true; }
+ if (instruction_ instanceof Instruction.LocalLiteral) {
+ Instruction.LocalLiteral ll = (Instruction.LocalLiteral)instruction_;
+ register =
+ ll.high
+ ? setField(36, 19, ll.literal, register)
+ : setField(18, 0, ll.literal, register);
+ return true;
+ }
+ Instruction.Move instruction = (Instruction.Move)instruction_;
// if no instruction waiting, do nothing
if (instruction == null) return false;
if (instruction.dataOut) {
// if item to be transmitted, send it
- new Packet(getInterpreter(), this, register, (InterpreterDestination)instruction.dest).send();
+ InterpreterDestination dest = (InterpreterDestination)instruction.dest;
+ if (instruction.dataOutDest) {
+ // FIXME: still not supported
+ long bits = BitManipulations.getField(InstructionEncoder.OFFSET_PUMP_ADDR+InstructionEncoder.WIDTH_PUMP_ADDR-1,
+ InstructionEncoder.OFFSET_PUMP_ADDR,
+ register);
+ getInterpreter().dispatch(((Interpreter)getInterpreter()).iie.readInstruction(register), bits);
+ /*
+ dest = (InterpreterDestination)(((Interpreter)getInterpreter()).iie.getDestByAddr(bits));
+ if (dest == null) {
+ if (pump != null) {
+
+ Pump pump = ((Interpreter)getInterpreter()).iie.getDestByInstAddr(bits);
+ }
+ }
+ */
+ //throw new RuntimeException();
+ } else {
+ new Packet(getInterpreter(), this, register, dest).send();
+ }
if (instruction.tokenOut)
throw new RuntimeException("outboxes may not send acks!");