if (failed) break;
if (expect.size() == 0) break;
//if (now!=0) { System.err.println(); System.err.println(System.currentTimeMillis()-now); now=0;}
- long l = unBitSet(fp.readWord());
+ long l = unBitSet(fp.recvWord());
long l2 = expect.remove(0);
// FIXME, this is ugly and not size-independent
public static void run(Fleet fleet, Instruction[] instructions) throws IOException {
FleetProcess client = fleet.run(instructions);
while(true) {
- long result = unBitSet(client.readWord());
+ long result = unBitSet(client.recvWord());
System.err.print(result);
System.err.print(" 0x");
System.err.print(Long.toString(result, 16));
private boolean terminated = false;
- /** dispatch an instruction */
- public abstract void dispatchInstruction(Instruction i);
- public abstract void dispatchWord(Destination d, BitVector word);
- public void dispatchToken(Destination d) { throw new RuntimeException("not implemented"); }
- public void flush() { }
+ /** dispatch an instruction; may be buffered */
+ public abstract void sendInstruction(Instruction i);
+
+ /** dispatch a word to a given destination; may be buffered */
+ public abstract void sendWord(Destination d, BitVector word);
+
+ /** dispatch a token to a given destination; may be buffered */
+ public abstract void sendToken(Destination d);
+
+ /** flush all instructions, words, and tokens dispatched so far */
+ public abstract void flush();
/** the dock used to read back data from the slave */
public abstract Dock getDebugInputDock();
/** returns the next word delivered at the dock specified by <tt>getDebugInputDock()</tt> */
- public abstract BitVector readWord();
+ public abstract BitVector recvWord();
/** Terminate the process; subclasses may be assured that this will be called exactly once. */
protected abstract void _terminate();
};
FleetProcess fp = fleet.run(instructions);
- BitVector bv = fp.readWord();
+ BitVector bv = fp.recvWord();
System.out.println(bv.toLong());
fp.terminate();
}
};
FleetProcess fp = fleet.run(instructions);
- BitVector bv = fp.readWord();
+ BitVector bv = fp.recvWord();
System.out.println(bv.toLong());
fp.terminate();
}
FleetProcess fp = fleet.run(instructions.toArray(new Instruction[0]));
for(int i=0; i<8; i++)
- System.out.println(fp.readWord().toLong());
+ System.out.println(fp.recvWord().toLong());
fp.terminate();
}
public Dock getDebugInputDock() {
return fpga.getShip("Debug",0).getDock("in");
}
- public BitVector readWord() {
+ public BitVector recvWord() {
if (isTerminated())
throw new RuntimeException("this fleet has been terminated");
try {
this.dos = new DataOutputStream(os);
for(Instruction inst : instructions)
- dispatchInstruction(inst);
+ sendInstruction(inst);
flush();
final InputStream is = new BufferedInputStream(s.getInputStream());
t.start();
}
- public void dispatchToken(Destination d) { dispatchWord(d, new BitVector(fpga.getWordWidth()), true); }
- public void dispatchWord(Destination d, BitVector word) { dispatchWord(d, word, false); }
- private void dispatchWord(Destination d, BitVector word, boolean token) {
+ public void sendToken(Destination d) { sendWord(d, new BitVector(fpga.getWordWidth()), true); }
+ public void sendWord(Destination d, BitVector word) { sendWord(d, word, false); }
+ private void sendWord(Destination d, BitVector word, boolean token) {
try {
Dock dispatchFrom = fpga.debugShip.getDock("in");
long out = 0;
throw new RuntimeException(e);
}
}
- public void dispatchInstruction(Instruction inst) {
+ public void sendInstruction(Instruction inst) {
Dock dispatchFrom = fpga.debugShip.getDock("in");
- dispatchWord(inst.dock.getInstructionDestination(),
- new BitVector(fpga.getWordWidth()).set(fpga.writeInstruction(inst, dispatchFrom)));
+ sendWord(inst.dock.getInstructionDestination(),
+ new BitVector(fpga.getWordWidth()).set(fpga.writeInstruction(inst, dispatchFrom)));
}
private static Move discard(Dock dock) { return new Move(dock, false, IgnoreOLC, false, null, false, true, false, false, false, false); }
private class InterpreterProcess extends FleetProcess implements Runnable {
private Instruction[] instructions;
- public void dispatchWord(Destination d, BitVector word) {
+ public void flush() { }
+ public void sendWord(Destination d, BitVector word) {
throw new RuntimeException("not implemented");
}
+ public void sendToken(Destination d) { throw new RuntimeException("not implemented"); }
public InterpreterProcess(Instruction[] instructions) {
this.instructions = instructions;
for(Instruction i : instructions)
- dispatchInstruction(i);
+ sendInstruction(i);
}
public Fleet getFleet() { return Interpreter.this; }
- public void dispatchInstruction(Instruction i) { dispatch(i); }
+ public void sendInstruction(Instruction i) { dispatch(i); }
public Dock getDebugInputDock() { return debugShip.getDock("in"); }
- public BitVector readWord() {
+ public BitVector recvWord() {
try {
return debugStream.take();
} catch (Exception e) { throw new RuntimeException(e); }
FleetProcess fp = n.fleet.run((Instruction[])al.toArray(new Instruction[0]));
System.out.println("launching...");
- while(true) System.out.println(fp.readWord().toLong());
+ while(true) System.out.println(fp.recvWord().toLong());
}
private void recvSendTokenDeliver(Dock dock, Destination dest) {