--- /dev/null
+ship: Alu1
+
+== Ports ===========================================================
+data in: in
+data in: inOp
+
+data out: out
+
+== Constants ========================================================
+== TeX ==============================================================
+== Fleeterpreter ====================================================
+ public void service() {
+/*
+ if (in.dataReadyForShip() && op.dataReadyForShip()) {
+ int data = in.removeDataForShip();
+ int opcode = in.removeDataForShip();
+ switch(opcode) {
+ case 0: out.addDataFromShip(-1 * data); // NEG
+ break;
+ case 1: out.addDataFromShip(data+1); // INC
+ break;
+ case 2: out.addDataFromShip(data-1); // DEC
+ break;
+ case 3: out.addDataFromShip(Math.abs(data)); // ABS
+ break;
+ default: out.addDataFromShip(0);
+ break;
+ }
+ }
+*/
+ }
+
+== ArchSim ==============================================================
+== FPGA ==============================================================
+
+== Contributors =========================================================
+Adam Megacz <megacz@cs.berkeley.edu>
--- /dev/null
+ship: Alu2
+
+== Ports ===========================================================
+data in: a
+data in: b
+data in: op
+
+data out: out
+
+== Constants ========================================================
+ADD: add the two arguments; treat link as carry
+SUB: subtract the two arguments; treat link as carry
+
+== TeX ==============================================================
+This ship is a two-input arithmetic unit. It features several
+opcodes, such as {\tt ADD} and {\tt SUB}. In my opinion, it is
+niftycool.
+
+== Fleeterpreter ====================================================
+public void service() {
+ if (box_a.dataReadyForShip() &&
+ box_b.dataReadyForShip() &&
+ box_op.dataReadyForShip() &&
+ box_out.readyForItemFromShip()) {
+ int a = box_a.removeDataForShip();
+ int b = box_b.removeDataForShip();
+ int op = box_op.removeDataForShip();
+ switch(op) {
+ case 0: box_out.addDataFromShip(a+b); // ADD
+ break;
+ case 1: box_out.addDataFromShip(a-b); // SUB
+ break;
+ case 2: box_out.addDataFromShip(a*b); // MUL
+ break;
+ case 3: box_out.addDataFromShip(a/b); // DIV
+ break;
+ case 4: box_out.addDataFromShip(a%b); // REM
+ break;
+ default: box_out.addDataFromShip(0);
+ break;
+ }
+ }
+}
+
+== ArchSim ==============================================================
+
+== FPGA ==============================================================
+
+== Contributors =========================================================
+Adam Megacz <megacz@cs.berkeley.edu>
--- /dev/null
+ship: Debug
+
+== Ports ===========================================================
+data in: data
+
+== Constants ========================================================
+
+== TeX ==============================================================
+
+== Fleeterpreter ====================================================
+public void service() {
+ if (box_data.dataReadyForShip())
+ ((Interpreter)getFleet()).debug(box_data.removeDataForShip());
+}
+
+== ArchSim ==============================================================
+
+== FPGA ==============================================================
+
+== Contributors =========================================================
+Adam Megacz <megacz@cs.berkeley.edu>
--- /dev/null
+ship: Dscratch
+
+== Ports ===========================================================
+data in: read_addr
+data out: read_data
+
+data in: write_addr
+data in: write_data
+token out: write_done
+
+== Fleeterpreter ====================================================
+ private long[] mem = new long[0];
+ public long readMem(int addr) { return mem[addr]; }
+ public void writeMem(int addr, long val) {
+ if (addr >= mem.length) {
+ long[] newmem = new long[addr * 2 + 1];
+ System.arraycopy(mem, 0, newmem, 0, mem.length);
+ mem = newmem;
+ }
+ mem[addr] = val;
+ }
+
+ public void service() {
+ if (box_read_addr.dataReadyForShip() &&
+ box_read_data.readyForItemFromShip()) {
+ box_read_data.addDataFromShip((int)readMem(box_read_addr.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();
+ }
+ }
+
+== ArchSim ==============================================================
+== FPGA ==============================================================
+== Constants ========================================================
+== TeX ==============================================================
+
+== Contributors =========================================================
+Adam Megacz <megacz@cs.berkeley.edu>
--- /dev/null
+ship: Execute
+
+== Ports ===========================================================
+data in: in
+
+== Constants ========================================================
+== TeX ==============================================================
+== Fleeterpreter ====================================================
+ public void service() {
+ //throw new Error("the Execute ship is only for FPGA simulations");
+ }
+
+== ArchSim ==============================================================
+== FPGA ==============================================================
+
+== Contributors =========================================================
+Adam Megacz <megacz@cs.berkeley.edu>
--- /dev/null
+ship: Fifo
+
+== Ports ===========================================================
+data in: in
+data out: out
+
+== Constants ========================================================
+== TeX ==============================================================
+== Fleeterpreter ====================================================
+ private Queue<Integer> fifo = new LinkedList<Integer>();
+ public void service() {
+ if (box_in.dataReadyForShip()) {
+ fifo.add(box_in.removeDataForShip());
+ }
+ if (box_out.readyForDataFromShip() && fifo.size() > 0) {
+ box_out.addDataFromShip(fifo.remove());
+ }
+ }
+
+== ArchSim ==============================================================
+== FPGA ==============================================================
+
+== Contributors =========================================================
+Adam Megacz <megacz@cs.berkeley.edu>
--- /dev/null
+ship: Halt
+
+== Ports ===========================================================
+token in: in
+
+== Constants ========================================================
+
+== TeX ==============================================================
+
+== Fleeterpreter ====================================================
+public void service() {
+ if (!box_in.tokenReadyForShip()) return;
+ box_in.removeTokenForShip();
+ ((Interpreter)getInterpreter()).halt = true;
+ Log.println(Log.yellow(" HALT: ====== halt ship got a token; halting the fleet ======"));
+}
+
+== ArchSim ==============================================================
+
+== FPGA ==============================================================
+
+== Contributors =========================================================
+Adam Megacz <megacz@cs.berkeley.edu>
--- /dev/null
+ship: Iscratch
+
+== Ports ===========================================================
+data in: write_addr
+data in: write_data
+token out: write_done
+
+data in: cbd
+
+== Fleeterpreter ====================================================
+
+ private long[] mem = new long[0];
+ public long readMem(int addr) { return mem[addr]; }
+ public void writeMem(int addr, long val) {
+ if (addr >= mem.length) {
+ long[] newmem = new long[addr * 2 + 1];
+ System.arraycopy(mem, 0, newmem, 0, mem.length);
+ mem = newmem;
+ }
+ mem[addr] = val;
+ }
+
+ public void dispatch(int addr, int size) {
+ for(int i=addr; i<addr+size; i++) {
+ Instruction instr = ((Interpreter)getFleet()).readInstruction(readMem(i));
+ ((Interpreter)getFleet()).dispatch(instr, i);
+ }
+ }
+
+ public void service() {
+ if (box_cbd.dataReadyForShip()) {
+ int val = box_cbd.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()) {
+ Interpreter f = (Interpreter)getFleet();
+ f.writeMem(box_write_addr.removeDataForShip(),
+ box_write_data.removeDataForShip());
+ box_write_done.addTokenFromShip();
+ }
+ }
+
+ public void boot(byte[] instructions) {
+ Interpreter fleet = (Interpreter)getFleet();
+ // load the iscratch and take note of the 0-address CBD
+ long launch = 0;
+ for(int i=0; i<instructions.length; i+=6) {
+ long word = 0;
+ for(int j=0; j<6; j++)
+ word = (word << 8) | (instructions[i+j] & 0xff);
+ writeMem(i/6, word);
+ if (i==0) launch = word;
+ }
+
+ // dispatch the 0-address CBD
+ int base = (int)(launch >> 6);
+ base = base & ~(0xffffffff << 18);
+ int size = (int)launch;
+ size = size & ~(0xffffffff << 6);
+ dispatch(base, size);
+ }
+
+== Constants ========================================================
+== TeX ==============================================================
+== ArchSim ==============================================================
+== FPGA ==============================================================
+
+== Contributors =========================================================
+Adam Megacz <megacz@cs.berkeley.edu>
--- /dev/null
+ship: Lut
+
+== Ports ===========================================================
+data in: a
+data in: b
+data in: lut
+
+data out: out
+
+== Constants ========================================================
+== 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();
+ int ret = 0;
+ if ((lut & 1) != 0) ret |= (~a) & (~b);
+ if ((lut & 2) != 0) ret |= (a) & (~b);
+ if ((lut & 4) != 0) ret |= (~a) & (b);
+ if ((lut & 8) != 0) ret |= a & b;
+ box_out.addDataFromShip(ret);
+ }
+ }
+
+== ArchSim ==============================================================
+== FPGA ==============================================================
+
+== Contributors =========================================================
+Adam Megacz <megacz@cs.berkeley.edu>
--- /dev/null
+ship: Shift
+
+== Ports ===========================================================
+data in: val
+data in: shamt
+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;
+ box_out.addDataFromShip(val);
+ }
+ }
+
+== ArchSim ==============================================================
+== FPGA ==============================================================
+
+== Contributors =========================================================
+Adam Megacz <megacz@cs.berkeley.edu>