-
Notifications
You must be signed in to change notification settings - Fork 1
/
forward.v
92 lines (83 loc) · 2.47 KB
/
forward.v
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
module forward(clk, EX_ex, RW_mm, RW_wb, Z_mm, Z_wb, Y_ex, X_ex, p1_mux, p2_mux, r1_mux, r2_mux, wdata_mux, f1_mux, f2_mux);
input clk;
input [6:0] EX_ex;
input [2:0] RW_mm; //2:F, 1:I, 0:P
input RW_wb; //I
input [3:0] Z_mm;
input [3:0] Z_wb;
input [3:0] Y_ex;
input [3:0] X_ex;
output p1_mux;
output p2_mux;
output [1:0] r1_mux;
output [1:0] r2_mux;
output [1:0] wdata_mux;
output f1_mux;
output f2_mux;
reg p1_mux_r;
reg p2_mux_r;
reg [1:0] r1_mux_r;
reg [1:0] r2_mux_r;
reg [1:0] wdata_mux_r;
reg f1_mux_r;
reg f2_mux_r;
always @(*) begin
//always @(posedge clk) begin
//pred/fpu pipeline forward
if ((Z_mm == Y_ex) && (RW_mm[0] == 1'b1)) begin
p1_mux_r = 1'b1;
end else begin
p1_mux_r = 1'b0;
end
if ((Z_mm == X_ex) && (RW_mm[0] == 1'b1)) begin
p2_mux_r = 1'b1;
end else begin
p2_mux_r = 1'b0;
end
if ((Z_mm == Y_ex) && (RW_mm[2] == 1'b1)) begin
f1_mux_r= 1'b1;
end else begin
f1_mux_r = 1'b0;
end
if ((Z_mm == X_ex) && (RW_mm[2] == 1'b1)) begin
f2_mux_r = 1'b1;
end else begin
f2_mux_r = 1'b0;
end
//integer pipeline
//src1, 00:normal, 01:EX forward, 10:MEM forward, 11:PC addr
//src2, 00:REG, 01:EX forward, 10:MEM forward, 11:IMM
if (EX_ex[6] == 1'b1) begin
r1_mux_r = 2'b11;
end else if ((Z_mm == Y_ex) && (RW_mm[1] == 1'b1)) begin
r1_mux_r = 2'b01;
end else if ((Z_wb == Y_ex) && (RW_wb == 1'b1)) begin
r1_mux_r = 2'b10;
end else begin
r1_mux_r = 2'b00;
end
if (EX_ex[5] == 1'b1) begin
r2_mux_r = 2'b11;
end else if ((Z_mm == X_ex) && (RW_mm[1] == 1'b1)) begin
r2_mux_r = 2'b01;
end else if ((Z_mm == X_ex) && (RW_mm[1] == 1'b1)) begin
r2_mux_r = 2'b10;
end else begin
r2_mux_r = 2'b00;
end
if ((Z_wb == X_ex) && (RW_mm[1] == 1'b1)) begin
wdata_mux_r = 2'b01;
end else if ((Z_wb == X_ex) && (RW_wb == 1'b1)) begin
wdata_mux_r = 2'b10;
end else begin
wdata_mux_r = 2'b00;
end
end
assign p1_mux = (EX_ex[4:0] == 5'b0) ? 2'b00 : p1_mux_r;
assign p2_mux = (EX_ex[4:0] == 5'b0) ? 2'b00 : p2_mux_r;
assign r1_mux = (EX_ex[4:0] == 5'b0) ? 2'b00 : r1_mux_r;
assign r2_mux = (EX_ex[4:0] == 5'b0) ? 2'b00 : r2_mux_r;
assign f1_mux = (EX_ex[4:0] == 5'b0) ? 2'b00 : f1_mux_r;
assign f2_mux = (EX_ex[4:0] == 5'b0) ? 2'b00 : f2_mux_r;
assign wdata_mux = (EX_ex[4:0] == 5'b0) ? 2'b00 : wdata_mux_r;
endmodule