aboutsummaryrefslogtreecommitdiff
path: root/riscv/triggers.cc
diff options
context:
space:
mode:
authorScott Johnson <scott.johnson@arilinc.com>2022-12-01 09:53:49 -0800
committerScott Johnson <scott.johnson@arilinc.com>2022-12-01 09:53:49 -0800
commit1327dc6f6e0b39c775a527106d95b76291dd61c1 (patch)
treefb587ec7f5f61c2e07a75c650e4a0d4509ae66ec /riscv/triggers.cc
parenta078ef221f222ca5536307c6e695999b60b2a1ff (diff)
downloadriscv-isa-sim-1327dc6f6e0b39c775a527106d95b76291dd61c1.zip
riscv-isa-sim-1327dc6f6e0b39c775a527106d95b76291dd61c1.tar.gz
riscv-isa-sim-1327dc6f6e0b39c775a527106d95b76291dd61c1.tar.bz2
Use std::optional for detect_trap_match in trigger_t hierarchy
Goal is to remove match_result_t.fire field to eliminate dont-care fields.
Diffstat (limited to 'riscv/triggers.cc')
-rw-r--r--riscv/triggers.cc16
1 files changed, 8 insertions, 8 deletions
diff --git a/riscv/triggers.cc b/riscv/triggers.cc
index 0839acf..20135e2 100644
--- a/riscv/triggers.cc
+++ b/riscv/triggers.cc
@@ -184,7 +184,7 @@ void itrigger_t::tdata1_write(processor_t * const proc, const reg_t val, const b
action = legalize_action(get_field(val, CSR_ITRIGGER_ACTION));
}
-match_result_t itrigger_t::detect_trap_match(processor_t * const proc, const trap_t& t) noexcept
+std::optional<match_result_t> itrigger_t::detect_trap_match(processor_t * const proc, const trap_t& t) noexcept
{
state_t * const state = proc->get_state();
if ((state->prv == PRV_M && !m) ||
@@ -192,7 +192,7 @@ match_result_t itrigger_t::detect_trap_match(processor_t * const proc, const tra
(!state->v && state->prv == PRV_U && !u) ||
(state->v && state->prv == PRV_S && !vs) ||
(state->v && state->prv == PRV_U && !vu)) {
- return match_result_t(false);
+ return std::nullopt;
}
auto xlen = proc->get_xlen();
@@ -203,7 +203,7 @@ match_result_t itrigger_t::detect_trap_match(processor_t * const proc, const tra
hit = true;
return match_result_t(true, TIMING_AFTER, action);
}
- return match_result_t(false);
+ return std::nullopt;
}
reg_t etrigger_t::tdata1_read(const processor_t * const proc) const noexcept
@@ -236,7 +236,7 @@ void etrigger_t::tdata1_write(processor_t * const proc, const reg_t val, const b
action = legalize_action(get_field(val, CSR_ETRIGGER_ACTION));
}
-match_result_t etrigger_t::detect_trap_match(processor_t * const proc, const trap_t& t) noexcept
+std::optional<match_result_t> etrigger_t::detect_trap_match(processor_t * const proc, const trap_t& t) noexcept
{
state_t * const state = proc->get_state();
if ((state->prv == PRV_M && !m) ||
@@ -244,7 +244,7 @@ match_result_t etrigger_t::detect_trap_match(processor_t * const proc, const tra
(!state->v && state->prv == PRV_U && !u) ||
(state->v && state->prv == PRV_S && !vs) ||
(state->v && state->prv == PRV_U && !vu)) {
- return match_result_t(false);
+ return std::nullopt;
}
auto xlen = proc->get_xlen();
@@ -255,7 +255,7 @@ match_result_t etrigger_t::detect_trap_match(processor_t * const proc, const tra
hit = true;
return match_result_t(true, TIMING_AFTER, action);
}
- return match_result_t(false);
+ return std::nullopt;
}
module_t::module_t(unsigned count) : triggers(count) {
@@ -367,8 +367,8 @@ std::optional<match_result_t> module_t::detect_trap_match(const trap_t& t) noexc
return std::nullopt;
for (auto trigger: triggers) {
- match_result_t result = trigger->detect_trap_match(proc, t);
- if (result.fire)
+ auto result = trigger->detect_trap_match(proc, t);
+ if (result.has_value())
return result;
}
return std::nullopt;