remote_run += ./a.out /dev/selectmap1 fleet.bin
runfpga: fleet.jar build/main.bit
- $(java) $(cp) $(interpreter_class) --dump-code < contrib/demo.fleet
+ $(java) $(cp) $(interpreter_class) --dump-code
rsync -zare ssh --progress --verbose build/fleet.bin build/main.bit src/edu/berkeley/fleet/slipway/test.c root@bee441.cs.berkeley.edu:
ssh root@bee441.cs.berkeley.edu '$(remote_run)'
#include "contrib/demo.ships"
-10: sendto alu2.a;
-2: sendto alu2.b;
+debug.data: [*] take, deliver;
+
+1: sendto alu2.a;
+1: sendto alu2.b;
0: sendto alu2.op;
0: sendto alu2.op;
0: sendto alu2.op;
0: sendto alu2.op;
+
alu2.out:
take;
- [2] sendto alu2.a;
- [2] sendto alu2.b;
+ [2] sendto alu2.a;
+ [2] sendto alu2.b;
take, sendto alu2.a;
take, sendto alu2.b;
- take, ack debug.data;
+ take, sendto debug.data;
+
+alu2.op: [*] take, deliver;
+alu2.a: [*] take, deliver;
+alu2.b: [*] take, deliver;
+
#import edu.berkeley.fleet.ships
+#ship alu2 : Alu2
+#ship debug : Debug
+#ship execute : Execute
+#ship fifo : Fifo
+
// alu1
// alu2
// sort2
//#ship alu1 : Alu1
-#ship alu2 : Alu2
-#ship debug : Debug
-#ship execute : Execute
//#ship alu1 : Alu1
//#ship dup1 : Dup
Instruction.Executable inst = (Instruction.Executable)d;
InterpreterBenkoBox dest = resolve(inst.dest);
instr = dest==null ? 0 : (dest.addr << 1);
+ if (inst.count >= (1<<8))
+ throw new RuntimeException("count field must be less than 128");
instr |= (((long)inst.count) << (11+1));
if (inst.tokenIn) instr |= (1L << (11+1+7+0));
if (inst.dataIn) instr |= (1L << (11+1+7+1));
if (inst.latch) instr |= (1L << (11+1+7+2));
if (inst.dataOut) instr |= (1L << (11+1+7+3));
if (inst.tokenOut) instr |= (1L << (11+1+7+4));
+ if (inst.recycle) instr |= (1L);
instr |= ((long)resolve(inst.benkoBox).instr_addr) << (11+5+7+1);
} else if (d instanceof Instruction.Literal.Absolute) {
Instruction.Literal.Absolute ld = (Instruction.Literal.Absolute)d;
instr = (2L << (11+24));
instr |= (resolve(ld.dest).addr) << 24;
+ if (ld.value >= (1<<25))
+ throw new RuntimeException("literals must be less than 2^24");
instr |= ((long)ld.value);
}
for(BenkoBox port : ship.getBenkoBoxes()) {
if (((InterpreterBenkoBox)port).special()) continue;
if (port instanceof Inbox) {
+ /*
if (((InterpreterBenkoBox)port).noInbox())
System.out.print("stupidinbox");
else
- System.out.print("inbox");
+ */
+ System.out.print("inbox");
} else {
System.out.print("outbox");
}
}
public void service() {
- throw new Error("the Execute ship is only for FPGA simulations");
+ //throw new Error("the Execute ship is only for FPGA simulations");
}
}
case (reg_op)
0: out_d = reg_a + reg_b;
1: out_d = reg_a - reg_b;
- //2: out_d = reg_a * reg_b; // will not synthesize
- //3: out_d = reg_a / reg_b; // will not synthesize
- //4: out_d = reg_a % reg_b; // will not synthesize
+ //2: out_d = reg_a * reg_b; // will not synthesize --AM
+ //3: out_d = reg_a / reg_b; // will not synthesize --AM
+ //4: out_d = reg_a % reg_b; // will not synthesize --AM
default: out_d = 0;
endcase
`onwrite(out_r, out_a)
--- /dev/null
+ reg have_instruction;
+ reg have_token;
+ reg have_data;
+ reg send_token;
+ reg send_data;
+ reg parse_instruction;
+ reg do_recycle;
+ reg [(`COUNT_BITS-1):0] kill_count;
+ reg [(`INSTRUCTION_WIDTH-1):0] instruction;
+
+ wire [(`INSTRUCTION_WIDTH-1):0] instr_d2;
+ wire [(`INSTRUCTION_WIDTH-1):0] instr_d0;
+
+ reg kill_r;
+ reg kill_a;
+ reg [(`COUNT_WIDTH-1):0] kill_d;
+
+ reg [(`INSTRUCTION_WIDTH-1):0] kinstruction;
+ reg instr_rx;
+ wire instr_ax;
+ reg ifull;
+
+ always @(posedge clk) begin
+ if (!ifull) begin
+ `onread(instr_r, instr_a)
+ ifull = 1;
+ kinstruction = instr_d;
+ end
+ end else begin
+ if (`instruction_is_kill(kinstruction)) begin
+ kill_d = `instruction_count(kinstruction);
+ `onwrite(kill_r, kill_a)
+ ifull = 0;
+ end
+ end else begin
+ `onwrite(instr_rx, instr_ax)
+ ifull = 0;
+ end
+ end
+ end
+ end
+
+ reg recycle_r;
+ wire recycle_r_;
+ assign recycle_r_ = recycle_r;
+ wire recycle_a;
+ wire [(`INSTRUCTION_WIDTH-1):0] recycle_inst;
+ assign recycle_inst = instruction;
+
+ wire instr_a2_;
+ reg instr_a2;
+ assign instr_a2_ = instr_a2;
+
+ funnel ifunnel(clk, instr_r0, instr_a0, instr_d0,
+ instr_rx, instr_ax, kinstruction,
+ recycle_r_, recycle_a, recycle_inst);
+
+ fifo4 ififo(clk, instr_r0, instr_a0, instr_d0,
+ instr_r2, instr_a2_, instr_d2);
+
+ always @(posedge clk) begin
+
+ if (do_recycle) begin
+ `onwrite(recycle_r, recycle_a)
+ do_recycle = 0;
+ have_instruction = 0;
+ parse_instruction = 0;
+ end
+
+ end else begin
+
+ if (!have_instruction && !parse_instruction) begin
+ `onread(instr_r2, instr_a2)
+ instruction = instr_d2;
+ parse_instruction = 1;
+ end
+ end
+
+ // FIXME: actually don't want to kill partway through an instruction
+ `onread(kill_r, kill_a)
+ kill_count = kill_count + kill_d;
+ end
+
+ if ((parse_instruction || have_instruction) && (kill_count > 0)) begin
+ kill_count = kill_count - 1;
+ have_instruction = 0;
+ parse_instruction = 0;
+ end
+
+ if (parse_instruction) begin
+ have_token = !`instruction_bit_tokenin(instruction);
+ have_data = !`instruction_bit_datain(instruction);
+ `packet_dest(`data_out_d) = `instruction_bit_dest(instruction);
+ send_data = !`instruction_bit_dataout(instruction);
+ send_token = !`instruction_bit_tokenout(instruction);
+ have_instruction = 1;
+ parse_instruction = 0;
+ end
+/*
+ if (!`token_in_r && `token_in_a) `token_in_a = 0;
+ if (!`data_in_r && `data_in_a) `data_in_a = 0;
+ if (`token_out_r && `token_out_a) `token_out_r = 0;
+ if (`data_out_r && `data_out_a) `data_out_r = 0;
+ if (have_instruction &&
+ (have_token || `token_in_r) &&
+ (have_data || `data_in_r) &&
+ (send_data || !`data_out_a) &&
+ (send_token || !`token_out_a) &&
+ ) begin
+ if (!have_token) begin
+ token_in_a = 1;
+ have_token = 1;
+ end
+ if (!have_data) begin
+ data_in_a = 1;
+ have_data = 1;
+ end
+ fire_ok = 1;
+ end
+
+ if (fire_ok) begin
+ if (send_data) begin
+ `onwrite(`data_out_r, `data_out_a)
+ send_data = 0;
+ end
+ end
+ if (send_token) begin
+ `onwrite(`token_out_r, `token_out_a)
+ send_token = 0;
+ end
+ end
+ if (!send_data && !send_token) begin
+ fire_ok = false;
+// die here
+ end
+ end
+*/
+ if (have_instruction && !have_token) begin
+ `onread(`token_in_r, `token_in_a)
+ have_token = 1;
+ end
+ end
+
+ if (have_instruction && !have_data) begin
+ `onread(`data_in_r, `data_in_a)
+ if (`instruction_bit_latch(instruction)) begin
+ `packet_data(`data_out_d) = `data_in_d;
+ end
+ have_data = 1;
+ end
+ end
+
+ if (have_instruction && have_data && have_token) begin
+ // FIXME: add token send on diff port
+ if (!send_data || !send_token) begin
+ `onwrite(`data_out_r, `data_out_a)
+ send_data = 1;
+ send_token = 1;
+ end
+ end
+ end
+
+ if (have_instruction && have_data && have_token && send_data && send_token) begin
+
+ case (`instruction_count(instruction))
+ 0: begin end
+ 1: have_instruction = 0;
+ default: `instruction_count(instruction) = `instruction_count(instruction) - 1;
+ endcase
+
+ if (have_instruction && `instruction_bit_recycle(instruction)) begin
+ do_recycle = 1;
+ end else begin
+ parse_instruction = have_instruction;
+ end
+
+ end
+ end
+ end
--- /dev/null
+`include "macros.v"
+
+// fifo *ship*: a 16-deep word-wide fifo
+module fifo (clk,
+ in_r, in_a, in_d,
+ out_r, out_a, out_d);
+
+ input clk;
+ input in_r;
+ input out_a;
+ output in_a;
+ output out_r;
+ input [(`DATAWIDTH-1):0] in_d;
+ output [(`DATAWIDTH-1):0] out_d;
+
+ wire [(`DATAWIDTH-1):0] d12;
+ wire [(`DATAWIDTH-1):0] d23;
+ wire [(`DATAWIDTH-1):0] d34;
+
+ fifo4 s1(clk, in_r, in_a, in_d, r12, a12, d12);
+ fifo4 s2(clk, r12, a12, d12, r23, a23, d23);
+ fifo4 s3(clk, r23, a23, d23, r34, a34, d34);
+ fifo4 s4(clk, r34, a34, d34, out_r, out_a, out_d);
+
+endmodule
`include "macros.v"
module inbox(clk,
- instr_r, instr_a_, instr_d,
- fabric_in_r, fabric_in_a_, fabric_in_d,
- fabric_out_r_, fabric_out_a, fabric_out_d_,
- ship_r_, ship_a, ship_d_);
+ instr_r, instr_a_, instr_d,
+ fabric_in_r, fabric_in_a_, fabric_in_d,
+ fabric_out_r_, fabric_out_a, fabric_out_d_,
+ ship_r_, ship_a, ship_d_
+ );
+
input clk;
- `input(instr_r, instr_a, instr_a_, [(`INSTRUCTION_WIDTH-1):0], instr_d)
-// `input(fabric_in_r, fabric_in_a, fabric_in_a_, [`DATAWIDTH:0], fabric_in_d)
- `output(fabric_out_r, fabric_out_r_, fabric_out_a, [(`PACKET_WIDTH-1):0], fabric_out_d_)
+ output fabric_in_a_;
+ input fabric_in_r;
+ input [(`DATAWIDTH-1):0] fabric_in_d;
+ //`input(fabric_in_r, fabric_in_a, fabric_in_a_, [(`DATAWIDTH-1):0], fabric_in_d)
+ `output(fabric_out_r, fabric_out_r_, fabric_out_a, [(`PACKET_WIDTH-1):0], fabric_out_d_)
+ `defreg(fabric_out_d_, [(`PACKET_WIDTH-1):0], fabric_out_d)
+ `output(ship_r, ship_r_, ship_a, [(`DATAWIDTH-1):0], ship_d_)
+ reg [(`PACKET_WIDTH-1):0] ship_d;
+ assign ship_d_ = `packet_data(ship_d);
+
+ `input(instr_r, instr_a, instr_a_, [(`INSTRUCTION_WIDTH-1):0], instr_d)
+
+ wire fabric_in_a0_;
+ reg fabric_in_a0;
+ assign fabric_in_a0_ = fabric_in_a0;
+
+ `define token_in_r fabric_in_r0
+ `define token_in_a fabric_in_a0
+ `define token_in_d fabric_in_d0
+
+ `define data_out_r ship_r
+ `define data_out_a ship_a
+ `define data_out_d ship_d
- input fabric_in_r;
- output fabric_in_a_;
- input [(`PACKET_WIDTH-1):0] fabric_in_d;
+ `define token_out_r fabric_out_r
+ `define token_out_a fabric_out_a
+ `define token_out_d fabric_out_d
- output ship_r_;
- input ship_a;
- output [(`DATAWIDTH-1):0] ship_d_;
- wire [(`DATAWIDTH-1):0] fabric_in_data;
+ `define data_in_d `packet_data(fabric_in_d0)
+ `define data_in_a fabric_in_a0
+ `define data_in_r fabric_in_r0
- assign fabric_in_data = `packet_data(fabric_in_d);
+ wire [(`PACKET_WIDTH-1):0] fabric_in_d0;
- fifo4 dfifo(clk, fabric_in_r, fabric_in_a_, fabric_in_data,
- ship_r_, ship_a, ship_d_);
+ fifo4 dfifo(clk, fabric_in_r, fabric_in_a_, fabric_in_d,
+ fabric_in_r0, fabric_in_a0_, fabric_in_d0);
+ `include "box.inc"
endmodule
`include "macros.v"
module outbox(clk,
- instr_r, instr_a_, instr_d,
- fabric_in_r, fabric_in_a, fabric_in_d,
- fabric_out_r, fabric_out_a, fabric_out_d,
- ship_r, ship_a, ship_d);
- input clk;
+ instr_r, instr_a_, instr_d,
+ fabric_in_r, fabric_in_a_, fabric_in_d,
+ fabric_out_r_, fabric_out_a, fabric_out_d_,
+ ship_r, ship_a_, ship_d
+ );
- input instr_r;
- output instr_a_;
- reg instr_a;
- assign instr_a_ = instr_a;
- input [(`INSTRUCTION_WIDTH-1):0] instr_d;
- wire [(`INSTRUCTION_WIDTH-1):0] instr_d2;
+ input clk;
- wire [(`INSTRUCTION_WIDTH-1):0] instr_d0;
- wire [(`INSTRUCTION_WIDTH-1):0] recycle_d;
+ output fabric_in_a_;
+ input fabric_in_r;
+ input [(`DATAWIDTH-1):0] fabric_in_d;
+ //`input(fabric_in_r, fabric_in_a, fabric_in_a_, [(`DATAWIDTH-1):0], fabric_in_d)
+ `output(fabric_out_r, fabric_out_r_, fabric_out_a, [(`PACKET_WIDTH-1):0], fabric_out_d_)
+ `defreg(fabric_out_d_, [(`PACKET_WIDTH-1):0], fabric_out_d)
+ `input(ship_r, ship_a, ship_a_, [(`DATAWIDTH-1):0], ship_d)
+ `input(instr_r, instr_a, instr_a_, [(`INSTRUCTION_WIDTH-1):0], instr_d)
- input ship_r;
- output ship_a;
- input [(`DATAWIDTH-1):0] ship_d;
+ wire fabric_in_a0_;
+ reg fabric_in_a0;
+ assign fabric_in_a0_ = fabric_in_a0;
- input fabric_in_r;
- output fabric_in_a;
- input [(`PACKET_WIDTH-1):0] fabric_in_d;
- wire [(`PACKET_WIDTH-1):0] fabric_in_d2;
+ `define token_in_r fabric_in_r0
+ `define token_in_a fabric_in_a0
+ `define token_in_d fabric_in_d0
- output fabric_out_r;
- input fabric_out_a;
- output [(`PACKET_WIDTH-1):0] fabric_out_d;
+ `define data_out_r fabric_out_r
+ `define data_out_a fabric_out_a
+ `define data_out_d fabric_out_d
- reg kill_r;
- wire kill_a;
- reg [(`COUNT_WIDTH-1):0] kill_d;
+ `define token_out_r fabric_out_r
+ `define token_out_a fabric_out_a
+ `define token_out_d fabric_out_d
- reg [(`INSTRUCTION_WIDTH-1):0] instruction;
- reg instr_rx;
- wire instr_ax;
- reg ifull;
+ `define data_in_d ship_d
+ `define data_in_a ship_a
+ `define data_in_r ship_r
- always @(posedge clk) begin
- if (!ifull) begin
- `onread(instr_r, instr_a)
- ifull = 1;
- instruction = instr_d;
- end
- end else begin
- if (`instruction_is_kill(instruction)) begin
- kill_d = `instruction_count(instruction);
- `onwrite(kill_r, kill_a)
- ifull = 0;
- end
- end else begin
- `onwrite(instr_rx, instr_ax)
- ifull = 0;
- end
- end
- end
- end
+ wire [(`PACKET_WIDTH-1):0] fabric_in_d0;
- fifo4 dfifo(clk, fabric_in_r, fabric_in_a, fabric_in_data,
- fabric_in_r2, fabric_in_a2, fabric_in_data2);
+ fifo4 dfifo(clk, fabric_in_r, fabric_in_a_, fabric_in_d,
+ fabric_in_r0, fabric_in_a0_, fabric_in_d0);
- funnel ifunnel(clk, instr_r0, instr_a0, instr_d0,
- instr_rx, instr_ax, instruction,
- recycle_r, recycle_a, recycle_d);
-
- fifo4 ififo(clk, instr_r0, instr_a0, instr_d0,
- instr_r2, instr_a2, instr_d2);
-
- outboxcore ob(clk, instr_r2, instr_a2, instr_d2,
- fabric_in_r2, fabric_in_a2, fabric_in_d2,
- fabric_out_r, fabric_out_a, fabric_out_d,
- ship_r, ship_a, ship_d,
- kill_r, kill_a, kill_d,
- recycle_r, recycle_a, recycle_d);
+ `include "box.inc"
endmodule
+++ /dev/null
-`include "macros.v"
-
-module outboxcore(clk,
- instr_r, instr_a_, instr_d,
- fabric_in_r, fabric_in_a_, fabric_in_d,
- fabric_out_r_, fabric_out_a, fabric_out_d_,
- ship_r, ship_a_, ship_d,
- kill_r, kill_a_, kill_d,
- recycle_r_, recycle_a, recycle_d_
- );
- input clk;
- reg have_instruction;
- reg have_token;
- reg have_data;
- reg send_token;
- reg send_data;
- reg parse_instruction;
- reg do_recycle;
- reg [(`COUNT_BITS-1):0] kill_count;
- reg [(`INSTRUCTION_WIDTH-1):0] instruction;
-
- `input(instr_r, instr_a, instr_a_, [(`INSTRUCTION_WIDTH-1):0], instr_d)
- `input(fabric_in_r, fabric_in_a, fabric_in_a_, [(`PACKET_WIDTH-1):0], fabric_in_d)
- `output(fabric_out_r, fabric_out_r_, fabric_out_a, [(`PACKET_WIDTH-1):0], fabric_out_d_)
- `defreg(fabric_out_d_, [(`PACKET_WIDTH-1):0], fabric_out_d)
- `input(ship_r, ship_a, ship_a_, [(`DATAWIDTH-1):0], ship_d)
- `input(kill_r, kill_a, kill_a_, [(`COUNT_WIDTH-1):0], kill_d)
- `output(recycle_r, recycle_r_, recycle_a, [(`INSTRUCTION_WIDTH-1):0], recycle_d_)
- assign recycle_d_ = instruction;
-
- always @(posedge clk) begin
-
- if (do_recycle) begin
- `onwrite(recycle_r, recycle_a)
- do_recycle = 0;
- end
-
- end else begin
-
- if (!have_instruction && !parse_instruction) begin
- `onread(instr_r, instr_a)
- instruction = instr_d;
- parse_instruction = 1;
- end
- end
-
- /*
- // FIXME: actually don't want to kill partway through an instruction
- `onread(kill_r, kill_a)
- kill_count = kill_d;
- end
-
- if (have_instruction && (kill_count > 0)) begin
- kill_count = kill_count - 1;
- have_instruction = 0;
- end
- */
-
- if (parse_instruction) begin
- have_token = !`instruction_bit_tokenin(instruction);
- have_data = !`instruction_bit_datain(instruction);
- `packet_dest(fabric_out_d) = `instruction_bit_dest(instruction);
- send_data = !`instruction_bit_dataout(instruction);
- send_token = !`instruction_bit_tokenout(instruction);
- have_instruction = 1;
- parse_instruction = 0;
- end
-
- if (have_instruction && !have_token) begin
- `onread(fabric_in_r, fabric_in_a)
- have_token = 1;
- end
- end
-
- if (have_instruction && !have_data) begin
- `onread(ship_r, ship_a)
- if (`instruction_bit_latch(instruction)) begin
- `packet_data(fabric_out_d) = ship_d;
- end
- have_data = 1;
- end
- end
-
- if (have_instruction && have_data && have_token) begin
- if (!send_data || !send_token) begin
- `onwrite(fabric_out_r, fabric_out_a)
- send_data = 1;
- send_token = 1;
- end
- end
- end
-
- if (have_instruction && have_data && have_token && send_data && send_token) begin
- if (`instruction_count(instruction)==1) begin
- have_instruction = 0;
- end else begin
- have_instruction = 0;
- if (`instruction_count(instruction)>0) begin
- `instruction_count(instruction) = `instruction_count(instruction) - 1;
- end
- if (`instruction_bit_recycle(instruction)) begin
- have_instruction = 0;
- do_recycle = 1;
- end else begin
- parse_instruction = 1;
- end
- end
- end
- end
- end
-endmodule
-
int main(int argc, char** argv) {
char c;
uint32 i,j;
+ int64_t result;
+ int64_t temp;
printf("hello.\n");
fd = open(argv[1], O_RDWR);
printf("open %s = %d\n", argv[1], fd);
}
}
- //send(0x03, 0x101010);
- //send(0x00, 0x101010);
- //send(0x01, 0x010101);
- /*
- send(0x06, 0x22);
- send(0x02, 0x22);
- send(0x04,
- inst(0x01, 0, 1, 1, 1, 0, 1, 0x00)
- );
- */
- /*
- if (argc > 3)
- send(27, atoi(argv[3]));
- if (argc > 4)
- send(7, atoi(argv[4]));
- */
printf("\n===================================================================\n\n");
- /*
- sendc(0x00);
- sendc(12);
- sendc(12);
- sendc(0x06);
- */
-
- // for( j=0; j<16; j++) {
- i = recvc();
- printf("result: %d / %x \n", i, i);
- i = recvc();
- printf("result: %d / %x \n", i, i);
- i = recvc();
- printf("result: %d / %x \n", i, i);
- i = recvc();
- printf("result: %d / %x \n", i, i);
- i = recvc();
- printf("result: %d / %x \n", i, i);
- i = recvc();
- printf("result: %d / %x \n", i, i);
- // }
+ while(1) {
+ result = 0;
+ for(j=0; j<6; j++) {
+ temp = recvc();
+ temp = temp << (j * 8);
+ result = result | temp;
+ }
+ printf("%lld = 0x%llx\n", result, result);
+ fflush(stdout);
+ }
return 0;
}