Skip to content

Commit

Permalink
🐛 Stall pipeline in write-after-write loads
Browse files Browse the repository at this point in the history
Fixes #8 by making sure that newer instructions cannot be overtaken by
an in-flight stalled load.
  • Loading branch information
Stefan Mach committed Dec 20, 2017
1 parent c5f1a3a commit f9354dc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion riscv_controller.sv
Expand Up @@ -118,8 +118,12 @@ module riscv_controller
input logic [DBG_SETS_W-1:0] dbg_settings_i,
output logic dbg_trap_o,

// Regfile target
input logic [5:0] regfile_alu_waddr_id_i, // currently decoded target address

// Forwarding signals from regfile
input logic regfile_we_ex_i, // FW: write enable from EX stage
input logic [5:0] regfile_waddr_ex_i, // FW: write address from EX stage
input logic regfile_we_wb_i, // FW: write enable from WB stage
input logic regfile_alu_we_fw_i, // FW: ALU/MUL write enable from EX stage

Expand Down Expand Up @@ -726,7 +730,7 @@ module riscv_controller
( (data_req_ex_i == 1'b1) && (regfile_we_ex_i == 1'b1) ||
(wb_ready_i == 1'b0) && (regfile_we_wb_i == 1'b1)
) &&
( (reg_d_ex_is_reg_a_i == 1'b1) || (reg_d_ex_is_reg_b_i == 1'b1) || (reg_d_ex_is_reg_c_i == 1'b1) )
( (reg_d_ex_is_reg_a_i == 1'b1) || (reg_d_ex_is_reg_b_i == 1'b1) || (reg_d_ex_is_reg_c_i == 1'b1) || (regfile_waddr_ex_i == regfile_alu_waddr_id_i))
)
begin
deassert_we_o = 1'b1;
Expand Down
4 changes: 4 additions & 0 deletions riscv_id_stage.sv
Expand Up @@ -1169,8 +1169,12 @@ module riscv_id_stage
.dbg_settings_i ( dbg_settings_i ),
.dbg_trap_o ( dbg_trap_o ),

// Write targets from ID
.regfile_alu_waddr_id_i ( regfile_alu_waddr_id ),

// Forwarding signals from regfile
.regfile_we_ex_i ( regfile_we_ex_o ),
.regfile_waddr_ex_i ( regfile_waddr_ex_o ),
.regfile_we_wb_i ( regfile_we_wb_i ),

// regfile port 2
Expand Down

0 comments on commit f9354dc

Please sign in to comment.