diff options
-rw-r--r-- | riscv/triggers.cc | 7 | ||||
-rw-r--r-- | riscv/triggers.h | 1 |
2 files changed, 7 insertions, 1 deletions
diff --git a/riscv/triggers.cc b/riscv/triggers.cc index 0ff36e8..60e9ea2 100644 --- a/riscv/triggers.cc +++ b/riscv/triggers.cc @@ -319,13 +319,18 @@ std::optional<match_result_t> itrigger_t::detect_trap_match(processor_t * const bool interrupt = (t.cause() & ((reg_t)1 << (xlen - 1))) != 0; reg_t bit = t.cause() & ~((reg_t)1 << (xlen - 1)); assert(bit < xlen); - if (interrupt && ((bit == 0 && nmi) || ((tdata2 >> bit) & 1))) { // Assume NMI's exception code is 0 + if (simple_match(interrupt, bit)) { hit = true; return match_result_t(TIMING_AFTER, action); } return std::nullopt; } +bool itrigger_t::simple_match(bool interrupt, reg_t bit) const +{ + return interrupt && ((bit == 0 && nmi) || ((tdata2 >> bit) & 1)); // Assume NMI's exception code is 0 +} + reg_t etrigger_t::tdata1_read(const processor_t * const proc) const noexcept { auto xlen = proc->get_xlen(); diff --git a/riscv/triggers.h b/riscv/triggers.h index 62d6db8..555ac13 100644 --- a/riscv/triggers.h +++ b/riscv/triggers.h @@ -156,6 +156,7 @@ public: virtual std::optional<match_result_t> detect_trap_match(processor_t * const proc, const trap_t& t) noexcept override; private: + bool simple_match(bool interrupt, reg_t bit) const; bool dmode; bool hit; bool nmi; |