diff --git a/src/frontend/frontend.sv b/src/frontend/frontend.sv index 78fade6d5..f0f050d77 100644 --- a/src/frontend/frontend.sv +++ b/src/frontend/frontend.sv @@ -230,7 +230,10 @@ module frontend #( // or reduce struct always_comb begin bp_valid = 1'b0; - for (int i = 0; i < INSTR_PER_FETCH; i++) bp_valid |= (cf_type[i] != NoCF); + // BP cannot be valid if we have a return instruction and the RAS is not giving a valid address + // Check that we encountered a control flow and that for a return the RAS + // contains a valid prediction. + for (int i = 0; i < INSTR_PER_FETCH; i++) bp_valid |= ((cf_type[i] != NoCF & cf_type[i] != Return) | ((cf_type[i] == Return) & ras_predict.valid)); end assign is_mispredict = resolved_branch_i.valid & resolved_branch_i.is_mispredict;