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