From 114be91bbe7e907f1070d807ae56ce50993304f6 Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Tue, 24 Feb 2026 14:55:19 -0800 Subject: [PATCH] Remove incorrect use of static variable It prevents modeling mixed RV32/RV64 systems. --- riscv/csrs.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/riscv/csrs.cc b/riscv/csrs.cc index c631e4e3..cc12e1d2 100644 --- a/riscv/csrs.cc +++ b/riscv/csrs.cc @@ -455,12 +455,11 @@ reg_t base_status_csr_t::compute_sstatus_write_mask() const noexcept { } reg_t base_status_csr_t::adjust_sd(const reg_t val) const noexcept { - // This uses get_const_xlen() instead of get_xlen() not only because - // the variable is static, so it's only called once, but also + // This uses get_const_xlen() instead of get_xlen() // because the SD bit moves when XLEN changes, which means we would // need to call adjust_sd() on every read, instead of on every // write. - static const reg_t sd_bit = proc->get_const_xlen() == 64 ? SSTATUS64_SD : SSTATUS32_SD; + const reg_t sd_bit = proc->get_const_xlen() == 64 ? SSTATUS64_SD : SSTATUS32_SD; if (((val & SSTATUS_FS) == SSTATUS_FS) || ((val & SSTATUS_VS) == SSTATUS_VS) || ((val & SSTATUS_XS) == SSTATUS_XS)) {