3 == Ports ===========================================================
9 == Constants ========================================================
16 == TeX ==============================================================
17 == Fleeterpreter ====================================================
18 public void service() {
19 if (box_in.dataReadyForShip() && box_inOp.dataReadyForShip()) {
20 int data = box_in.removeDataForShip();
21 int opcode = box_inOp.removeDataForShip();
23 case 0: box_out.addDataFromShip(-1 * data); // NEG
25 case 1: box_out.addDataFromShip(data+1); // INC
27 case 2: box_out.addDataFromShip(data-1); // DEC
29 case 3: box_out.addDataFromShip(Math.abs(data)); // ABS
31 default: box_out.addDataFromShip(0);
37 == FleetSim ==============================================================
38 == FPGA ==============================================================
40 reg [(`DATAWIDTH-1):0] reg_a;
42 reg [(`DATAWIDTH-1):0] reg_op;
44 always @(posedge clk) begin
46 `onread(in_r, in_a) have_a = 1; reg_a = in_d; end
49 `onread(inOp_r, inOp_a) have_op = 1; reg_op = inOp_d; end
52 if (have_a && have_op) begin
57 3: out_d = (reg_a<0) ? (-reg_a) : reg_a;
58 4: out_d = 37'b1111111111111111111111111111111111111;
61 `onwrite(out_r, out_a)
69 == Contributors =========================================================
70 Adam Megacz <megacz@cs.berkeley.edu>