diff options
author | YenHaoChen <howard25336284@gmail.com> | 2023-07-17 12:04:56 +0800 |
---|---|---|
committer | YenHaoChen <howard25336284@gmail.com> | 2023-07-25 08:41:13 +0800 |
commit | f6e7338b26f1508bdcc823ff1920427bf72e95ae (patch) | |
tree | eeb14bed1730b165a21c9ac9f373e89645c6d115 /riscv/csrs.cc | |
parent | 432c9ee97613ec73bbb10591f0cef9c1c93b4284 (diff) | |
download | riscv-isa-sim-f6e7338b26f1508bdcc823ff1920427bf72e95ae.zip riscv-isa-sim-f6e7338b26f1508bdcc823ff1920427bf72e95ae.tar.gz riscv-isa-sim-f6e7338b26f1508bdcc823ff1920427bf72e95ae.tar.bz2 |
legalize menvcfg.CBIE
The value 2 of menvcfg.CBIE is reserved. This commit legalizes it to 0
by adding a specialized class envcfg_csr_t.
Reference: https://github.com/riscv/riscv-CMOs/issues/65
Diffstat (limited to 'riscv/csrs.cc')
-rw-r--r-- | riscv/csrs.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/riscv/csrs.cc b/riscv/csrs.cc index 7ea07d1..a895b6c 100644 --- a/riscv/csrs.cc +++ b/riscv/csrs.cc @@ -901,6 +901,19 @@ bool masked_csr_t::unlogged_write(const reg_t val) noexcept { return basic_csr_t::unlogged_write((read() & ~mask) | (val & mask)); } +envcfg_csr_t::envcfg_csr_t(processor_t* const proc, const reg_t addr, const reg_t mask, + const reg_t init): + masked_csr_t(proc, addr, mask, init) { + // In unlogged_write() we WARLize this field for all three of [msh]envcfg + assert(MENVCFG_CBIE == SENVCFG_CBIE && MENVCFG_CBIE == HENVCFG_CBIE); +} + +bool envcfg_csr_t::unlogged_write(const reg_t val) noexcept { + const reg_t cbie_reserved = 2; // Reserved value of xenvcfg.CBIE + const reg_t adjusted_val = get_field(val, MENVCFG_CBIE) != cbie_reserved ? val : set_field(val, MENVCFG_CBIE, 0); + return masked_csr_t::unlogged_write(adjusted_val); +} + // implement class henvcfg_csr_t henvcfg_csr_t::henvcfg_csr_t(processor_t* const proc, const reg_t addr, const reg_t mask, const reg_t init, csr_t_p menvcfg): masked_csr_t(proc, addr, mask, init), |