package edu.berkeley.fleet;
-/** an instruction within a codebag, as specified in am10 */
+/** an instruction within a codebag, as specified in am10; this class is immutable */
public class Instruction extends Dispatchable {
public final PortReference source;
public final PortReference destination;
public final int count;
- public final IgnoreCopyTake dataIn;
- public final boolean ack;
+
public final boolean trigger;
+ public final boolean dataIn;
+ public final boolean latch;
public final boolean dataOut;
-
- public static enum IgnoreCopyTake { IGNORE, COPY, TAKE };
+ public final boolean ack;
+ public final boolean recycle;
public Instruction(PortReference source,
PortReference destination,
int count,
- IgnoreCopyTake dataIn,
+ boolean dataIn,
+ boolean latch,
boolean ack,
boolean trigger,
boolean dataOut) {
+ this(source, destination, count, dataIn, latch, ack, trigger, dataOut, false);
+ }
+ public Instruction(PortReference source,
+ PortReference destination,
+ int count,
+ boolean dataIn,
+ boolean latch,
+ boolean ack,
+ boolean trigger,
+ boolean dataOut,
+ boolean recycle) {
this.source = source;
this.destination = destination;
this.count = count;
this.dataIn = dataIn;
+ this.latch = latch;
this.ack = ack;
this.trigger = trigger;
this.dataOut = dataOut;
+ this.recycle = recycle;
if (count <= 0)
throw new RuntimeException("count field of an instruction must be >0");
}
public String toString() {
StringBuffer ret = new StringBuffer();
- if (trigger) ret.append("triggered ");
- switch(dataIn) {
- case IGNORE:
- ret.append("nop");
- break;
- case COPY:
- ret.append(dataOut ? "copy" : "wait");
- break;
- case TAKE:
- ret.append(dataOut ? "move" : "discard");
- break;
- }
- if (ack) ret.append("+ack");
- ret.append(" ");
ret.append(source);
- ret.append(" ");
+ ret.append(": ");
+ boolean more=false;
switch(count) {
- case 1: ret.append("->"); break;
- case Integer.MAX_VALUE: ret.append("-[*]->"); break;
- default: ret.append("-["+count+"]->"); break;
+ case 1: break;
+ case Integer.MAX_VALUE: ret.append("[*] ");
+ default: ret.append("["+count+"] ");
}
- ret.append(" ");
- ret.append(destination);
+ if (trigger) { ret.append("wait"); more=true; }
+ if (dataIn && latch) { if (more) ret.append(", "); ret.append("take"); more = true; }
+ if (dataIn && !latch) { if (more) ret.append(", "); ret.append("discard"); more = true; }
+ if (dataOut && destination!=null) { if (more) ret.append(", "); ret.append("sendto "+destination); more = true; }
+ if (dataOut && destination==null) { if (more) ret.append(", "); ret.append("accept"); more = true; }
+ if (ack) { if (more) ret.append(", "); ret.append("ack "+destination); more = true; }
return ret.toString();
}
}