aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerry Zhao <jerryz123@berkeley.edu>2023-01-11 09:26:38 -0800
committerJerry Zhao <jerryz123@berkeley.edu>2023-01-18 11:20:32 -0800
commit0b379b8be61af616182740c88fbb6f2c0d060644 (patch)
treeeec36ab5f7a3e1d63c5bf842c821b44d9152cff6
parent67bbdf5506c5ef8dfd2cb198c3eb918ca6ca024f (diff)
downloadspike-0b379b8be61af616182740c88fbb6f2c0d060644.zip
spike-0b379b8be61af616182740c88fbb6f2c0d060644.tar.gz
spike-0b379b8be61af616182740c88fbb6f2c0d060644.tar.bz2
Instantiate tdata/tinfo as const csrs when trigger_count == 0
-rw-r--r--riscv/csrs.h2
-rw-r--r--riscv/processor.cc16
-rw-r--r--riscv/processor.h2
3 files changed, 12 insertions, 8 deletions
diff --git a/riscv/csrs.h b/riscv/csrs.h
index 8734339..31ba11b 100644
--- a/riscv/csrs.h
+++ b/riscv/csrs.h
@@ -637,8 +637,6 @@ class debug_mode_csr_t: public basic_csr_t {
virtual void verify_permissions(insn_t insn, bool write) const override;
};
-typedef std::shared_ptr<tdata2_csr_t> tdata2_csr_t_p;
-
class dpc_csr_t: public epc_csr_t {
public:
dpc_csr_t(processor_t* const proc, const reg_t addr);
diff --git a/riscv/processor.cc b/riscv/processor.cc
index f843224..39096e9 100644
--- a/riscv/processor.cc
+++ b/riscv/processor.cc
@@ -390,11 +390,17 @@ void state_t::reset(processor_t* const proc, reg_t max_isa)
csrmap[CSR_DCSR] = dcsr = std::make_shared<dcsr_csr_t>(proc, CSR_DCSR);
csrmap[CSR_TSELECT] = tselect = std::make_shared<tselect_csr_t>(proc, CSR_TSELECT);
-
- csrmap[CSR_TDATA1] = std::make_shared<tdata1_csr_t>(proc, CSR_TDATA1);
- csrmap[CSR_TDATA2] = tdata2 = std::make_shared<tdata2_csr_t>(proc, CSR_TDATA2);
- csrmap[CSR_TDATA3] = std::make_shared<tdata3_csr_t>(proc, CSR_TDATA3);
- csrmap[CSR_TINFO] = std::make_shared<tinfo_csr_t>(proc, CSR_TINFO);
+ if (proc->get_cfg().trigger_count > 0) {
+ csrmap[CSR_TDATA1] = std::make_shared<tdata1_csr_t>(proc, CSR_TDATA1);
+ csrmap[CSR_TDATA2] = tdata2 = std::make_shared<tdata2_csr_t>(proc, CSR_TDATA2);
+ csrmap[CSR_TDATA3] = std::make_shared<tdata3_csr_t>(proc, CSR_TDATA3);
+ csrmap[CSR_TINFO] = std::make_shared<tinfo_csr_t>(proc, CSR_TINFO);
+ } else {
+ csrmap[CSR_TDATA1] = std::make_shared<const_csr_t>(proc, CSR_TDATA1, 0);
+ csrmap[CSR_TDATA2] = tdata2 = std::make_shared<const_csr_t>(proc, CSR_TDATA2, 0);
+ csrmap[CSR_TDATA3] = std::make_shared<const_csr_t>(proc, CSR_TDATA3, 0);
+ csrmap[CSR_TINFO] = std::make_shared<const_csr_t>(proc, CSR_TINFO, 0);
+ }
unsigned scontext_length = (xlen == 32 ? 16 : 34); // debug spec suggests 16-bit for RV32 and 34-bit for RV64
csrmap[CSR_SCONTEXT] = scontext = std::make_shared<masked_csr_t>(proc, CSR_SCONTEXT, (reg_t(1) << scontext_length) - 1, 0);
unsigned hcontext_length = (xlen == 32 ? 6 : 13) + (proc->extension_enabled('H') ? 1 : 0); // debug spec suggest 7-bit (6-bit) for RV32 and 14-bit (13-bit) for RV64 with (without) H extension
diff --git a/riscv/processor.h b/riscv/processor.h
index 5daa6f4..a8ccac0 100644
--- a/riscv/processor.h
+++ b/riscv/processor.h
@@ -126,7 +126,7 @@ struct state_t
csr_t_p dpc;
dcsr_csr_t_p dcsr;
csr_t_p tselect;
- tdata2_csr_t_p tdata2;
+ csr_t_p tdata2;
csr_t_p scontext;
csr_t_p mcontext;