aboutsummaryrefslogtreecommitdiff
path: root/riscv/csrs.cc
diff options
context:
space:
mode:
authorWeiwei Li <liweiwei@iscas.ac.cn>2022-07-06 10:43:57 +0800
committerWeiwei Li <liweiwei@iscas.ac.cn>2022-07-07 08:32:54 +0800
commit9b66f89b8102f032f721fe332819325508aa3b95 (patch)
tree38b71303de40d374190ae2261cae1d1d1a87a168 /riscv/csrs.cc
parent45b9b9c2940704c6e2d77f04450abb2155dbb8b7 (diff)
downloadspike-9b66f89b8102f032f721fe332819325508aa3b95.zip
spike-9b66f89b8102f032f721fe332819325508aa3b95.tar.gz
spike-9b66f89b8102f032f721fe332819325508aa3b95.tar.bz2
modify mstatush_csr_t to general rv32_high_csr_t
Diffstat (limited to 'riscv/csrs.cc')
-rw-r--r--riscv/csrs.cc20
1 files changed, 12 insertions, 8 deletions
diff --git a/riscv/csrs.cc b/riscv/csrs.cc
index 7d1be10..b8fa920 100644
--- a/riscv/csrs.cc
+++ b/riscv/csrs.cc
@@ -493,19 +493,23 @@ bool mstatus_csr_t::unlogged_write(const reg_t val) noexcept {
return true;
}
-// implement class mstatush_csr_t
-mstatush_csr_t::mstatush_csr_t(processor_t* const proc, const reg_t addr, mstatus_csr_t_p mstatus):
+// implement class rv32_high_csr_t
+rv32_high_csr_t::rv32_high_csr_t(processor_t* const proc, const reg_t addr, const reg_t mask, csr_t_p orig):
csr_t(proc, addr),
- mstatus(mstatus),
- mask(MSTATUSH_MPV | MSTATUSH_GVA | MSTATUSH_SBE | MSTATUSH_MBE) {
+ orig(orig),
+ mask(mask) {
+}
+
+reg_t rv32_high_csr_t::read() const noexcept {
+ return (orig->read() >> 32) & mask;
}
-reg_t mstatush_csr_t::read() const noexcept {
- return (mstatus->read() >> 32) & mask;
+void rv32_high_csr_t::verify_permissions(insn_t insn, bool write) const {
+ orig->verify_permissions(insn, write);
}
-bool mstatush_csr_t::unlogged_write(const reg_t val) noexcept {
- return mstatus->unlogged_write((mstatus->written_value() & ~(mask << 32)) | ((val & mask) << 32));
+bool rv32_high_csr_t::unlogged_write(const reg_t val) noexcept {
+ return orig->unlogged_write((orig->written_value() & ~(mask << 32)) | ((val & mask) << 32));
}
// implement class sstatus_csr_t