-
Notifications
You must be signed in to change notification settings - Fork 0
/
EXForward.v
28 lines (26 loc) · 874 Bytes
/
EXForward.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
module EXForward(
input [4:0] EX_rs,
input [4:0] EX_rt,
input [4:0] MEM_rd,
input [4:0] WB_rd,
input MEM_RegWrite,
input WB_RegWrite,
output [1:0] EX_rs_Src,
output [1:0] EX_rt_Src
);
wire MEM_to_EX_rs, MEM_to_EX_rt, WB_to_EX_rs, WB_to_EX_rt;
assign MEM_to_EX_rs = MEM_RegWrite && (MEM_rd != 5'b00000) && (EX_rs == MEM_rd);
assign MEM_to_EX_rt = MEM_RegWrite && (MEM_rd != 5'b00000) && (EX_rt == MEM_rd);
assign WB_to_EX_rs = WB_RegWrite && (WB_rd != 5'b00000) && (EX_rs == WB_rd);
assign WB_to_EX_rt = WB_RegWrite && (WB_rd != 5'b00000) && (EX_rt == WB_rd);
// Normal 00
// WB 01
// MEM 10
// EX 11
assign EX_rs_Src = MEM_to_EX_rs? 2'b10:
WB_to_EX_rs? 2'b01:
2'b00;
assign EX_rt_Src = MEM_to_EX_rt? 2'b10:
WB_to_EX_rt? 2'b01:
2'b00;
endmodule