import java.io.*;
import java.util.*;
-/** represents a <i>running</i> "slave" fleet with a debug connection */
+/**
+ * Represents a <i>running</i> "slave" fleet with debugging
+ * facilities controlled by the "master" JVM.
+ *
+ * <p>Each Fleet which supports this API must include:
+ * <ul><li> The ability to dispatch instructions, words, and tokens
+ * from the master, "on the fly".
+ * <li> A "debug.in" dock such that any words delivered there
+ * are sent back to the master.
+ * </ul>
+ */
public abstract class FleetProcess {
private boolean terminated = false;
- /** dumps an instruction into the fetch unit */
- public abstract void invokeInstruction(Instruction i);
+ /** dispatch an instruction; may be buffered */
+ public abstract void sendInstruction(Instruction i);
- /** reads a word back from the debug port */
- public abstract long readWord();
+ /** dispatch a word to a given destination; may be buffered */
+ public abstract void sendWord(Destination d, BitVector word);
- /** subclasses may be assured that this will be called exactly once */
+ /** dispatch a word to a given destination; may be buffered */
+ public abstract void sendWord(Destination d, BitVector word, BitVector signal);
+
+ /** convenience method: sends the word to d's data destination */
+ public void sendWord(Dock d, BitVector word) { sendWord(d.getDataDestination(), word); }
+
+ /** dispatch a token to a given destination; may be buffered */
+ public abstract void sendToken(Destination d);
+
+ /** convenience method: sends a token to d's data destination */
+ public void sendToken(Dock d) { sendToken(d.getDataDestination()); }
+
+ /** convenience method: sends a token to d's instruction destination */
+ public void sendTorpedo(Dock d) { sendToken(d.getInstructionDestination()); }
+
+ /** 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 recvWord();
+
+ /** Terminate the process; subclasses may be assured that this will be called exactly once. */
protected abstract void _terminate();
- public synchronized void terminate() {
+ public void masterClear() { throw new RuntimeException("not implemented"); }
+
+ /** Terminate the process. */
+ public final synchronized void terminate() {
if (terminated) return;
terminated = true;
_terminate();
}
- public boolean isTerminated() {
- return terminated;
- }
+ /** Returns true if the process is terminated */
+ public final boolean isTerminated() { return terminated; }
- public synchronized void finalize() {
- if (!terminated)
- terminate();
- }
+ public synchronized void finalize() { terminate(); }
+ /** return the Fleet that this FleetProcess controls */
+ public abstract Fleet getFleet();
}