Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions rtl/ibex_id_stage.sv
Original file line number Diff line number Diff line change
Expand Up @@ -1076,9 +1076,15 @@ module ibex_id_stage #(
end

// Signal which instructions to count as retired in minstret, all traps along with ebrk and
// ecall instructions are not counted.
// ecall instructions are not counted. Writes to minstret/minstreth themselves are also excluded
// to avoid incrementing right after a write.
logic minstret_write;
assign minstret_write = csr_access_o &
(csr_op_o inside {CSR_OP_WRITE, CSR_OP_SET, CSR_OP_CLEAR}) &
(csr_addr_o inside {CSR_MINSTRET, CSR_MINSTRETH});

assign instr_perf_count_id_o = ~ebrk_insn & ~ecall_insn_dec & ~illegal_insn_dec &
~illegal_csr_insn_i & ~instr_fetch_err_i;
~illegal_csr_insn_i & ~instr_fetch_err_i & ~minstret_write;

// An instruction is ready to move to the writeback stage (or retire if there is no writeback
// stage)
Expand Down
2 changes: 1 addition & 1 deletion rtl/ibex_wb_stage.sv
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ module ibex_wb_stage #(
// Speculative versions of the signals do not factor in exceptions and whether the instruction
// is done yet. These are used to get correct values for instructions reading the relevant
// performance counters in the ID stage.
assign perf_instr_ret_wb_spec_o = wb_count_q;
assign perf_instr_ret_wb_spec_o = wb_count_q & wb_valid_q;
assign perf_instr_ret_compressed_wb_spec_o = perf_instr_ret_wb_spec_o & wb_compressed_q;
assign perf_instr_ret_wb_o = instr_done_wb_o & wb_count_q &
~(lsu_resp_valid_i & lsu_resp_err_i);
Expand Down
Loading