diff options
author | Tim Newsome <tim@sifive.com> | 2022-03-16 10:24:34 -0700 |
---|---|---|
committer | Tim Newsome <tim@sifive.com> | 2022-04-05 10:10:03 -0700 |
commit | 894f77677d2d6bb84cf57ddec68e87857df357a1 (patch) | |
tree | 0987ec3c7240f7570ad90d862bfd68241a63e2a0 /riscv | |
parent | 21975f9ebc19c90798e0e559a015f352e45e3e50 (diff) | |
download | spike-894f77677d2d6bb84cf57ddec68e87857df357a1.zip spike-894f77677d2d6bb84cf57ddec68e87857df357a1.tar.gz spike-894f77677d2d6bb84cf57ddec68e87857df357a1.tar.bz2 |
Move tdata2 logic into trigger.
There isn't much logic, but different trigger types will have different
logic.
Diffstat (limited to 'riscv')
-rw-r--r-- | riscv/csrs.cc | 8 | ||||
-rw-r--r-- | riscv/triggers.cc | 12 | ||||
-rw-r--r-- | riscv/triggers.h | 2 |
3 files changed, 16 insertions, 6 deletions
diff --git a/riscv/csrs.cc b/riscv/csrs.cc index 34ba699..69e3c4b 100644 --- a/riscv/csrs.cc +++ b/riscv/csrs.cc @@ -1004,15 +1004,11 @@ tdata2_csr_t::tdata2_csr_t(processor_t* const proc, const reg_t addr): } reg_t tdata2_csr_t::read() const noexcept { - return proc->TM.triggers[state->tselect->read()]->tdata2; + return proc->TM.triggers[state->tselect->read()]->tdata2_read(proc); } bool tdata2_csr_t::unlogged_write(const reg_t val) noexcept { - if (proc->TM.triggers[state->tselect->read()]->dmode && !state->debug_mode) { - return false; - } - proc->TM.triggers[state->tselect->read()]->tdata2 = val; - return true; + return proc->TM.triggers[state->tselect->read()]->tdata2_write(proc, val); } diff --git a/riscv/triggers.cc b/riscv/triggers.cc index 5acca77..f6b6e7d 100644 --- a/riscv/triggers.cc +++ b/riscv/triggers.cc @@ -69,6 +69,18 @@ bool mcontrol_t::tdata1_write(processor_t *proc, const reg_t val) noexcept { return true; } +reg_t mcontrol_t::tdata2_read(const processor_t *proc) const noexcept { + return tdata2; +} + +bool mcontrol_t::tdata2_write(processor_t *proc, const reg_t val) noexcept { + if (dmode && !proc->get_state()->debug_mode) { + return false; + } + tdata2 = val; + return true; +} + module_t::module_t(unsigned count) : triggers(count) { for (unsigned i = 0; i < count; i++) { triggers[i] = new mcontrol_t(); diff --git a/riscv/triggers.h b/riscv/triggers.h index ac5724b..8dad4f6 100644 --- a/riscv/triggers.h +++ b/riscv/triggers.h @@ -46,6 +46,8 @@ public: mcontrol_t(); reg_t tdata1_read(const processor_t *proc) const noexcept; bool tdata1_write(processor_t *proc, const reg_t val) noexcept; + reg_t tdata2_read(const processor_t *proc) const noexcept; + bool tdata2_write(processor_t *proc, const reg_t val) noexcept; uint8_t type; uint8_t maskmax; |