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 reg [(`PACKET_WIDTH-1):0] reg_a;
55 reg [(`PACKET_WIDTH-1):0] reg_op;
56 reg [(`PACKET_WIDTH-1):0] extrabits;
58 always @(posedge clk) begin
60 `onread(in_r, in_a) have_a = 1; reg_a = in_d; end
63 `onread(inOp_r, inOp_a)
65 reg_op = inOp_d[(`DATAWIDTH-1):0];
66 extrabits = inOp_d[(`PACKET_WIDTH-1):`DATAWIDTH];
70 if (have_a && have_op) begin
75 3: out_d = (reg_a<0) ? (-reg_a) : reg_a;
76 4: out_d = 37'b1111111111111111111111111111111111111;
80 `onwrite(out_r, out_a)
87 == Test ==============================================================================
98 debug.in: [*] take, deliver;
105 [4] take, sendto debug.in;
107 [*] take, sendto debug.in;
113 literal 0; [2] deliver;
116 == Contributors =========================================================
117 Adam Megacz <megacz@cs.berkeley.edu>