3 == Ports ===========================================================
13 == TeX ==============================================================
15 {\tt Alu1} is a ``one-input'' arithmetic logic unit. It includes
16 logic for performing arithmetic operations on a single argument.
17 Currently this includes
19 increment ({\sc inc}),
20 decrement ({\sc dec}), and
21 absolute value ({\sc abs}).
23 \subsection*{Semantics}
25 When a value is present at each of {\tt in} and {\tt inOp}, these two
26 values are consumed. Based on the value consumed at {\tt inOp}, the
27 requested operation is performed on the value consumed from {\tt in}.
28 The result of this operation is then made available at {\tt out}.
30 == Fleeterpreter ====================================================
31 public void service() {
32 if (box_in.dataReadyForShip() && box_inOp.dataReadyForShip() && box_out.readyForDataFromShip()) {
33 long data = box_in.removeDataForShip();
34 long opcode = box_inOp.removeDataForShip();
36 case 0: box_out.addDataFromShip(-1 * data); // NEG
38 case 1: box_out.addDataFromShip(data+1); // INC
40 case 2: box_out.addDataFromShip(data-1); // DEC
42 case 3: box_out.addDataFromShip(Math.abs(data)); // ABS
44 default: box_out.addDataFromShip(0);
50 == FleetSim ==============================================================
51 == FPGA ==============================================================
53 always @(posedge clk) begin
57 if (out_r && out_a) out_r <= 0;
58 if (!in_r && in_a) in_a <= 0;
59 if (!inOp_r && inOp_a) inOp_a <= 0;
60 if (!out_r && !out_a && in_r && !in_a && inOp_r && !inOp_a) begin
68 3: out_d <= (in_d<0) ? (-in_d) : in_d;
75 == Test ==============================================================================
93 load repeat counter with 4;
98 load repeat counter with 4;
99 take, sendto debug.in;
101 take, sendto debug.in;
105 [*] take, deliver, notify fifo.out;
108 [*] wait, take, sendto alu1.inOp;
118 == Contributors =========================================================
119 Adam Megacz <megacz@cs.berkeley.edu>