aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Waterman <andrew@sifive.com>2023-09-13 13:28:27 -0700
committerGitHub <noreply@github.com>2023-09-13 13:28:27 -0700
commit67df25aedc93183ced375e04f87931178b9e9c26 (patch)
tree603fd3f4ad76c9893f3d9c1f2f6b3be557bb2a70
parenteb9a55a519634c146bc7f287e99315654f3067ad (diff)
parent9bc80f3d095c8220200dec74b0c03f5d806976af (diff)
downloadspike-67df25aedc93183ced375e04f87931178b9e9c26.zip
spike-67df25aedc93183ced375e04f87931178b9e9c26.tar.gz
spike-67df25aedc93183ced375e04f87931178b9e9c26.tar.bz2
Merge pull request #1458 from YenHaoChen/pr-multiple-icount
Hit multiple icount triggers with different actions
-rw-r--r--riscv/triggers.cc19
-rw-r--r--riscv/triggers.h6
2 files changed, 18 insertions, 7 deletions
diff --git a/riscv/triggers.cc b/riscv/triggers.cc
index b2b815d..5a2d18b 100644
--- a/riscv/triggers.cc
+++ b/riscv/triggers.cc
@@ -305,7 +305,7 @@ void mcontrol6_t::tdata1_write(processor_t * const proc, const reg_t val, const
load = get_field(val, CSR_MCONTROL6_LOAD);
}
-std::optional<match_result_t> icount_t::detect_icount_match(processor_t * const proc) noexcept
+std::optional<match_result_t> icount_t::detect_icount_fire(processor_t * const proc) noexcept
{
if (!common_match(proc) || !allow_action(proc->get_state()))
return std::nullopt;
@@ -317,13 +317,19 @@ std::optional<match_result_t> icount_t::detect_icount_match(processor_t * const
ret = match_result_t(TIMING_BEFORE, action);
}
- if (count >= 1 && (ret == std::nullopt || action != MCONTROL_ACTION_DEBUG_MODE)) {
+ return ret;
+}
+
+void icount_t::detect_icount_decrement(processor_t * const proc) noexcept
+{
+ if (!common_match(proc) || !allow_action(proc->get_state()))
+ return;
+
+ if (count >= 1) {
if (count == 1)
pending = 1;
count = count - 1;
}
-
- return ret;
}
reg_t icount_t::tdata1_read(const processor_t * const proc) const noexcept
@@ -588,10 +594,13 @@ std::optional<match_result_t> module_t::detect_icount_match() noexcept
std::optional<match_result_t> ret = std::nullopt;
for (auto trigger: triggers) {
- auto result = trigger->detect_icount_match(proc);
+ auto result = trigger->detect_icount_fire(proc);
if (result.has_value() && (!ret.has_value() || ret->action < result->action))
ret = result;
}
+ if (ret == std::nullopt || ret->action != MCONTROL_ACTION_DEBUG_MODE)
+ for (auto trigger: triggers)
+ trigger->detect_icount_decrement(proc);
return ret;
}
diff --git a/riscv/triggers.h b/riscv/triggers.h
index 0bf6097..6f00122 100644
--- a/riscv/triggers.h
+++ b/riscv/triggers.h
@@ -85,7 +85,8 @@ public:
virtual std::optional<match_result_t> detect_memory_access_match(processor_t UNUSED * const proc,
operation_t UNUSED operation, reg_t UNUSED address, std::optional<reg_t> UNUSED data) noexcept { return std::nullopt; }
- virtual std::optional<match_result_t> detect_icount_match(processor_t UNUSED * const proc) { return std::nullopt; }
+ virtual std::optional<match_result_t> detect_icount_fire(processor_t UNUSED * const proc) { return std::nullopt; }
+ virtual void detect_icount_decrement(processor_t UNUSED * const proc) {}
virtual std::optional<match_result_t> detect_trap_match(processor_t UNUSED * const proc, const trap_t UNUSED & t) noexcept { return std::nullopt; }
protected:
@@ -248,7 +249,8 @@ public:
virtual bool icount_check_needed() const override { return count > 0 || pending; }
virtual void stash_read_values() override;
- virtual std::optional<match_result_t> detect_icount_match(processor_t * const proc) noexcept override;
+ virtual std::optional<match_result_t> detect_icount_fire(processor_t * const proc) noexcept override;
+ virtual void detect_icount_decrement(processor_t * const proc) noexcept override;
private:
bool dmode = false;