Flags: zero, negative, overflow, ?
-\begin{verbatim}
-move elsewhere:
-//MUL:
-//DIV:
-//MOD:
-\end{verbatim}
-
== Fleeterpreter ====================================================
public long resolveLiteral(String literal) {
if (literal.equals("ADD")) return 0;
deliver;
[*] take, deliver;
alu.out:
- [*] nop;
+ clog;
(*) wait, take, sendto lut.inLut;
(*) sendto alu.in;
- kill*;
+ unclog;
// acks from debug ship trigger new truth tables
-debug.in: [*] take, deliver, notify alu.out;
+debug.in:
+ [*] take, deliver, notify alu.out;
lut.inLut:
literal 0;
public abstract class Instruction {
- public static class Kill extends Instruction {
-
- public final Pump pump;
- public final int count;
- public final boolean killOnlyStandingInstructions;
- public Kill(Pump pump, int count, boolean killOnlyStandingInstructions) {
- this.pump=pump;
- this.count=count;
- this.killOnlyStandingInstructions = killOnlyStandingInstructions;
- if (killOnlyStandingInstructions && count !=1)
- throw new RuntimeException("currently, kill* must have count=1");
+ public final Pump pump;
+ public Instruction(Pump pump) { this.pump = pump; }
+ public String toString() { return pump+": "; }
+
+ public static abstract class CountingInstruction extends Instruction {
+ public final int count;
+ public CountingInstruction(Pump pump, int count) {
+ super(pump);
+ this.count = count;
}
- public String toString() { return (count>1 ? "["+count+"] " : "") + "kill" + (killOnlyStandingInstructions ? "*" : ""); }
+ protected abstract boolean isRequeueing();
+ public String toString() { return super.toString()+(count==1?"":(isRequeueing()?("("+(count==0?"*":(count+""))+")"):("["+(count==0?"*":(count+""))+"]")))+" "; }
+ }
+ public static class UnClog extends Instruction {
+ public UnClog(Pump pump) { super(pump); }
+ public String toString() { return super.toString() + "unclog;"; }
+ }
+
+ public static class Clog extends Instruction {
+ public Clog(Pump pump) { super(pump); }
+ public String toString() { return super.toString() + "clog;"; }
+ }
+
+ public static class Kill extends CountingInstruction {
+ public Kill(Pump pump, int count) { super(pump, count); }
+ protected boolean isRequeueing() { return false; }
+ public String toString() { return super.toString() + "kill;"; }
}
public static class Executable extends Instruction {
- public final Pump pump;
public final Destination dest;
public final int count;
- public final boolean tokenIn;
- public final boolean dataIn;
- public final boolean latch;
- public final boolean dataOutDest;
- public final boolean dataOut;
- public final boolean tokenOut;
- public final boolean requeue;
+ public final boolean tokenIn;
+ public final boolean dataIn;
+ public final boolean latch;
+ public final boolean dataOutDest;
+ public final boolean dataOut;
+ public final boolean tokenOut;
+ public final boolean requeue;
+ public final boolean ignoreUntilLast;
+
+ protected boolean isRequeueing() { return requeue; }
/** count=0 denotes a standing move */
- public Executable(Pump pump,
+ public Executable(Pump pump,
Destination dest,
int count,
boolean tokenIn,
boolean dataOutDest,
boolean dataOut,
boolean tokenOut,
- boolean requeue) {
- this.pump = pump;
+ boolean requeue,
+ boolean ignoreUntilLast) {
+ super(pump);
this.dest = dest;
this.count = count;
this.tokenIn = tokenIn;
this.dataOut = dataOut;
this.tokenOut = tokenOut;
this.requeue = requeue;
+ this.ignoreUntilLast = ignoreUntilLast;
if (count < 0)
throw new RuntimeException("count field of an instruction must be >=0");
}
public Instruction.Executable decrementCount() {
if (count==1) return null;
return new Executable(pump, dest, count==0 ? 0 : count-1,
- tokenIn, dataIn, latch, dataOutDest, dataOut, tokenOut, requeue);
+ tokenIn, dataIn, latch, dataOutDest, dataOut, tokenOut, requeue, ignoreUntilLast);
}
public String toString() {
- String ret = pump.toString() + ": ";
- if (count==0 || count>1 || requeue) {
- ret += requeue ? "(" : "[";
- if (count>1) ret += count;
- if (count==0) ret += "*";
- ret += requeue ? ")" : "] ";
- }
+ // FIXME
+ String ret = super.toString();
boolean needcomma = false;
if (tokenIn) { ret += (needcomma ? ", " : "") + "wait"; needcomma = true; }
if (dataIn && latch) {
}
- public static class LocalLiteral extends Instruction {
- public final Pump pump;
+ public static class LocalLiteral extends CountingInstruction {
public final long literal;
- public LocalLiteral(Pump pump, long literal) {
- this.pump = pump;
+ public boolean isRequeueing() { return true; }
+ public LocalLiteral(Pump pump, long literal, int count) {
+ super(pump, count);
this.literal = literal;
}
}
- public static class Literal extends Instruction {
- public final Destination dest;
- protected Literal(Destination dest) { this.dest = dest; }
-
- public static class Absolute extends Literal {
- public final long value;
- public Absolute(Destination dest, long value) { super(dest); this.value = value; }
- public String toString() {
- return value + ": sendto " + dest;
- }
- }
-
- public static class Relative extends Literal {
- /** value transmitted will be offset plus the address from which this instruction was loaded */
- public final long offset;
- public Relative(Destination dest, long offset) { super(dest); this.offset = offset; }
- public String toString() {
- String off = ""+offset;
- if (offset > 0) off = "+"+off;
- return "(@"+offset+"): sendto " + dest;
- }
- }
- }
-
public static class CodeBagDescriptor extends Instruction {
/** address of CBD, relative to address that this instruction was loaded from */
- public final Pump pump;
public final long offset;
public final long size;
public CodeBagDescriptor(Pump pump, long offset, long size) {
- this.pump = pump;
+ super(pump);
this.offset = offset;
this.size = size;
}
CodeBag baseCodeBag = new CodeBag();
CodeBag rootCodeBag = new CodeBag();
skip = false;
- baseCodeBag.add(new Instruction.Literal.CodeBagDescriptor(null, rootCodeBag.getFakeAddress(), 1));
+ baseCodeBag.add(new Instruction.CodeBagDescriptor(null, rootCodeBag.getFakeAddress(), 1));
walk((Tree<String>)parse(r), rootCodeBag);
if (fleet instanceof edu.berkeley.fleet.fpga.Fpga)
((edu.berkeley.fleet.fpga.Fpga)fleet).dumpFabric(true);
CodeBag c = codeBags.get(i);
dos.flush();
for(Instruction inst : c) {
- if (inst instanceof Instruction.Literal.CodeBagDescriptor) {
+ if (inst instanceof Instruction.CodeBagDescriptor) {
dos.flush();
- Instruction.Literal.CodeBagDescriptor old = (Instruction.Literal.CodeBagDescriptor)inst;
+ Instruction.CodeBagDescriptor old = (Instruction.CodeBagDescriptor)inst;
int offset = codeBagMap[(int)old.offset];// - count;
- inst = new Instruction.Literal.CodeBagDescriptor(old.pump,
+ inst = new Instruction.CodeBagDescriptor(old.pump,
offset,
codeBags.get((int)old.offset).size());
//System.out.println("cbd: " + offset + " " + codeBags.get((int)old.offset).size() + " " + codeBags.get((int)old.offset).name + " " + codeBags.get((int)old.offset));
boolean tokenOut = false;
boolean dataOutDest = false;
boolean localLiteral = false;
+ boolean ignoreUntilLast = false;
long literal = 0;
Destination dest = null;
for(int i=0; i<ttx.size(); i++) {
if ("Wait".equals(ttt.head())) { tokenIn = true; }
else if ("Nop".equals(ttt.head())) { }
else if ("KillStar".equals(ttt.head())) {
- cb.add(new Instruction.Kill(pump, count, true));
+ cb.add(new Instruction.UnClog(pump));
+ continue OUTER;
+ } else if ("Clog".equals(ttt.head())) {
+ cb.add(new Instruction.Clog(pump));
continue OUTER;
} else if ("Kill".equals(ttt.head())) {
- cb.add(new Instruction.Kill(pump, count, false));
+ cb.add(new Instruction.Kill(pump, count));
continue OUTER;
}
else if ("Discard".equals(ttt.head())) { dataIn = true; latch = false; }
else if ("LocalLiteralCodeBag".equals(ttt.head())) {
String refname = name(ttt.child(0).child(0));
CodeBag cb2 = getCodeBag(refname);
- cb.add(new Instruction.Literal.CodeBagDescriptor(pump, cb2.getFakeAddress(), 0));
+ cb.add(new Instruction.CodeBagDescriptor(pump, cb2.getFakeAddress(), 0));
continue OUTER;
} else if ("LocalLiteralConst".equals(ttt.head())) {
localLiteral = true;
else if ("DataOutDest".equals(ttt.head())) { dataOutDest = true; }
else if ("Deliver".equals(ttt.head())) { dataOut = true; }
else if ("Ack".equals(ttt.head())) { tokenOut = true; dest = portReference(ttt.child(0)); }
+ else if ("AckLast".equals(ttt.head())) { tokenOut = true; ignoreUntilLast = true; dest = portReference(ttt.child(0)); }
}
if (localLiteral)
- cb.add(new Instruction.LocalLiteral(pump, literal));
+ cb.add(new Instruction.LocalLiteral(pump, literal, count));
else
cb.add(new Instruction.Executable(pump,
dest, count, tokenIn, dataIn,
- latch, dataOutDest, dataOut, tokenOut, requeue));
+ latch, dataOutDest, dataOut, tokenOut, requeue, ignoreUntilLast));
}
}
}
("":: Command +/ (ws! "," ws!) ws! ";"!)
Command = Nop:: "nop"
| Kill:: "kill"
- | KillStar:: "kill*"
+ | KillStar:: "unclog"
+ | Clog:: "clog"
| Wait:: "wait"
| Discard:: "dismiss"
| Take:: ("take"|"receive")
| LocalLiteralConst:: "literal" ws! SSL
| LocalLiteralCodeBag:: "literal" ws! CodeBag
| Ack:: "notify" ws! Port
+ | AckLast:: "notifyLast" ws! Port
Source = Port
| ShipSpecific
if (tex!=null)
pw.println(tex);
for(PumpDescription bbd : sd) {
- pw.println("\\subsection*{"+(bbd.isInbox() ? "Inbox: " : "Outbox: ")+"{\\tt "+bbd.getName()+"}}");
+ pw.println("\\subsection*{"+(bbd.isInbox() ? "Input: " : "Output: ")+"{\\tt "+bbd.getName()+"}}");
}
}
public Fpga(String bitfile) {
this.bitfile = bitfile;
createShip("Debug", "debug");
- createShip("Memory", "Memory");
+ createShip("Memory", "memory");
+ createShip("Memory", "memory2"); // need this to avoid a bug
createShip("Fifo", "fifo1");
createShip("Fifo", "fifo2");
createShip("Fifo", "fifo3");
- createShip("Execute", "execute");
createShip("Alu1", "alu1");
createShip("Alu2", "alu2a");
createShip("Lut3", "lut3");
Assignable data_latch = new SimpleAssignable(inbox ? data_out.getName() : "`packet_data("+data_out.getName()+")");
String data_latch_input = inbox ? "`packet_data("+data_in.getName()+")" : data_in.getName();
- // Literal
- box.new Event(
- new Object[] {
- ondeckFull.isFull(),
- data_out,
- "`instruction_is_literal(ondeck)"
- },
- new Action[] {
- new SimpleAction("ondeck_full<=0;"),
- new AssignAction(data_latch, "`instruction_literal(ondeck)"),
- newMayProceed.doFill()
- }
- );
-
box.new Event(
new Object[] { ondeckFull.isFull(),
data_out,
token_out,
ififo_in,
- "!`instruction_is_literal(ondeck)",
+ "(`instruction_is_normal(ondeck) || `instruction_is_literal(ondeck))",
new ConditionalTrigger("`instruction_bit_datain(ondeck)", data_in),
new ConditionalTrigger("`instruction_bit_tokenin(ondeck)", token_in)
},
new Action[] { new SimpleAction("ondeck_full<=0;"),
- new ConditionalAction("`instruction_count(ondeck)==1 || `instruction_bit_recycle(ondeck)", newMayProceed.doFill()),
- new ConditionalAction("`instruction_bit_recycle(ondeck) && `instruction_count(ondeck)!=1",
+ new ConditionalAction("`instruction_count(ondeck)==1 || `instruction_bit_requeue(ondeck)", newMayProceed.doFill()),
+ new ConditionalAction("`instruction_bit_requeue(ondeck) && `instruction_count(ondeck)!=1",
new AssignAction(ififo_in, ondeck)),
- new ConditionalAction("`instruction_bit_recycle(ondeck) && `instruction_count(ondeck)!=1 && `instruction_count(ondeck)==0",
+ new ConditionalAction("`instruction_bit_requeue(ondeck) && `instruction_count(ondeck)!=1 && `instruction_count(ondeck)==0",
new AssignAction(instruction_count_ififo_in, "0")),
- new ConditionalAction("`instruction_bit_recycle(ondeck) && `instruction_count(ondeck)!=1 && `instruction_count(ondeck)!=0",
+ new ConditionalAction("`instruction_bit_requeue(ondeck) && `instruction_count(ondeck)!=1 && `instruction_count(ondeck)!=0",
new AssignAction(instruction_count_ififo_in, instruction_count_ondeck+"-1")),
- new ConditionalAction("`instruction_bit_recycle(ondeck) && `instruction_count(ondeck)!=1", ififo_in),
- new ConditionalAction("!`instruction_bit_recycle(ondeck) && `instruction_count(ondeck)!=1", doRepeat.doFill()),
+ new ConditionalAction("`instruction_bit_requeue(ondeck) && `instruction_count(ondeck)!=1", ififo_in),
+ new ConditionalAction("!`instruction_bit_requeue(ondeck) && `instruction_count(ondeck)!=1", doRepeat.doFill()),
new ConditionalAction("`instruction_count(ondeck)==0", new AssignAction(repcount, "0")),
new ConditionalAction("`instruction_count(ondeck)!=0", new AssignAction(repcount, instruction_count_ondeck+"-1")),
+ new ConditionalAction("`instruction_is_literal(ondeck)", new AssignAction(data_latch, "`instruction_literal(ondeck)")),
new ConditionalAction("`instruction_bit_datain(ondeck)", data_in),
new ConditionalAction("`instruction_bit_dataout(ondeck)", data_out),
new ConditionalAction("`instruction_bit_tokenin(ondeck)", token_in),
- new ConditionalAction("`instruction_bit_tokenout(ondeck)", token_out),
+ new ConditionalAction("`instruction_bit_tokenout(ondeck) && (!`instruction_bit_tokenoutlast(ondeck) || `instruction_count(ondeck)==1)",
+ token_out),
new ConditionalAction("`instruction_bit_latch(ondeck)", new AssignAction(data_latch, data_latch_input)),
new ConditionalAction("`instruction_bit_tokenout(ondeck)",
new AssignAction(new SimpleAssignable("`packet_dest("+token_out.getName()+")"),
);
PrintWriter pw = new PrintWriter(new OutputStreamWriter(new FileOutputStream(prefix+"/"+name+".v")));
- pw.println("`define instruction_bit_tokenout(instruction) instruction["+OFFSET_TO+"]");
- pw.println("`define instruction_bit_dataout(instruction) instruction["+OFFSET_DO+"]");
- pw.println("`define instruction_bit_latch(instruction) instruction["+OFFSET_DL+"]");
- pw.println("`define instruction_bit_datain(instruction) instruction["+OFFSET_DI+"]");
- pw.println("`define instruction_bit_tokenin(instruction) instruction["+OFFSET_TI+"]");
- pw.println("`define instruction_bit_recycle(instruction) instruction["+OFFSET_RQ+"]");
pw.println("`define instruction_bit_dest(instruction) instruction["+(OFFSET_DEST+WIDTH_DEST_ADDR-1)+":"+OFFSET_DEST+"]");
pw.println("`define instruction_count(instruction) instruction["+(OFFSET_COUNT+WIDTH_COUNT-1)+":"+OFFSET_COUNT+"]");
- pw.println("`define instruction_is_kill(i) (`instruction_bit_latch(i) && (!(`instruction_bit_datain(i))))");
- pw.println("`define instruction_is_literal(i) (`instruction_bit_tokenout(i) && `instruction_bit_tokenin(i) && !`instruction_bit_dataout(i))");
- pw.println("`define instruction_literal(i) i["+(OFFSET_LITERAL+WIDTH_LITERAL-1)+":"+OFFSET_LITERAL+"]");
- pw.println("`define instruction_bit_kill_only_standing(i) (`instruction_bit_tokenin(i))");
- pw.println("`define instruction_is_clog(instruction) (`instruction_count(instruction)==0 && !`instruction_bit_tokenin(instruction) && !`instruction_bit_datain(instruction) && !`instruction_bit_tokenout(instruction) && !`instruction_bit_dataout(instruction))");
- pw.println("`define instruction_is_unclog(instruction) (`instruction_bit_kill_only_standing(instruction) && `instruction_is_kill(instruction))");
+ pw.println("`define instruction_is_literal(i) (i["+(OFFSET_MASK_LITERAL+WIDTH_MASK_LITERAL-1)+":"+OFFSET_MASK_LITERAL+"]=="+MASK_LITERAL+")");
+ pw.println("`define instruction_is_kill(i) (i["+(OFFSET_MASK_KILL+WIDTH_MASK_KILL-1)+":"+OFFSET_MASK_KILL+"]=="+MASK_KILL+")");
+ pw.println("`define instruction_is_unclog(i) (i["+(OFFSET_MASK_UNCLOG+WIDTH_MASK_UNCLOG-1)+":"+OFFSET_MASK_UNCLOG+"]=="+MASK_UNCLOG+")");
+ pw.println("`define instruction_is_clog(i) (i["+(OFFSET_MASK_CLOG+WIDTH_MASK_CLOG-1)+":"+OFFSET_MASK_CLOG+"]=="+MASK_CLOG+")");
+ pw.println("`define instruction_is_normal(i) (i["+(OFFSET_MASK_NORMAL+WIDTH_MASK_NORMAL-1)+":"+OFFSET_MASK_NORMAL+"]=="+MASK_NORMAL+")");
+ pw.println("`define instruction_bit_requeue(instruction) (instruction["+OFFSET_RQ+"] || `instruction_is_literal(instruction))");
+
+ pw.println("`define instruction_bit_tokenout(i) (!`instruction_is_literal(i) && i["+OFFSET_TO+"])");
+ pw.println("`define instruction_bit_tokenoutlast(i) (!`instruction_is_literal(i) && i["+OFFSET_IG+"])");
+ pw.println("`define instruction_bit_dataout(i) (!`instruction_is_literal(i) && i["+OFFSET_DO+"])");
+ pw.println("`define instruction_bit_latch(i) (!`instruction_is_literal(i) && i["+OFFSET_DL+"])");
+ pw.println("`define instruction_bit_datain(i) (!`instruction_is_literal(i) && i["+OFFSET_DI+"])");
+ pw.println("`define instruction_bit_tokenin(i) (!`instruction_is_literal(i) && i["+OFFSET_TI+"])");
+
+ int signextbits = WIDTH_WORD - WIDTH_LITERAL;
+ pw.println("`define instruction_literal(i) {{ "+signextbits+"{i["+(OFFSET_LITERAL+WIDTH_LITERAL-1)+"]}},"+
+ " i["+(OFFSET_LITERAL+WIDTH_LITERAL-1)+":"+OFFSET_LITERAL+"]}");
box.dump(pw);
pw.flush();
return box;
import edu.berkeley.fleet.api.*;
import edu.berkeley.fleet.*;
import java.io.*;
-import static edu.berkeley.fleet.ies44.BitManipulations.*;
+import static edu.berkeley.fleet.util.BitManipulations.*;
public abstract class InstructionEncoder {
- public static final int WIDTH_WORD = 37; /* word width */
- public static final int WIDTH_CODEBAG_SIZE = 6;
- public static final int WIDTH_PUMP_ADDR = 11;
- public static final int WIDTH_DEST_ADDR = 11;
- public static final int WIDTH_COUNT = 7;
-
- public static final int OFFSET_COUNT = 0;
- public static final int OFFSET_DEST = OFFSET_COUNT+WIDTH_COUNT;
- public static final int OFFSET_CONTROL = OFFSET_DEST+WIDTH_DEST_ADDR;
- public static final int OFFSET_RQ = OFFSET_CONTROL+0;
- //public static final int OFFSET_IG =
- public static final int OFFSET_TO = OFFSET_CONTROL+1;
- public static final int OFFSET_DO = OFFSET_CONTROL+2;
- public static final int OFFSET_DL = OFFSET_CONTROL+3;
- public static final int OFFSET_DI = OFFSET_CONTROL+4;
- public static final int OFFSET_TI = OFFSET_CONTROL+5;
- public static final int OFFSET_PUMP_ADDR = OFFSET_TI+2;
-
- public static final int OFFSET_LITERAL = OFFSET_COUNT;
- public static final int WIDTH_LITERAL = WIDTH_COUNT+WIDTH_DEST_ADDR;
+ public static final int WIDTH_WORD = 37; /* word width */
+ public static final int WIDTH_CODEBAG_SIZE = 6;
+ public static final int WIDTH_PUMP_ADDR = 11;
+ public static final int WIDTH_DEST_ADDR = 11;
+ public static final int WIDTH_COUNT = 7;
+
+ public static final int OFFSET_MASK_LITERAL = 24;
+ public static final int WIDTH_MASK_LITERAL = 2;
+ public static final int MASK_LITERAL = 1;
+
+ public static final int OFFSET_MASK_KILL = 21;
+ public static final int WIDTH_MASK_KILL = 5;
+ public static final int MASK_KILL = 5;
+
+ public static final int OFFSET_MASK_UNCLOG = 21;
+ public static final int WIDTH_MASK_UNCLOG = 5;
+ public static final int MASK_UNCLOG = 2;
+
+ public static final int OFFSET_MASK_CLOG = 21;
+ public static final int WIDTH_MASK_CLOG = 5;
+ public static final int MASK_CLOG = 4;
+
+ public static final int OFFSET_MASK_NORMAL = 25;
+ public static final int WIDTH_MASK_NORMAL = 1;
+ public static final int MASK_NORMAL = 1;
+
+ public static final int OFFSET_COUNT = 0;
+ public static final int OFFSET_DEST = OFFSET_COUNT+WIDTH_COUNT;
+ public static final int OFFSET_CONTROL = OFFSET_DEST+WIDTH_DEST_ADDR;
+ public static final int OFFSET_RQ = OFFSET_CONTROL+0;
+ public static final int OFFSET_IG = OFFSET_CONTROL+1;
+ public static final int OFFSET_TO = OFFSET_CONTROL+2;
+ public static final int OFFSET_DO = OFFSET_CONTROL+3;
+ public static final int OFFSET_DL = OFFSET_CONTROL+4;
+ public static final int OFFSET_DI = OFFSET_CONTROL+5;
+ public static final int OFFSET_TI = OFFSET_CONTROL+6;
+ public static final int OFFSET_INSTRUCTIONTYPE = OFFSET_CONTROL+7;
+ public static final int OFFSET_PUMP_ADDR = OFFSET_INSTRUCTIONTYPE+1;
+
+ public static final int OFFSET_LITERAL = OFFSET_COUNT+WIDTH_COUNT;
+ public static final int WIDTH_LITERAL = OFFSET_MASK_LITERAL - OFFSET_LITERAL;
/** get the bits describing this box's location on the DESTINATION HORN */
protected abstract long getDestAddr(Destination box);
}
}
- public Instruction readInstruction(long instr) {
- long inst = instr;
- switch((int)getField(WIDTH_WORD-1, WIDTH_WORD-2, inst)) {
- case 0: {
- Pump name = getBoxByInstAddr(getIntField(OFFSET_PUMP_ADDR+WIDTH_PUMP_ADDR-1, OFFSET_PUMP_ADDR, inst));
- Destination dest = getDestByAddr (getIntField(OFFSET_DEST+WIDTH_DEST_ADDR-1, OFFSET_DEST, inst));
- int count = getIntField( OFFSET_COUNT+WIDTH_COUNT-1, OFFSET_COUNT, inst);
- boolean tokenIn = getBit(OFFSET_TI, instr);
- boolean dataIn = getBit(OFFSET_DI, instr);
- boolean latch = getBit(OFFSET_DL, instr);
- boolean dataOut = getBit(OFFSET_DO, instr);
- boolean tokenOut = getBit(OFFSET_TO, instr);
- boolean requeue = getBit(OFFSET_RQ, instr);
- boolean dataOutDest = dataOut && tokenOut;
- boolean isLiteral = tokenIn && tokenOut && !dataOutDest;
- if (isLiteral)
- return new Instruction.LocalLiteral(name, getIntField(OFFSET_LITERAL+WIDTH_LITERAL-1, OFFSET_LITERAL, inst));
- if (latch & !dataIn) return new Instruction.Kill(name, count, tokenIn);
- return new Instruction.Executable(name, dest, count, tokenIn, dataIn, latch, dataOutDest,
- dataOut, tokenOut, requeue);
- }
- /*
- case 1: {
- Destination name = getDestByAddr(getField(WIDTH_WORD-3, WIDTH_WORD-3-WIDTH_DEST_ADDR+1, inst));
- long offset = getSignedField(WIDTH_WORD-3-WIDTH_DEST_ADDR, WIDTH_CODEBAG_SIZE, instr);
- long size = getSignedField(WIDTH_CODEBAG_SIZE-1, 0, instr);
- return new Instruction.Literal.CodeBagDescriptor(name, offset, size);
- }
- */
- case 2: {
- Destination name = getDestByAddr(getField(WIDTH_WORD-3, WIDTH_WORD-3-WIDTH_PUMP_ADDR+1, inst));
- return new Instruction.Literal.Absolute(name, getSignedField(WIDTH_WORD-3-WIDTH_PUMP_ADDR, 0, instr));
- }
-
- case 3: {
- Destination name = getDestByAddr(getField(WIDTH_WORD-3, WIDTH_WORD-3-WIDTH_PUMP_ADDR+1, inst));
- return new Instruction.Literal.Relative(name, getSignedField(WIDTH_WORD-3-WIDTH_PUMP_ADDR, 0, instr));
- }
-
- }
- return null;
-
+ public Instruction readInstruction(long inst) {
+ Pump name = getBoxByInstAddr(getIntField(OFFSET_PUMP_ADDR+WIDTH_PUMP_ADDR-1, OFFSET_PUMP_ADDR, inst));
+ Destination dest = getDestByAddr (getIntField(OFFSET_DEST+WIDTH_DEST_ADDR-1, OFFSET_DEST, inst));
+ int count = getIntField( OFFSET_COUNT+WIDTH_COUNT-1, OFFSET_COUNT, inst);
+ boolean tokenIn = getBit(OFFSET_TI, inst);
+ boolean dataIn = getBit(OFFSET_DI, inst);
+ boolean latch = getBit(OFFSET_DL, inst);
+ boolean dataOut = getBit(OFFSET_DO, inst);
+ boolean tokenOut = getBit(OFFSET_TO, inst);
+ boolean requeue = getBit(OFFSET_RQ, inst);
+ boolean ignoreUntilLast = getBit(OFFSET_IG, inst);
+ boolean dataOutDest = dataOut && tokenOut;
+ boolean isLiteral = getIntField(OFFSET_MASK_LITERAL+WIDTH_MASK_LITERAL-1, OFFSET_MASK_LITERAL, inst)==MASK_LITERAL;
+ if (isLiteral)
+ return new Instruction.LocalLiteral(name, getIntField(OFFSET_LITERAL+WIDTH_LITERAL-1, OFFSET_LITERAL, inst), count);
+ if (latch & !dataIn && !tokenIn && !dataOut && !tokenOut) return new Instruction.Clog(name);
+ if (latch & !dataIn && tokenIn) return new Instruction.UnClog(name);
+ if (latch & !dataIn) return new Instruction.Kill(name, count);
+ return new Instruction.Executable(name, dest, count, tokenIn, dataIn, latch, dataOutDest,
+ dataOut, tokenOut, requeue, ignoreUntilLast);
}
public long writeInstruction(Instruction d) {
long instr = 0;
- // Kill is encoded as Execute with the illegal combination (Latch & ~DataIn)
- if (d instanceof Instruction.Kill) {
- Instruction.Kill k = (Instruction.Kill)d;
- d = new Instruction.Executable(k.pump, null, k.count, k.killOnlyStandingInstructions,
- false, true, false, false, false, false);
- }
+ if (d.pump != null)
+ instr |= putField(OFFSET_PUMP_ADDR+WIDTH_PUMP_ADDR-1, OFFSET_PUMP_ADDR, getBoxInstAddr(d.pump));
- if (d instanceof Instruction.Literal.CodeBagDescriptor) {
- Instruction.Literal.CodeBagDescriptor lc = (Instruction.Literal.CodeBagDescriptor)d;
- d = new Instruction.LocalLiteral(lc.pump, ((lc.offset << WIDTH_CODEBAG_SIZE)) | lc.size);
+ if (d instanceof Instruction.CodeBagDescriptor) {
+ Instruction.CodeBagDescriptor lc = (Instruction.CodeBagDescriptor)d;
+ d = new Instruction.LocalLiteral(lc.pump, ((lc.offset << WIDTH_CODEBAG_SIZE)) | lc.size, 1);
}
- if (d instanceof Instruction.LocalLiteral) {
+ if (d instanceof Instruction.UnClog) {
+ instr |= putField(OFFSET_MASK_UNCLOG+WIDTH_MASK_UNCLOG-1, OFFSET_MASK_UNCLOG, MASK_UNCLOG);
+
+ } else if (d instanceof Instruction.Kill) {
+ Instruction.Kill k = (Instruction.Kill)d;
+ instr |= putField(OFFSET_MASK_KILL+WIDTH_MASK_KILL-1, OFFSET_MASK_KILL, MASK_KILL);
+ instr |= putField(OFFSET_COUNT+WIDTH_COUNT-1, OFFSET_COUNT, k.count);
+
+ } else if (d instanceof Instruction.Clog) {
+ instr |= putField(OFFSET_MASK_CLOG+WIDTH_MASK_CLOG-1, OFFSET_MASK_CLOG, MASK_CLOG);
+
+ } else if (d instanceof Instruction.LocalLiteral) {
Instruction.LocalLiteral inst = (Instruction.LocalLiteral)d;
if (inst.pump != null) {
- instr |= putField(OFFSET_PUMP_ADDR+WIDTH_PUMP_ADDR-1, OFFSET_PUMP_ADDR, getBoxInstAddr(inst.pump));
- instr |= putField(OFFSET_TI, OFFSET_TI, 1);
- instr |= putField(OFFSET_TO, OFFSET_TO, 1);
- instr |= putField(OFFSET_LITERAL+WIDTH_LITERAL-1, OFFSET_LITERAL, inst.literal);
+ instr |= putField(OFFSET_MASK_LITERAL+WIDTH_MASK_LITERAL-1, OFFSET_MASK_LITERAL, MASK_LITERAL);
+ instr |= putSignedField(OFFSET_LITERAL+WIDTH_LITERAL-1, OFFSET_LITERAL, inst.literal);
+ instr |= putField(OFFSET_COUNT+WIDTH_COUNT-1, OFFSET_COUNT, inst.count);
} else {
instr = inst.literal;
}
} else if (d instanceof Instruction.Executable) {
Instruction.Executable inst = (Instruction.Executable)d;
- instr |= putField(OFFSET_PUMP_ADDR+WIDTH_PUMP_ADDR-1, OFFSET_PUMP_ADDR, getBoxInstAddr(inst.pump));
+ instr |= putField(OFFSET_MASK_NORMAL+WIDTH_MASK_NORMAL-1, OFFSET_MASK_NORMAL, MASK_NORMAL);
instr |= putField(OFFSET_DEST+WIDTH_DEST_ADDR-1, OFFSET_DEST, inst.dest==null?0:getDestAddr(inst.dest));
instr |= putField(OFFSET_COUNT+WIDTH_COUNT-1, OFFSET_COUNT, inst.count);
instr |= putField(OFFSET_TI, OFFSET_TI, inst.tokenIn?1:0);
instr |= putField(OFFSET_DO, OFFSET_DO, (inst.dataOutDest||inst.dataOut)?1:0);
instr |= putField(OFFSET_TO, OFFSET_TO, (inst.dataOutDest||inst.tokenOut)?1:0);
instr |= putField(OFFSET_RQ, OFFSET_RQ, inst.requeue?1:0);
+ instr |= putField(OFFSET_IG, OFFSET_IG, inst.ignoreUntilLast?1:0);
}
return instr;
InterpreterPump sourcePump = (InterpreterPump)(((Instruction.Executable)i).pump);
((InstructionPump)sourcePump).addInstruction(((Instruction.Executable)i));
- } else if (i instanceof Instruction.Literal.CodeBagDescriptor) {
- Instruction.Literal.CodeBagDescriptor cbd = (Instruction.Literal.CodeBagDescriptor)i;
+ } else if (i instanceof Instruction.CodeBagDescriptor) {
+ Instruction.CodeBagDescriptor cbd = (Instruction.CodeBagDescriptor)i;
long absolute_cbd = ((cbd.offset+address) << 6) | cbd.size;
throw new RuntimeException();
//new Packet(this, null, (int)absolute_cbd, (InterpreterDestination)cbd.pump).send();
- } else if (i instanceof Instruction.Literal.Absolute) {
- new Packet(this, null,
- (int)((Instruction.Literal.Absolute)i).value,
- (InterpreterDestination)(((Instruction.Literal.Absolute)i).dest)).send();
-
+ } else if (i instanceof Instruction.UnClog) {
+ //FIXME
} else if (i instanceof Instruction.Kill) {
InterpreterPump pump = (InterpreterPump)(((Instruction.Kill)i).pump);
- ((InstructionPump)pump).kill(((Instruction.Kill)i).count,
- ((Instruction.Kill)i).killOnlyStandingInstructions);
+ ((InstructionPump)pump).kill(((Instruction.Kill)i).count, false);
+
} else {
throw new Error("unsupported: " + i.getClass().getName());
import edu.berkeley.sbp.util.ANSI;
import edu.berkeley.fleet.api.*;
import edu.berkeley.fleet.ies44.*;
+import edu.berkeley.fleet.util.*;
import edu.berkeley.fleet.api.Instruction;
public class Outbox extends InstructionPump {
// 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,
register);
dest = (InterpreterDestination)(((Interpreter)getInterpreter()).iie.getDestByAddr(bits));
+ throw new RuntimeException();
}
new Packet(getInterpreter(), this, register, dest).send();
if (instruction.tokenOut)
-package edu.berkeley.fleet.ies44;
+package edu.berkeley.fleet.util;
import edu.berkeley.fleet.api.*;
import edu.berkeley.fleet.*;
import java.io.*;
+/** useful functions for manipulating bit fields within longs */
public class BitManipulations {
public static boolean getBit(int bit, long val) { return ((val & (1L << bit)) != 0); }
public static long getSignedField(int highBit, int lowBit, long val) {
-#skip
#expect -1
#ship debug : Debug
debug.in:
-// literal -1;
+ literal -1;
deliver;
fifo2.out: wait, take, sendto fifo.in;
fifo.out:
- [*] nop;
+ clog;
notify fifo2.out;
take, sendto debug.in;
take, sendto debug.in;
- kill*;
- kill*;
+ unclog;
+ unclog;
+
--- /dev/null
+// expected output
+#expect 2
+
+// ships required in order to run this code
+#ship debug : Debug
+#ship fifo : Fifo
+
+fifo.in:
+ literal 3; [3] deliver;
+ literal 2; [3] deliver;
+
+fifo.out:
+ clog;
+ (9) take, sendto debug.in;
+ (3) notifyLast debug.in;
+ unclog;
+
+debug.in:
+ [4] wait;
+ [*] take, deliver;
+
fifo.out: [*] take, sendto debug.in;
debug.in:
- [*] nop;
+ clog;
(2) take;
(3) deliver;
- kill*;
+ unclog;
--- /dev/null
+#expect 5
+#expect 9
+#expect 5
+#expect 9
+#expect 5
+#expect 9
+
+#ship fifo : Fifo
+#ship debug : Debug
+
+fifo.in:
+ literal 9;
+ [6] deliver;
+
+debug.in:
+ [*] take, deliver;
+
+fifo.out:
+ clog;
+ (3) literal 5;
+ (3) sendto debug.in;
+ (3) take;
+ (3) sendto debug.in;
+ unclog;
+
+
+
f.out: take, sendto alu.in1;
take, sendto alu.in2;
-alu.in1: [*] nop;
+alu.in1: clog;
(*) take, deliver;
(*) deliver;
(*) dismiss;
(4) deliver;
- kill*;
+ unclog;
alu.in2: take;
[*] deliver;
alu.inOp: literal Alu2.inOp[ADD];
[*] deliver;
-alu.out: [*] nop;
+alu.out: clog;
(40) take, sendto alu.in1;
(50) sendto debug.in;
- kill*;
+ unclog;
debug.in: [*] take, deliver;