-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForwardingUnit.sv
72 lines (72 loc) · 1.78 KB
/
ForwardingUnit.sv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
module ForwardingUnit(input logic [31:0] pre_inst, new_inst, input logic reg_wrMW, br_taken, is_mret, input logic [1:0] interrupt,
output logic For_A, For_B, Stall, Stall_MW, Flush);
always_comb begin
if (reg_wrMW) begin
/*
if (pre_inst[6:0] == 7'b0000011) begin // Load
case (new_inst[6:0])
7'b0110011: begin // R-type
Stall <= ((new_inst[19:15] == pre_inst[11:7]) | (new_inst[24:20] == pre_inst[11:7]));
Stall_MW <= ((new_inst[19:15] == pre_inst[11:7]) | (new_inst[24:20] == pre_inst[11:7]));
end
7'b0010011: begin // I-type
Stall <= (new_inst[19:15] == pre_inst[11:7]);
Stall_MW <= (new_inst[19:15] == pre_inst[11:7]);
end
endcase
end */
case (new_inst[6:0])
7'b0110011: begin // R-type
if (new_inst[19:15] == 0) For_A <= 0;
else For_A <= new_inst[19:15] == pre_inst[11:7];
if (new_inst[24:20] == 0) For_B <= 0;
else For_B <= new_inst[24:20] == pre_inst[11:7];
Stall <= 0;
Stall_MW <= 0;
Flush <= 0;
end
7'b0010011: begin // I-type
if (new_inst[19:15] == 0) For_A <= 0;
else For_A <= new_inst[19:15] == pre_inst[11:7];
For_B <= 0;
Stall <= 0;
Stall_MW <= 0;
Flush <= 0;
end
default: begin
For_A <= 0;
For_B <= 0;
Stall <= 0;
Stall_MW <= 0;
Flush <= 0;
end
endcase
if (br_taken) begin
For_A <= 0;
For_B <= 0;
Stall <= 0;
Stall_MW <= 0;
Flush <= 1;
end
end else if (br_taken) begin
For_A <= 0;
For_B <= 0;
Stall <= 0;
Stall_MW <= 0;
Flush <= 1;
end else begin
For_A <= 0;
For_B <= 0;
Stall <= 0;
Stall_MW <= 0;
Flush <= 0;
end
if (interrupt == 1 | is_mret) begin
For_A <= 0;
For_B <= 0;
Stall <= 0;
Stall_MW <= 0;
Flush <= 1;
end
end
endmodule