Skip to content

Commit

Permalink
Make allow_action() take proc instead of state
Browse files Browse the repository at this point in the history
  • Loading branch information
rtwfroody committed Sep 5, 2024
1 parent 9c5a20f commit 4abd669
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions riscv/triggers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,9 @@ bool trigger_t::textra_match(processor_t * const proc) const noexcept
return true;
}

bool trigger_t::allow_action(const state_t * const state) const
bool trigger_t::allow_action(processor_t * const proc) const
{
const state_t *state = proc->get_state();
if (get_action() == ACTION_DEBUG_EXCEPTION) {
const bool mstatus_mie = state->mstatus->read() & MSTATUS_MIE;
const bool sstatus_sie = state->sstatus->read() & MSTATUS_SIE;
Expand Down Expand Up @@ -242,7 +243,7 @@ std::optional<match_result_t> mcontrol_common_t::detect_memory_access_match(proc
value &= 0xffffffff;
}

if (simple_match(xlen, value) && allow_action(proc->get_state())) {
if (simple_match(xlen, value) && allow_action(proc)) {
/* This is OK because this function is only called if the trigger was not
* inhibited by the previous trigger in the chain. */
set_hit(timing ? HIT_IMMEDIATELY_AFTER : HIT_BEFORE);
Expand Down Expand Up @@ -331,7 +332,7 @@ void mcontrol6_t::tdata1_write(processor_t * const proc, const reg_t val, const

std::optional<match_result_t> icount_t::detect_icount_fire(processor_t * const proc) noexcept
{
if (!common_match(proc) || !allow_action(proc->get_state()))
if (!common_match(proc) || !allow_action(proc))
return std::nullopt;

std::optional<match_result_t> ret = std::nullopt;
Expand All @@ -346,7 +347,7 @@ std::optional<match_result_t> icount_t::detect_icount_fire(processor_t * const p

void icount_t::detect_icount_decrement(processor_t * const proc) noexcept
{
if (!common_match(proc) || !allow_action(proc->get_state()))
if (!common_match(proc) || !allow_action(proc))
return;

if (count >= 1) {
Expand Down Expand Up @@ -438,7 +439,7 @@ std::optional<match_result_t> trap_common_t::detect_trap_match(processor_t * con
bool interrupt = (t.cause() & ((reg_t)1 << (xlen - 1))) != 0;
reg_t bit = t.cause() & ~((reg_t)1 << (xlen - 1));
assert(bit < xlen);
if (simple_match(interrupt, bit) && allow_action(proc->get_state())) {
if (simple_match(interrupt, bit) && allow_action(proc)) {
hit = true;
return match_result_t(TIMING_AFTER, action);
}
Expand Down
2 changes: 1 addition & 1 deletion riscv/triggers.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class trigger_t {
protected:
static action_t legalize_action(reg_t val, reg_t action_mask, reg_t dmode_mask) noexcept;
bool common_match(processor_t * const proc, bool use_prev_prv = false) const noexcept;
bool allow_action(const state_t * const state) const;
bool allow_action(processor_t * const proc) const;
reg_t tdata2;

bool vs = false;
Expand Down

0 comments on commit 4abd669

Please sign in to comment.