#skip
#ship debug : Debug
#expect 0
-0: sendto debug.in;
== Contributors =========================================================
Adam Megacz <megacz@cs.berkeley.edu>
#skip
#ship debug : Debug
#expect 0
-0: sendto debug.in;
+
== Contributors =========================================================
Adam Megacz <megacz@cs.berkeley.edu>
`input(stride_r, stride_a, stride_a_, [(`DATAWIDTH-1):0], stride_d)
`input(count_r, count_a, count_a_, [(`DATAWIDTH-1):0], count_d)
`output(out_r, out_r_, out_a, [(`DATAWIDTH-1):0], out_d_)
- //`defreg(out_d_, [(`DATAWIDTH-1):0], out_d)
-
`input(preload_r, preload_a, preload_a_, [(`DATAWIDTH-1):0], preload_d)
`input(cbd_r, cbd_a, cbd_a_, [(`DATAWIDTH-1):0], cbd_d)
`output(ihorn_r, ihorn_r_, ihorn_a, [(`PACKET_WIDTH-1):0], ihorn_d_)
end else if (command_valid) begin
command_valid <= 0;
command = ramread;
- case (command[(`INSTRUCTION_WIDTH-1):(`INSTRUCTION_WIDTH-2)])
- 0: begin
- ihorn_full <= 1;
- `packet_data(ihorn_d) <= `instruction_data(command);
- `packet_dest(ihorn_d) <= `instruction_dest(command);
- end
- 1: begin
- dhorn_full <= 1;
- temp = command[(`INSTRUCTION_WIDTH-(2+`DESTINATION_ADDRESS_BITS)):0];
- temp = temp + ( { current_instruction_read_from, {(`CODEBAG_SIZE_BITS){1'b0}} });
- data[(`DATAWIDTH-1):(`CODEBAG_SIZE_BITS)] = temp;
- data[(`CODEBAG_SIZE_BITS-1):0] = command[(`CODEBAG_SIZE_BITS-1):0];
- `packet_data(dhorn_d) <= temp;
- `packet_dest(dhorn_d) <=
- command[(`INSTRUCTION_WIDTH-3):(`INSTRUCTION_WIDTH-(3+`DESTINATION_ADDRESS_BITS)+1)];
- end
- 2: begin
- dhorn_full <= 1;
- `packet_data(dhorn_d) <= { {(`DATAWIDTH-24){command[23]}}, command[23:0] };
- `packet_dest(dhorn_d) <= command[34:24];
- end
- 3: begin
- dhorn_full <= 1;
- `packet_data(dhorn_d) <= { {(`DATAWIDTH-24){command[23]}}, command[23:0] } + current_instruction_read_from;
- `packet_dest(dhorn_d) <= command[34:24];
- end
- endcase
+ ihorn_full <= 1;
+ `packet_data(ihorn_d) <= `instruction_data(command);
+ `packet_dest(ihorn_d) <= `instruction_dest(command);
+ end
end else if (cbd_pos < cbd_size) begin
current_instruction_read_from <= cbd_base+cbd_pos;
// instructions not in any codebag are part of the "root codebag"
// which is dispatched when the code is loaded
-BOB: sendto memory.inCBD;
-memory.inCBD: [*] take, deliver;
-debug.in: [*] take, deliver;
-
-
-// This codebag illustrates how to do a loop. Notice that this
-// is actually an uncontrolled data emitter -- it could clog the
-// switch fabric!
+memory.inCBD:
+ literal BOB;
+ deliver;
BOB: {
- 12: sendto debug.in;
- 13: sendto debug.in;
- 14: sendto debug.in;
+ debug.in:
+ literal 12; deliver;
+ literal 13; deliver;
+ literal 14; deliver;
}
return "(@"+offset+"): sendto " + dest;
}
}
+ }
- public static class CodeBagDescriptor extends Literal {
- /** address of CBD, relative to address that this instruction was loaded from */
- public final long offset;
- public final long size;
- public CodeBagDescriptor(Destination dest, long offset, long size) {
- super(dest); this.offset = offset; this.size = size; }
- public String toString() {
- String off = ""+offset;
- if (offset > 0) off = "+"+off;
- return "(CBD @"+off+"+"+size+"): 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;
+ this.offset = offset;
+ this.size = size;
+ }
+ public String toString() {
+ String off = ""+offset;
+ if (offset > 0) off = "+"+off;
+ return "(CBD @"+off+"+"+size+"): sendto " + pump;
}
}
+
}
if (inst instanceof Instruction.Literal.CodeBagDescriptor) {
dos.flush();
Instruction.Literal.CodeBagDescriptor old = (Instruction.Literal.CodeBagDescriptor)inst;
- int offset = codeBagMap[(int)old.offset] - count;
- inst = new Instruction.Literal.CodeBagDescriptor(old.dest,
+ int offset = codeBagMap[(int)old.offset];// - count;
+ inst = new Instruction.Literal.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));
}
fleet.writeInstruction(dos, inst);
count++;
}
Pump pump(Tree<String> t) {
- if (!"Port".equals(t.head()) && !"SubPort".equals(t.head()) && !"ShipSpecificLiteral".equals(t.head())) return null;
+ if (!"Port".equals(t.head()) && !"SubPort".equals(t.head()) && !"ShipSpecificLiteral".equals(t.head()))
+ throw new RuntimeException(t+"");
String shipName = name(t.child(0));
String portName = name(t.child(1));
Ship ship = shipMap.get(shipName);
for(Tree<String> statement : t.child(1))
fillCodeBag(statement, cb2);
- } else if (t.head().equals("ShipSpecificLiteral")) {
- long literal = parseSSL(t.child(0));
- cb.add(new Instruction.Literal.Absolute(portReference(t.child(1)), literal));
-
- } else if (t.head().equals("Literal")) {
- long literal = Long.parseLong(string(t.child(0)));
- cb.add(new Instruction.Literal.Absolute(portReference(t.child(1)), literal));
-
- } else if (t.head().equals("CodeBagDescriptor")) {
- String refname = name(t.child(0).child(0));
- CodeBag cb2 = getCodeBag(refname);
- cb.add(new Instruction.Literal.CodeBagDescriptor(portReference(t.child(1)), cb2.getFakeAddress(), 0));
-
} else if (t.head().equals("Fiber")) {
Pump pump = (Pump)pump(t.child(0));
else if ("Take".equals(ttt.head())) { dataIn = true; latch = true; }
else if ("SendTo".equals(ttt.head())) { dataOut = true; dest = portReference(ttt.child(0)); }
else if ("LocalLiteral".equals(ttt.head())) { localLiteral = true; literal = Long.parseLong(string(ttt.child(0))); }
- else if ("LocalLiteralConst".equals(ttt.head())) {
+ 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));
+ continue OUTER;
+ } else if ("LocalLiteralConst".equals(ttt.head())) {
localLiteral = true;
literal = parseSSL(ttt.child(0));
}
private class CodeBag extends ArrayList<Instruction> {
public long address = -1;
- public CodeBag() { codeBags.add(this); }
- public CodeBag(String name) { this(); codeBagsByName.put(name, this); }
+ public final String name;
+ public CodeBag() { codeBags.add(this); this.name = "root"; }
+ public CodeBag(String name) { codeBags.add(this); codeBagsByName.put(name, this); this.name = name; }
public long getFakeAddress() { return codeBags.indexOf(this); }
public boolean equals(Object o) { return this==o; }
}
| Program:: ("":: Directive+/ws) ws! CodeBagBody
Statement = Fiber:: Source ":" ("":: Instruction +/ ws) /ws
- | Literal:: int ":" "sendto" Port ";" /ws
- | ShipSpecificLiteral:: SSL ":" "sendto" Port ";" /ws
- | CodeBagDescriptor:: CodeBag ":" "sendto" Port ";" /ws
| NamedCodeBag:: name ":" "{" CodeBagBody "}" /ws
CountField = Brack:: "[" int "]"
| Deliver:: "deliver"
| LocalLiteral:: "literal" ws! int
| LocalLiteralConst:: "literal" ws! SSL
+ | LocalLiteralCodeBag:: "literal" ws! CodeBag
| Ack:: "notify" ws! Port
Source = Port
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));
d = new Instruction.Executable(k.pump, null, k.count, k.killOnlyStandingInstructions,
false, true, false, false, false, false);
}
+
+ 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.LocalLiteral) {
Instruction.LocalLiteral inst = (Instruction.LocalLiteral)d;
- 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);
+ 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);
+ } else {
+ instr = inst.literal;
+ }
} else if (d instanceof Instruction.Executable) {
Instruction.Executable inst = (Instruction.Executable)d;
instr |= putField(OFFSET_TO, OFFSET_TO, (inst.dataOutDest||inst.tokenOut)?1:0);
instr |= putField(OFFSET_RQ, OFFSET_RQ, inst.requeue?1:0);
- } else if (d instanceof Instruction.Literal.CodeBagDescriptor) {
- Instruction.Literal.CodeBagDescriptor lc = (Instruction.Literal.CodeBagDescriptor)d;
- instr = putField(WIDTH_WORD-1, WIDTH_WORD-2, 1);
- if (lc.dest != null) instr |= putField(WIDTH_WORD-3, WIDTH_WORD-3-WIDTH_DEST_ADDR+1, getDestAddr(lc.dest));
- instr |= putSignedField(WIDTH_WORD-3-WIDTH_DEST_ADDR, WIDTH_CODEBAG_SIZE, lc.offset);
- instr |= putField(WIDTH_CODEBAG_SIZE-1, 0, lc.size);
-
- } else if (d instanceof Instruction.Literal.Absolute) {
- Instruction.Literal.Absolute ld = (Instruction.Literal.Absolute)d;
- instr = putField(WIDTH_WORD-1, WIDTH_WORD-2, 2);
- instr |= putField(WIDTH_WORD-3, WIDTH_WORD-3-WIDTH_DEST_ADDR+1, getDestAddr(ld.dest));
- instr |= putSignedField(WIDTH_WORD-3-WIDTH_DEST_ADDR, 0, ld.value);
-
- } else if (d instanceof Instruction.Literal.Relative) {
- Instruction.Literal.Relative lr = (Instruction.Literal.Relative)d;
- instr = putField(WIDTH_WORD-1, WIDTH_WORD-2, 3);
- instr |= putField(WIDTH_WORD-3, WIDTH_WORD-3-WIDTH_DEST_ADDR+1, getDestAddr(lr.dest));
- instr |= putSignedField(WIDTH_WORD-3-WIDTH_DEST_ADDR, 0, lr.offset);
-
}
return instr;
}
} else if (i instanceof Instruction.Literal.CodeBagDescriptor) {
Instruction.Literal.CodeBagDescriptor cbd = (Instruction.Literal.CodeBagDescriptor)i;
long absolute_cbd = ((cbd.offset+address) << 6) | cbd.size;
- new Packet(this, null, (int)absolute_cbd, (InterpreterDestination)cbd.dest).send();
+ 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,
fifo.in: [*] take, deliver;
// addresses and values to initialize the memory with
-1: sendto memory.inAddrWrite;
-4: sendto memory.inCount;
-1: sendto memory.inStride;
-11: sendto memory.inDataWrite;
-12: sendto memory.inDataWrite;
-13: sendto memory.inDataWrite;
-14: sendto memory.inDataWrite;
+//1: sendto memory.inAddrWrite;
+//4: sendto memory.inCount;
+//1: sendto memory.inStride;
+//11: sendto memory.inDataWrite;
+//12: sendto memory.inDataWrite;
+//13: sendto memory.inDataWrite;
+//14: sendto memory.inDataWrite;
// send write-completion tokens to the fifo output
memory.out:
take, sendto memory.inAddrRead;
// read addresses
-4: sendto fifo.in;
-4: sendto memory.inCount;
--1: sendto memory.inStride;
+//4: sendto fifo.in;
+//4: sendto memory.inCount;
+//-1: sendto memory.inStride;
// output ///////////////////////////////////////////////////////////////////
-#expect 5263440
+#expect 5263
// program //////////////////////////////////////////////////////////////////
#ship debug : Debug
memory.inAddrRead: [*] take, deliver;
memory.inAddrWrite: [*] take, deliver;
memory.inDataWrite: [*] take, deliver;
-bitfifo.in: [*] take, deliver;
-bitfifo.inOp: [*] take, deliver;
-bitfifo.outOp: [*] take, deliver;
FRED: {
- fifo.in: take, deliver, notify fifo.out;
+ fifo.in: deliver, notify fifo.out;
}
-5263440: sendto fifo.in;
+
+fifo.in: literal 5263;
fifo.out: wait, take, sendto debug.in;
-0: sendto bitfifo.in; // six bits of leading zero (to wash out the codebag size)
-FRED: sendto bitfifo.in; // FRED = { address_of_fred[31], size_of_fred[6] }
+bitfifo.in:
+ literal 0; deliver; // six bits of leading zero (to wash out the codebag size)
+ literal FRED; deliver; // FRED = { address_of_fred[31], size_of_fred[6] }
// strip off bottom 6 bits
-BitFifo.inOp[take=6]: sendto bitfifo.inOp;
-BitFifo.inOp[take=37]: sendto bitfifo.inOp;
-BitFifo.outOp[take=37]: sendto bitfifo.outOp;
+bitfifo.inOp:
+ literal BitFifo.inOp[take=6]; deliver;
+ literal BitFifo.inOp[take=37]; deliver;
+bitfifo.outOp:
+ literal BitFifo.outOp[take=37]; deliver;
+
bitfifo.out: take, sendto memory.inAddrRead;
// value read out will be the instruction at FRED
f.out: take, sendto alu.in1;
take, sendto alu.in2;
-Alu2.inOp[ADD]: sendto alu.inOp;
alu.in1: [*] nop;
(*) take, deliver;
(*) deliver;
kill*;
alu.in2: take;
[*] deliver;
-alu.inOp: take;
+alu.inOp: literal Alu2.inOp[ADD];
[*] deliver;
alu.out: [*] nop;
(40) take, sendto alu.in1;