3 == Ports ===========================================================
11 == Constants ========================================================
12 == TeX ==============================================================
14 This ship performs addition of three inputs, producing two output
15 values in carry-save form. To complete the addition, send the two
16 output values to an Alu2 with opcode ADD. For summing a set of four
17 or more numbers, Alu3 followed by Alu2 is often faster than repeated
20 == Fleeterpreter ====================================================
21 public void service() {
22 if (box_in1.dataReadyForShip() &&
23 box_in2.dataReadyForShip() &&
24 box_in3.dataReadyForShip() &&
25 box_out1.readyForDataFromShip() &&
26 box_out2.readyForDataFromShip()) {
27 long v1 = box_in1.removeDataForShip();
28 long v2 = box_in2.removeDataForShip();
29 long v3 = box_in3.removeDataForShip();
30 long o1 = ((v1 & v2) | (v2 & v3) | (v1 & v3)) << 1;
31 long o2 = v1 ^ v2 ^ v3;
32 box_out1.addDataFromShip(o1);
33 box_out2.addDataFromShip(o2);
37 == FleetSim ==============================================================
39 == FPGA ==============================================================
42 reg [(`DATAWIDTH-1):0] a;
44 reg [(`DATAWIDTH-1):0] b;
46 reg [(`DATAWIDTH-1):0] c;
50 always @(posedge clk) begin
52 `onwrite(out1_r, out1_a) have_out1 <= 0; end
54 end else if (have_out2) begin
55 `onwrite(out2_r, out2_a) have_out2 <= 0; end
57 end else if (!have_out1 && !have_out2) begin
59 `onread(in1_r, in1_a) have_a <= 1; a <= in1_d; end
62 `onread(in2_r, in2_a) have_b <= 1; b <= in2_d; end
65 `onread(in3_r, in3_a) have_c <= 1; c <= in3_d; end
68 if (have_a && have_b && have_c) begin
69 out1_d <= { { ((a & b) | (b & c) | (a & c)) } , 1'b0 };
83 == Contributors =========================================================
84 Adam Megacz <megacz@cs.berkeley.edu>