diff options
author | Scott Johnson <scott.johnson@arilinc.com> | 2022-07-13 09:33:36 -0700 |
---|---|---|
committer | Scott Johnson <scott.johnson@arilinc.com> | 2022-07-13 18:57:55 -0700 |
commit | 85ab2228ddb802c33a967349d69b2d948846bd01 (patch) | |
tree | f10f767ca76db9903d0a9fb1169d9c833cd1804c /riscv/processor.cc | |
parent | 8f36f1a5f8a47282743706e7777a277b9f17ba6f (diff) | |
download | spike-85ab2228ddb802c33a967349d69b2d948846bd01.zip spike-85ab2228ddb802c33a967349d69b2d948846bd01.tar.gz spike-85ab2228ddb802c33a967349d69b2d948846bd01.tar.bz2 |
Add proxy for accessing the low 32 bits of a 64-bit CSR
Use this for mstatus on RV32 so that `csrw mstatus` does not modify
the bits in `mstatush`. Fixes #1044.
Diffstat (limited to 'riscv/processor.cc')
-rw-r--r-- | riscv/processor.cc | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/riscv/processor.cc b/riscv/processor.cc index c0f4964..28129ba 100644 --- a/riscv/processor.cc +++ b/riscv/processor.cc @@ -189,10 +189,13 @@ void state_t::reset(processor_t* const proc, reg_t max_isa) prv = PRV_M; v = false; csrmap[CSR_MISA] = misa = std::make_shared<misa_csr_t>(proc, CSR_MISA, max_isa); - csrmap[CSR_MSTATUS] = mstatus = std::make_shared<mstatus_csr_t>(proc, CSR_MSTATUS); + mstatus = std::make_shared<mstatus_csr_t>(proc, CSR_MSTATUS); if (xlen == 32) { + csrmap[CSR_MSTATUS] = std::make_shared<rv32_low_csr_t>(proc, CSR_MSTATUS, mstatus); csrmap[CSR_MSTATUSH] = std::make_shared<rv32_high_csr_t>(proc, CSR_MSTATUSH, mstatus); + } else { + csrmap[CSR_MSTATUS] = mstatus; } csrmap[CSR_MEPC] = mepc = std::make_shared<epc_csr_t>(proc, CSR_MEPC); csrmap[CSR_MTVAL] = mtval = std::make_shared<basic_csr_t>(proc, CSR_MTVAL, 0); |