3 == Ports ===========================================================
10 == Constants ========================================================
11 ADD: add the two arguments; treat link as carry
12 SUB: subtract the two arguments; treat link as carry
14 == TeX ==============================================================
15 This ship is a two-input arithmetic unit. It features several
16 opcodes, such as {\tt ADD} and {\tt SUB}. In my opinion, it is
19 == Fleeterpreter ====================================================
20 public void service() {
21 if (box_a.dataReadyForShip() &&
22 box_b.dataReadyForShip() &&
23 box_op.dataReadyForShip() &&
24 box_out.readyForItemFromShip()) {
25 int a = box_a.removeDataForShip();
26 int b = box_b.removeDataForShip();
27 int op = box_op.removeDataForShip();
29 case 0: box_out.addDataFromShip(a+b); // ADD
31 case 1: box_out.addDataFromShip(a-b); // SUB
33 case 2: box_out.addDataFromShip(a*b); // MUL
35 case 3: box_out.addDataFromShip(a/b); // DIV
37 case 4: box_out.addDataFromShip(a%b); // REM
39 default: box_out.addDataFromShip(0);
45 == ArchSim ==============================================================
47 == FPGA ==============================================================
49 == Contributors =========================================================
50 Adam Megacz <megacz@cs.berkeley.edu>