more bugfixes to Alu3
[fleet.git] / ships / Execute.ship
1 ship: Execute
2
3 == Ports ===========================================================
4 data  in:   in
5
6 == Constants ========================================================
7 == TeX ==============================================================
8 == Fleeterpreter ====================================================
9     public void service() {
10         //throw new Error("the Execute ship is only for FPGA simulations");
11     }
12
13 == FleetSim ==============================================================
14 == FPGA ==============================================================
15 `include "macros.v"
16
17 module execute (clk, in_r,     in_a_,   in_d,
18                      ihorn_r_, ihorn_a, ihorn_d_,
19                      dhorn_r_, dhorn_a, dhorn_d_
20                );
21   input clk;
22
23   `input(in_r,     in_a,     in_a_,   [(`DATAWIDTH-1):0],         in_d)
24   `output(ihorn_r, ihorn_r_, ihorn_a, [(`INSTRUCTION_WIDTH-1):0], ihorn_d_)
25   `defreg(ihorn_d_,                   [(`INSTRUCTION_WIDTH-1):0], ihorn_d)
26   `output(dhorn_r, dhorn_r_, dhorn_a, [(`PACKET_WIDTH-1):0],      dhorn_d_)
27   `defreg(dhorn_d_,                   [(`PACKET_WIDTH-1):0],      dhorn_d)
28
29   reg ihorn_full;
30   reg dhorn_full;
31
32   always @(posedge clk) begin
33     if (ihorn_full) begin
34       `onwrite(ihorn_r, ihorn_a)
35         ihorn_full = 0;
36       end
37     end else if (dhorn_full) begin
38       `onwrite(dhorn_r, dhorn_a)
39         dhorn_full = 0;
40       end
41     end else begin
42       `onread(in_r, in_a)
43         case (in_d[(`INSTRUCTION_WIDTH-1):(`INSTRUCTION_WIDTH-2)])
44           0: begin
45               ihorn_full  = 1;
46               ihorn_d = in_d;
47               end
48           //01:
49           2: begin
50               dhorn_full  = 1;
51               `packet_data(dhorn_d) = in_d[23:0];
52               `packet_dest(dhorn_d) = in_d[34:24];
53               end
54           //11:
55         endcase
56       end
57     end
58   end
59
60
61 endmodule
62
63
64 == Contributors =========================================================
65 Adam Megacz <megacz@cs.berkeley.edu>