aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYenHaoChen <howard25336284@gmail.com>2022-12-30 11:28:19 +0800
committerYenHaoChen <howard25336284@gmail.com>2023-01-04 08:07:52 +0800
commit9f4a93dbf92b5a9e475b3f18335a40bb3f122030 (patch)
tree94a9fd13e6f3e1a6c6929c0f4865e0c8b83f2d1a
parent007199efdce2b52650fac5822e2dd2351a0a16b9 (diff)
downloadspike-9f4a93dbf92b5a9e475b3f18335a40bb3f122030.zip
spike-9f4a93dbf92b5a9e475b3f18335a40bb3f122030.tar.gz
spike-9f4a93dbf92b5a9e475b3f18335a40bb3f122030.tar.bz2
triggers: refactor: add bool etrigger_t::simple_match()
-rw-r--r--riscv/triggers.cc7
-rw-r--r--riscv/triggers.h1
2 files changed, 7 insertions, 1 deletions
diff --git a/riscv/triggers.cc b/riscv/triggers.cc
index 60e9ea2..07d1484 100644
--- a/riscv/triggers.cc
+++ b/riscv/triggers.cc
@@ -370,13 +370,18 @@ std::optional<match_result_t> etrigger_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 && ((tdata2 >> bit) & 1)) {
+ if (simple_match(interrupt, bit)) {
hit = true;
return match_result_t(TIMING_AFTER, action);
}
return std::nullopt;
}
+bool etrigger_t::simple_match(bool interrupt, reg_t bit) const
+{
+ return !interrupt && ((tdata2 >> bit) & 1);
+}
+
module_t::module_t(unsigned count) : triggers(count) {
for (unsigned i = 0; i < count; i++) {
triggers[i] = new disabled_trigger_t();
diff --git a/riscv/triggers.h b/riscv/triggers.h
index 555ac13..f05466a 100644
--- a/riscv/triggers.h
+++ b/riscv/triggers.h
@@ -174,6 +174,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;
action_t action;