From 0d950c74f107330dbfc7757d7644943c481de669 Mon Sep 17 00:00:00 2001 From: rbuchner Date: Tue, 23 Jan 2024 15:57:43 -0800 Subject: [PATCH] Adjust wide_counter_csr_t::written_value() to only increment if counting is enabled The stored value is only decremented in that case so only then does it need re-adjusted. --- riscv/csrs.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/riscv/csrs.cc b/riscv/csrs.cc index b76b496e8e..29efeb905a 100644 --- a/riscv/csrs.cc +++ b/riscv/csrs.cc @@ -1038,7 +1038,7 @@ bool wide_counter_csr_t::unlogged_write(const reg_t val) noexcept { reg_t wide_counter_csr_t::written_value() const noexcept { // Re-adjust for upcoming bump() - return this->val + 1; + return val + (is_counting_enabled() ? 1 : 0); } // Returns true if counting is not inhibited by Smcntrpmf.