From d9389fb23e59d72c53b4967de6d2901cca1fe6ac Mon Sep 17 00:00:00 2001 From: Luke Wren Date: Thu, 16 Jun 2022 01:42:28 +0100 Subject: [PATCH] Fix a half-valid valid address phase being left behind when taking a new path with the jump going straight to the bus. If left in place, this causes the next-next fetch to be marked as half valid, corrupting fetch data. --- hdl/hazard3_decode.v | 5 +++-- hdl/hazard3_frontend.v | 1 + test/sim/coremark/dist/barebones/core_portme.mak | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/hdl/hazard3_decode.v b/hdl/hazard3_decode.v index 9fe7a90..4db61ab 100644 --- a/hdl/hazard3_decode.v +++ b/hdl/hazard3_decode.v @@ -146,8 +146,9 @@ always @ (posedge clk or negedge rst_n) begin // branch, it *must* be a valid branch instruction, because executing // the branch is how we recover from misprediction `ifdef FORMAL - // This can be defeated if you branch backward halfway into a 32-bit instruction that immediately precedes the branch. - if (predicted_branch && !d_starved && !debug_mode) begin + // This can be defeated if you branch backward halfway into a 32-bit + // instruction that immediately precedes the branch. + if (predicted_branch && !d_starved && !debug_mode && !d_except_instr_bus_fault) begin assert(!d_invalid); assert(d_branchcond == BCOND_ZERO || d_branchcond == BCOND_NZERO); end diff --git a/hdl/hazard3_frontend.v b/hdl/hazard3_frontend.v index 51b1e20..2044e96 100644 --- a/hdl/hazard3_frontend.v +++ b/hdl/hazard3_frontend.v @@ -348,6 +348,7 @@ always @ (posedge clk or negedge rst_n) begin if (jump_now) begin if (|EXTENSION_C) begin if (mem_addr_rdy) begin + mem_aph_hwvld <= 2'b11; mem_data_hwvld <= {1'b1, !jump_target[1]}; end else begin mem_aph_hwvld <= {1'b1, !jump_target[1]}; diff --git a/test/sim/coremark/dist/barebones/core_portme.mak b/test/sim/coremark/dist/barebones/core_portme.mak index e72ad5d..19b8e44 100755 --- a/test/sim/coremark/dist/barebones/core_portme.mak +++ b/test/sim/coremark/dist/barebones/core_portme.mak @@ -35,7 +35,7 @@ SEPARATE_COMPILE=1 # You must also define below how to create an object file, and how to link. OBJOUT = -o LFLAGS = -T ../../common/memmap.ld -ASFLAGS = -c -march=rv32imc_zicsr +ASFLAGS = -c -march=rv32im_zicsr OFLAG = -o COUT = -c