3 == Ports ===========================================================
9 == TeX ==============================================================
11 The Carry-Save Adder computes the carry-save sum of three input
12 values, provided sequentially at {\tt in}, and produces.
15 == Fleeterpreter ====================================================
17 public void service() {
18 if (box_in.dataReadyForShip() && box_out.readyForDataFromShip()) {
23 == FPGA ==============================================================
25 reg [(`DATAWIDTH-1):0] temp;
26 reg [(`DATAWIDTH):0] out_d;
29 assign out_d_ = out_d;
31 wire [(`DATAWIDTH-1):0] majority;
32 wire [(`DATAWIDTH-1):0] xors;
35 for(i=0; i<`DATAWIDTH; i=i+1) begin : OUT
36 assign majority[i] = (temp[i] & out_d[i]) | (in_d[i] & out_d[i]) | (temp[i] & in_d[i]);
37 assign xors[i] = temp[i] ^ out_d[i] ^ in_d[i];
41 always @(posedge clk) begin
48 if (`out_empty && state==3) begin
49 out_d <= { 1'b0, temp };
52 end else if (`in_full && `out_empty) begin
54 out_d <= { 1'b0, in_d };
55 end else if (state == 1) begin
57 end else if (state == 2) begin
58 out_d <= { majority[`DATAWIDTH-1:0], 1'b0 };
68 == Test ==============================================================
75 // ships required in order to run this code
77 #ship csa : CarrySaveAdder
82 set word=1018217; deliver;
83 set word=771820; deliver;
84 set word=2161521; deliver;
86 collect, send to csa.in; send to alu.in1;
87 collect, send to csa.in; send to alu.in2;
88 collect, send to csa.in; send to alu.in2;
90 alu.in1: set ilc=4; recv, deliver;
91 alu.in2: set ilc=4; recv, deliver;
93 set word=Alu.inOp[ADD];
96 collect, send to alu.in1;
97 collect; send to debug.in;
99 collect; send to debug.in;
107 collect, send to debug.in;
109 collect, send to debug.in;
114 send token to csa.out;
117 send token to alu.out;
121 == Contributors =========================================================
122 Adam Megacz <megacz@cs.berkeley.edu>