Skip to content

Commit

Permalink
triggers: Let mcontrol.match be default (0/equal) if maskmax is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
YenHaoChen committed Aug 27, 2024
1 parent d13dc0b commit 1510a6e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions riscv/triggers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ void mcontrol_t::tdata1_write(processor_t * const proc, const reg_t val, const b
timing = legalize_timing(val, MCONTROL_TIMING, MCONTROL_SELECT, MCONTROL_EXECUTE, MCONTROL_LOAD);
action = legalize_action(val, MCONTROL_ACTION, CSR_MCONTROL_DMODE(xlen));
chain = allow_chain ? get_field(val, MCONTROL_CHAIN) : 0;
match = legalize_match(get_field(val, MCONTROL_MATCH));
match = legalize_match(get_field(val, MCONTROL_MATCH), maskmax);
m = get_field(val, MCONTROL_M);
s = proc->extension_enabled_const('S') ? get_field(val, CSR_MCONTROL_S) : 0;
u = proc->extension_enabled_const('U') ? get_field(val, CSR_MCONTROL_U) : 0;
Expand Down Expand Up @@ -244,11 +244,11 @@ std::optional<match_result_t> mcontrol_common_t::detect_memory_access_match(proc
return std::nullopt;
}

mcontrol_common_t::match_t mcontrol_common_t::legalize_match(reg_t val) noexcept
mcontrol_common_t::match_t mcontrol_common_t::legalize_match(reg_t val, reg_t maskmax) noexcept
{
switch (val) {
case MATCH_NAPOT: if (maskmax == 0) return MATCH_EQUAL;
case MATCH_EQUAL:
case MATCH_NAPOT:
case MATCH_GE:
case MATCH_LT:
case MATCH_MASK_LOW:
Expand Down Expand Up @@ -294,13 +294,14 @@ void mcontrol6_t::tdata1_write(processor_t * const proc, const reg_t val, const
auto xlen = proc->get_const_xlen();
assert(get_field(val, CSR_MCONTROL6_TYPE(xlen)) == CSR_TDATA1_TYPE_MCONTROL6);
dmode = get_field(val, CSR_MCONTROL6_DMODE(xlen));
const reg_t maskmax6 = xlen - 1;
vs = get_field(val, CSR_MCONTROL6_VS);
vu = get_field(val, CSR_MCONTROL6_VU);
hit = hit_t(2 * get_field(val, CSR_MCONTROL6_HIT1) + get_field(val, CSR_MCONTROL6_HIT0)); // 2-bit field {hit1,hit0}
select = get_field(val, CSR_MCONTROL6_SELECT);
action = legalize_action(val, CSR_MCONTROL6_ACTION, CSR_MCONTROL6_DMODE(xlen));
chain = allow_chain ? get_field(val, CSR_MCONTROL6_CHAIN) : 0;
match = legalize_match(get_field(val, CSR_MCONTROL6_MATCH));
match = legalize_match(get_field(val, CSR_MCONTROL6_MATCH), maskmax6);
m = get_field(val, CSR_MCONTROL6_M);
s = proc->extension_enabled_const('S') ? get_field(val, CSR_MCONTROL6_S) : 0;
u = proc->extension_enabled_const('U') ? get_field(val, CSR_MCONTROL6_U) : 0;
Expand Down
2 changes: 1 addition & 1 deletion riscv/triggers.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class mcontrol_common_t : public trigger_t {
bool simple_match(unsigned xlen, reg_t value) const;

protected:
static match_t legalize_match(reg_t val) noexcept;
static match_t legalize_match(reg_t val, reg_t maskmax) noexcept;
static bool legalize_timing(reg_t val, reg_t timing_mask, reg_t select_mask, reg_t execute_mask, reg_t load_mask) noexcept;
bool dmode = false;
action_t action = ACTION_DEBUG_EXCEPTION;
Expand Down

0 comments on commit 1510a6e

Please sign in to comment.