-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathforwarding.sv
51 lines (41 loc) · 1.76 KB
/
forwarding.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
import definitions::*;
module forwarding(
input pipeline_id_reg_t id_reg_i,
input pipeline_ex_reg_t ex_reg_i,
input pipeline_mem_reg_t mem_reg_i,
input pipeline_wb_reg_t wb_reg_i,
output logic ex_alu_out_to_reg1_bypass_o,
output logic ex_alu_out_to_reg2_bypass_o,
output logic mem_alu_out_to_reg1_bypass_o,
output logic mem_alu_out_to_reg2_bypass_o,
output logic wb_alu_out_to_reg1_bypass_o,
output logic wb_alu_out_to_reg2_bypass_o
);
logic ex_alu_writes_regfile;
logic mem_alu_writes_regfile;
logic wb_alu_writes_regfile;
assign ex_alu_writes_regfile = ex_reg_i.valid &&
stage_will_write_alu_to_regfile(ex_reg_i.regfile_we,
ex_reg_i.regfile_wr_addr,
ex_reg_i.regfile_wr_sel);
assign mem_alu_writes_regfile = mem_reg_i.valid &&
stage_will_write_alu_to_regfile(mem_reg_i.regfile_we,
mem_reg_i.regfile_wr_addr,
mem_reg_i.regfile_wr_sel);
assign wb_alu_writes_regfile = wb_reg_i.valid &&
stage_will_write_alu_to_regfile(wb_reg_i.regfile_we,
wb_reg_i.regfile_wr_addr,
wb_reg_i.regfile_wr_sel);
assign ex_alu_out_to_reg1_bypass_o = ex_alu_writes_regfile &&
(id_reg_i.instr.common.rs1 == ex_reg_i.regfile_wr_addr);
assign ex_alu_out_to_reg2_bypass_o = ex_alu_writes_regfile &&
(id_reg_i.instr.common.rs2 == ex_reg_i.regfile_wr_addr);
assign mem_alu_out_to_reg1_bypass_o = mem_alu_writes_regfile &&
(id_reg_i.instr.common.rs1 == mem_reg_i.regfile_wr_addr);
assign mem_alu_out_to_reg2_bypass_o = mem_alu_writes_regfile &&
(id_reg_i.instr.common.rs2 == mem_reg_i.regfile_wr_addr);
assign wb_alu_out_to_reg1_bypass_o = wb_alu_writes_regfile &&
(id_reg_i.instr.common.rs1 == wb_reg_i.regfile_wr_addr);
assign wb_alu_out_to_reg2_bypass_o = wb_alu_writes_regfile &&
(id_reg_i.instr.common.rs2 == wb_reg_i.regfile_wr_addr);
endmodule