3 == Ports ===========================================================
16 == Constants ========================================================
17 == TeX ==============================================================
19 == Fleeterpreter ====================================================
21 Bitfifo.BitStorage outBits = new Bitfifo.BitStorage(74);
22 public void service() {
23 if (box_in1.dataReadyForShip() &&
24 box_in2.dataReadyForShip() &&
25 box_in3.dataReadyForShip() &&
26 outBits.hasSpace(1) &&
27 box_out1.readyForDataFromShip() &&
28 box_out2.readyForDataFromShip() &&
29 box_out3.readyForDataFromShip()) {
30 long v1 = box_in1.removeDataForShip();
31 long v2 = box_in2.removeDataForShip();
32 long v3 = box_in3.removeDataForShip();
37 o3 = ((v2 & 0x1L) == 0) ? 0 : v1;
39 o1 = ((v1 & v2) | (v2 & v3) | (v1 & v3))/* << 1*/;
40 o2 = (v1 ^ v2 ^ v3) >> 1;
42 outBits.add((v1 ^ v2 ^ v3) & 0x1L, 1);
44 box_out1.addDataFromShip(o1);
45 box_out2.addDataFromShip(o2);
46 box_out3.addDataFromShip(o3);
49 if (box_outBits.readyForDataFromShip() &&
50 outBits.size() >= 37) {
51 box_outBits.addDataFromShip(outBits.get(37));
55 == FleetSim ==============================================================
57 == FPGA ==============================================================
60 reg [(`DATAWIDTH-1):0] a;
62 reg [(`DATAWIDTH-1):0] b;
64 reg [(`DATAWIDTH-1):0] c;
68 always @(posedge clk) begin
70 `onwrite(out1_r, out1_a) have_out1 <= 0; end
72 end else if (have_out2) begin
73 `onwrite(out2_r, out2_a) have_out2 <= 0; end
75 end else if (!have_out1 && !have_out2) begin
77 `onread(in1_r, in1_a) have_a <= 1; a <= in1_d; end
80 `onread(in2_r, in2_a) have_b <= 1; b <= in2_d; end
83 `onread(in3_r, in3_a) have_c <= 1; c <= in3_d; end
86 if (have_a && have_b && have_c) begin
87 out1_d <= { { ((a & b) | (b & c) | (a & c)) } , 1'b0 };
99 == Test ========================================================================
107 1000000: sendto alu3.in1;
108 1200000: sendto alu3.in2;
112 alu3.in1: [*] take, deliver;
113 alu3.in2: [*] take, deliver;
114 alu3.in3: [*] take, deliver;
115 alu3.out1: [74] take, sendto alu3.in1;
116 [74] take, sendto alu3.in1;
117 alu3.out2: [74] take, sendto alu3.in2;
118 [74] take, sendto alu3.in2;
119 alu3.out3: [74] take, sendto alu3.in3;
120 [74] take, sendto alu3.in3;
121 alu3.outBits: [2] take, sendto debug.in;
122 debug.in: [*] take, deliver;
125 == Contributors =========================================================
126 Amir Kamil <kamil@cs.berkeley.edu>
127 Adam Megacz <megacz@cs.berkeley.edu>