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 InstructionPump {
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 item to be transmitted, send it
InterpreterDestination dest = (InterpreterDestination)instruction.dest;
if (instruction.dataOutDest) {
- // FIXME
- long bits = BitManipulations.getField(InstructionEncoder.WIDTH_WORD-1,
- InstructionEncoder.WIDTH_WORD-InstructionEncoder.WIDTH_DEST_ADDR,
+ // 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));
- throw new RuntimeException();
+ if (dest == null) {
+ if (pump != null) {
+
+ Pump pump = ((Interpreter)getInterpreter()).iie.getDestByInstAddr(bits);
+ }
+ }
+ */
+ //throw new RuntimeException();
+ } else {
+ new Packet(getInterpreter(), this, register, dest).send();
}
- new Packet(getInterpreter(), this, register, dest).send();
if (instruction.tokenOut)
throw new RuntimeException("outboxes may not send acks!");