diff --git a/rtl/ibex_compressed_decoder.sv b/rtl/ibex_compressed_decoder.sv index 34107ce06..8ae2e02a3 100644 --- a/rtl/ibex_compressed_decoder.sv +++ b/rtl/ibex_compressed_decoder.sv @@ -25,6 +25,7 @@ module ibex_compressed_decoder #( output logic [31:0] instr_o, output logic is_compressed_o, output ibex_pkg::instr_exp_e gets_expanded_o, + input logic flush_expanded_i, output logic illegal_instr_o ); import ibex_pkg::*; @@ -799,7 +800,7 @@ module ibex_compressed_decoder #( if (!rst_ni) begin cm_state_q <= CmIdle; end else begin - cm_state_q <= cm_state_d; + cm_state_q <= flush_expanded_i ? CmIdle : cm_state_d; end end diff --git a/rtl/ibex_if_stage.sv b/rtl/ibex_if_stage.sv index ba5c0db53..13ff96c93 100644 --- a/rtl/ibex_if_stage.sv +++ b/rtl/ibex_if_stage.sv @@ -409,6 +409,12 @@ module ibex_if_stage import ibex_pkg::*; #( // // since it does not matter where we decompress instructions, we do it here // to ease timing closure + + // The compressed decoder only has state for the Zcmp expanded instructions. Flush this state if + // there is an exception. + logic flush_expanded; + assign flush_expanded = pc_set_i & (pc_mux_i == ibex_pkg::PC_EXC); + ibex_compressed_decoder #( .RV32ZC (RV32ZC), .ResetAll (ResetAll) @@ -421,6 +427,7 @@ module ibex_if_stage import ibex_pkg::*; #( .instr_o (instr_decompressed), .is_compressed_o(instr_is_compressed), .gets_expanded_o(instr_gets_expanded), + .flush_expanded_i(flush_expanded), .illegal_instr_o(illegal_c_insn) );