frontend: Prevent prediction on invalid RAS entry (#475)

* bp_valid = 0 if ras_predict.valid = 0

Signed-off-by: Massimiliano Giacometti <massimiliano.giacometti@hensoldt-cyber.com>

* Update src/frontend/frontend.sv

Co-authored-by: Florian Zaruba <zarubaf@iis.ee.ethz.ch>
Signed-off-by: Massimiliano Giacometti <massimiliano.giacometti@hensoldt-cyber.com>

Co-authored-by: Florian Zaruba <zarubaf@iis.ee.ethz.ch>
This commit is contained in:
masgia 2020-07-16 10:53:10 +02:00 committed by GitHub
parent 1b65b8865a
commit c57b275df5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;