From 6692c1f26db8dc629f318f377565dc24045dcef2 Mon Sep 17 00:00:00 2001 From: Luke Wren Date: Sat, 22 May 2021 10:18:47 +0100 Subject: [PATCH] Fix premature taking of branches with RAW data dependencies on the previous instruction --- hdl/hazard3_core.v | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hdl/hazard3_core.v b/hdl/hazard3_core.v index 0454138..07fd74d 100644 --- a/hdl/hazard3_core.v +++ b/hdl/hazard3_core.v @@ -546,11 +546,12 @@ wire [W_ADDR-1:0] x_jump_target = x_trap_enter ? x_trap_addr : x_taken_jump_target; +// Be careful not to take branches whose comparisons depend on a load result wire x_jump_req = x_trap_enter || x_trap_exit || d_branchcond == BCOND_ALWAYS || - d_branchcond == BCOND_ZERO && !x_alu_cmp || - d_branchcond == BCOND_NZERO && x_alu_cmp; + d_branchcond == BCOND_ZERO && !x_alu_cmp && !x_stall_raw || + d_branchcond == BCOND_NZERO && x_alu_cmp && !x_stall_raw; assign f_jump_req = d_jump_req || x_jump_req; assign f_jump_target = x_jump_target;