+++ /dev/null
-
-// ships required in order to run this code
-#ship debug : Debug
-#ship dscratch : Dscratch
-#ship fifo : Fifo
-
-// dumb configurations
-debug.data: [*] take, deliver;
-dscratch.write_addr: [*] take, deliver;
-dscratch.write_data: [*] take, deliver;
-dscratch.read_addr: [*] take, deliver;
-fifo.in: [*] take, deliver;
-
-// addresses and values to initialize the dscratch with
-1: sendto dscratch.write_addr;
-2: sendto dscratch.write_addr;
-3: sendto dscratch.write_addr;
-4: sendto dscratch.write_addr;
-11: sendto dscratch.write_data;
-12: sendto dscratch.write_data;
-13: sendto dscratch.write_data;
-14: sendto dscratch.write_data;
-
-// send write-completion tokens to the fifo output
-dscratch.write_done:
- [*] take, sendto fifo.out;
-
-// when the write-completion tokens accumulate, unleash
-// the read addresses
-fifo.out:
- [4] wait;
- [4] take, sendto dscratch.read_addr;
-
-// read addresses
-4: sendto fifo.in;
-3: sendto fifo.in;
-2: sendto fifo.in;
-1: sendto fifo.in;
-
-// data read from dscratch goes to the debug ship
-dscratch.read_data:
- [*] take, sendto debug.data;
-#include "contrib/demo.ships"
+#ship debug : Debug
+#ship iscratch : Iscratch
-BOB: sendto iscratch.cbd;
-iscratch.cbd: [*] take, deliver;
-debug.data: [*] take, deliver;
+BOB: sendto iscratch.inCBD;
+iscratch.inCBD: [*] take, deliver;
+debug.in: [*] take, deliver;
BOB: {
- 12: sendto debug.data;
- 13: sendto debug.data;
- 14: sendto debug.data;
- BOB: sendto iscratch.cbd;
+ 12: sendto debug.in;
+ 13: sendto debug.in;
+ 14: sendto debug.in;
+ BOB: sendto iscratch.inCBD;
}
+++ /dev/null
-#ship alu2_bad : Alu2
-#ship alu2 : Alu2
-#ship debug : Debug
-#ship execute : Execute
-#ship fifo : Fifo
-//#ship mem : Mem
-#ship icache : Icache
-
-
-// alu1
-// alu2
-// sort2
-// mux
-// lut
-// dup
-// fifo
-// shifter
-// counter
-
-
-// want: memory, fetch, halt
-
-//#ship alu1 : Alu1
-
-
-//#ship alu1 : Alu1
-//#ship dup1 : Dup
-//#ship dup2 : Dup
-//#ship dup3 : Dup
-//#ship dup3 : Dup3
-//#ship demux1 : DeMux
-//#ship demux2 : DeMux
-//#ship sort : Sort2
-
+++ /dev/null
-
-// ships required in order to run this code
-#ship debug : Debug
-#ship iscratch : Iscratch
-
-// instructions not in any codebag are part of the "root codebag"
-// which is dispatched when the code is loaded
-
-debug.data: deliver;
-BOB: sendto iscratch.cbd;
-iscratch.cbd: [*] take, deliver;
-debug.data: [*] 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!
-
-BOB: {
- 12: sendto debug.data;
- 13: sendto debug.data;
- 14: sendto debug.data;
- BOB: sendto iscratch.cbd;
-}
-
+++ /dev/null
-//22: sendto debug.data
-//22: sendto debug.data
-//alu1.out: ack debug.data
-
-
-//22: sendto alu3.b
-
-// route the "max" output to the demux, and that to either
-// the finished-value output (debug.data) or the subtractor
-//sort.max: [*] take, sendto demux1.in
-// demux1.false: [*] take, sendto debug.data
-// demux1.true: [*] take, sendto alu.a
-//
-//// route the "min" value to the demux selector to decide if we are
-//// done; also send copies to the ALU and the secondary sort input
-//sort.min: [*] take, sendto dup3.in
-// dup3.a: [*] take, sendto demux1.select
-// dup3.b: [*] take, sendto alu.b
-// dup3.c: [*] take, sendto sort.b
-//
-//// "plug up" the ALU opcode input with a "1" (subtraction)
-//1: sendto alu.op
-// alu.op: take [*] accept
-//
-//// route all data emerging from the ALU back to the primary sort input
-//alu.out: [*] take, sendto sort.a
-//
-//// all other inputs are in default mode
-//sort.a: [*] take, accept
-//sort.b: [*] take, accept
-//alu.a: [*] take, accept
-//alu.b: [*] take, accept
-//dup3.in: [*] take, accept
-//demux1.select: [*] take, accept
-//demux1.in: [*] take, accept
-//
-//// gcd(377,221)=13 (we hope!)
-////377: sendto sort.a
-////221: sendto sort.b
-//
ship: Alu2
== Ports ===========================================================
-data in: a
-data in: b
-data in: op
+data in: in1
+data in: in2
+data in: inOp
data out: out
== Fleeterpreter ====================================================
public void service() {
- if (box_a.dataReadyForShip() &&
- box_b.dataReadyForShip() &&
- box_op.dataReadyForShip() &&
+ if (box_in1.dataReadyForShip() &&
+ box_in2.dataReadyForShip() &&
+ box_inOp.dataReadyForShip() &&
box_out.readyForItemFromShip()) {
- int a = box_a.removeDataForShip();
- int b = box_b.removeDataForShip();
- int op = box_op.removeDataForShip();
+ int a = box_in1.removeDataForShip();
+ int b = box_in2.removeDataForShip();
+ int op = box_inOp.removeDataForShip();
switch(op) {
case 0: box_out.addDataFromShip(a+b); // ADD
break;
ship: Debug
== Ports ===========================================================
-data in: data
+data in: in
== Constants ========================================================
== Fleeterpreter ====================================================
public void service() {
- if (box_data.dataReadyForShip())
- ((Interpreter)getFleet()).debug(box_data.removeDataForShip());
+ if (box_in.dataReadyForShip())
+ ((Interpreter)getFleet()).debug(box_in.removeDataForShip());
}
== ArchSim ==============================================================
ship: Dscratch
== Ports ===========================================================
-data in: read_addr
-data out: read_data
+data in: inReadAddr
+data out: outReadData
-data in: write_addr
-data in: write_data
-token out: write_done
+data in: inWriteAddr
+data in: inWriteData
+token out: outWriteDone
== Fleeterpreter ====================================================
private long[] mem = new long[0];
}
public void service() {
- if (box_read_addr.dataReadyForShip() &&
- box_read_data.readyForItemFromShip()) {
- box_read_data.addDataFromShip((int)readMem(box_read_addr.removeDataForShip()));
+ if (box_inReadAddr.dataReadyForShip() &&
+ box_outReadData.readyForItemFromShip()) {
+ box_outReadData.addDataFromShip((int)readMem(box_inReadAddr.removeDataForShip()));
}
- if (box_write_addr.dataReadyForShip() &&
- box_write_data.dataReadyForShip() &&
- box_write_done.readyForItemFromShip()) {
- writeMem(box_write_addr.removeDataForShip(),
- box_write_data.removeDataForShip());
- box_write_done.addTokenFromShip();
+ if (box_inWriteAddr.dataReadyForShip() &&
+ box_inWriteData.dataReadyForShip() &&
+ box_outWriteDone.readyForItemFromShip()) {
+ writeMem(box_inWriteAddr.removeDataForShip(),
+ box_inWriteData.removeDataForShip());
+ box_outWriteDone.addTokenFromShip();
}
}
ship: Iscratch
== Ports ===========================================================
-data in: write_addr
-data in: write_data
-token out: write_done
+data in: inWriteAddr
+data in: inWriteData
+token out: outWriteDone
-data in: cbd
+data in: inCBD
== Fleeterpreter ====================================================
}
public void service() {
- if (box_cbd.dataReadyForShip()) {
- int val = box_cbd.removeDataForShip();
+ if (box_inCBD.dataReadyForShip()) {
+ int val = box_inCBD.removeDataForShip();
int addr = val >> 6;
int size = val & 0x3f;
dispatch(addr, size);
}
- if (box_write_addr.dataReadyForShip() &&
- box_write_data.dataReadyForShip() &&
- box_write_done.readyForItemFromShip()) {
+ if (box_inWriteAddr.dataReadyForShip() &&
+ box_inWriteData.dataReadyForShip() &&
+ box_outWriteDone.readyForItemFromShip()) {
Interpreter f = (Interpreter)getFleet();
- f.writeMem(box_write_addr.removeDataForShip(),
- box_write_data.removeDataForShip());
- box_write_done.addTokenFromShip();
+ f.writeMem(box_inWriteAddr.removeDataForShip(),
+ box_inWriteData.removeDataForShip());
+ box_outWriteDone.addTokenFromShip();
}
}
public void boot(byte[] instructions) {
Interpreter fleet = (Interpreter)getFleet();
- // load the iscratch and take note of the 0-address CBD
+ // load the iscratch and take note of the 0-address INCBD
long launch = 0;
for(int i=0; i<instructions.length; i+=6) {
long word = 0;
if (i==0) launch = word;
}
- // dispatch the 0-address CBD
+ // dispatch the 0-address INCBD
int base = (int)(launch >> 6);
base = base & ~(0xffffffff << 18);
int size = (int)launch;
ship: Lut
== Ports ===========================================================
-data in: a
-data in: b
-data in: lut
+data in: in1
+data in: in2
+data in: inLut
data out: out
== TeX ==============================================================
== Fleeterpreter ====================================================
public void service() {
- if (box_a.dataReadyForShip() && box_b.dataReadyForShip() && box_lut.dataReadyForShip()) {
- int a = box_a.removeDataForShip();
- int b = box_b.removeDataForShip();
- int lut = box_lut.removeDataForShip();
+ if (box_in1.dataReadyForShip() && box_in2.dataReadyForShip() && box_inLut.dataReadyForShip()) {
+ int a = box_in1.removeDataForShip();
+ int b = box_in2.removeDataForShip();
+ int lut = box_inLut.removeDataForShip();
int ret = 0;
if ((lut & 1) != 0) ret |= (~a) & (~b);
if ((lut & 2) != 0) ret |= (a) & (~b);
ship: Shift
== Ports ===========================================================
-data in: val
-data in: shamt
+data in: in
+data in: inShift
data out: out
== Constants ========================================================
== TeX ==============================================================
== Fleeterpreter ====================================================
public void service() {
- if (box_val.dataReadyForShip() && box_shamt.dataReadyForShip()) {
- int val = box_val.removeDataForShip();
- int shamt = box_shamt.removeDataForShip();
- if (shamt < 0) val = val >> (-1 * shamt);
- else val = val << shamt;
+ if (box_in.dataReadyForShip() && box_inShift.dataReadyForShip()) {
+ int val = box_in.removeDataForShip();
+ int inShift = box_inShift.removeDataForShip();
+ if (inShift < 0) val = val >> (-1 * inShift);
+ else val = val << inShift;
box_out.addDataFromShip(val);
}
}
try {
go(fp, instructions);
} catch (Exception e) {
+ if (fp.isTerminated()) return;
throw new RuntimeException(e);
}
}
#ship fifo : Fifo
// dumb configurations
-debug.data: [*] take, deliver;
-dscratch.write_addr: [*] take, deliver;
-dscratch.write_data: [*] take, deliver;
-dscratch.read_addr: [*] take, deliver;
+debug.in: [*] take, deliver;
+dscratch.inWriteAddr: [*] take, deliver;
+dscratch.inWriteData: [*] take, deliver;
+dscratch.inReadAddr: [*] take, deliver;
fifo.in: [*] take, deliver;
// addresses and values to initialize the dscratch with
-1: sendto dscratch.write_addr;
-2: sendto dscratch.write_addr;
-3: sendto dscratch.write_addr;
-4: sendto dscratch.write_addr;
-11: sendto dscratch.write_data;
-12: sendto dscratch.write_data;
-13: sendto dscratch.write_data;
-14: sendto dscratch.write_data;
+1: sendto dscratch.inWriteAddr;
+2: sendto dscratch.inWriteAddr;
+3: sendto dscratch.inWriteAddr;
+4: sendto dscratch.inWriteAddr;
+11: sendto dscratch.inWriteData;
+12: sendto dscratch.inWriteData;
+13: sendto dscratch.inWriteData;
+14: sendto dscratch.inWriteData;
// send write-completion tokens to the fifo output
-dscratch.write_done:
+dscratch.outWriteDone:
[*] take, sendto fifo.out;
// when the write-completion tokens accumulate, unleash
// the read addresses
fifo.out:
[4] wait;
- [4] take, sendto dscratch.read_addr;
+ [4] take, sendto dscratch.inReadAddr;
// read addresses
4: sendto fifo.in;
1: sendto fifo.in;
// data read from dscratch goes to the debug ship
-dscratch.read_data:
- [*] take, sendto debug.data;
+dscratch.outReadData:
+ [*] take, sendto debug.in;
// expected output
#expect 9
-#expect 9
-#expect 8
-#expect 9
-#expect 9
-#expect 9
-#expect 9
-#expect 9
-#expect 9
-#expect 9
// ships required in order to run this code
#ship debug : Debug
#ship fifo : Fifo
-debug.data: [*] take, deliver;
+debug.in: [*] take, deliver;
9: sendto fifo.in;
fifo.in:
take;
[100] deliver;
- [100] deliver;
- [100] deliver;
- [100] deliver;
- [100] deliver;
- [100] deliver;
- [100] deliver;
- [100] deliver;
- [100] deliver;
- [100] deliver;
- [100] deliver;
- [100] deliver;
- [100] deliver;
- [100] deliver;
- [100] deliver;
- [100] deliver;
- [100] deliver;
- [100] deliver;
- [100] deliver;
- [100] deliver;
fifo.out:
- [100r] take, discard;
- [100r] take, discard;
- [1r] take, sendto debug.data;
- [100r] take, discard;
- [100r] take, discard;
- [1r] take, sendto debug.data;
- [100r] take, discard;
- [100r] take, discard;
- [1r] take, sendto debug.data;
- [100r] take, discard;
- [100r] take, discard;
- [1r] take, sendto debug.data;
- [100r] take, discard;
- [100r] take, discard;
- [1r] take, sendto debug.data;
- [100r] take, discard;
- [100r] take, discard;
- [1r] take, sendto debug.data;
- [100r] take, discard;
- [100r] take, discard;
- [1r] take, sendto debug.data;
- [100r] take, discard;
- [100r] take, discard;
- [1r] take, sendto debug.data;
- [100r] take, discard;
- [100r] take, discard;
- [1r] take, sendto debug.data;
- [100r] take, discard;
- [100r] take, discard;
- [1r] take, sendto debug.data;
+ [99r] take, sendto fifo.in;
+ [1r] take, sendto debug.in;
#expect 14
// ships required in order to run this code
-#ship debug : Debug
+#ship debug : Debug
#ship iscratch : Iscratch
// instructions not in any codebag are part of the "root codebag"
// which is dispatched when the code is loaded
-BOB: sendto iscratch.cbd;
-iscratch.cbd: [*] take, deliver;
-debug.data: [*] take, deliver;
+BOB: sendto iscratch.inCBD;
+iscratch.inCBD: [*] take, deliver;
+debug.in: [*] take, deliver;
// This codebag illustrates how to do a loop. Notice that this
// switch fabric!
BOB: {
- 12: sendto debug.data;
- 13: sendto debug.data;
- 14: sendto debug.data;
+ 12: sendto debug.in;
+ 13: sendto debug.in;
+ 14: sendto debug.in;
}