Skip to content

Commit

Permalink
Merge pull request riscv-software-src#1771 from rtwfroody/match_mask
Browse files Browse the repository at this point in the history
Fix mcontrol6 mask low/high operations.
  • Loading branch information
aswaterman authored Aug 19, 2024
2 parents f09b024 + 1a15805 commit a8c9d9c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions riscv/triggers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,17 @@ bool mcontrol_common_t::simple_match(unsigned xlen, reg_t value) const {
return value < tdata2;
case MATCH_MASK_LOW:
{
reg_t mask = tdata2 >> (xlen/2);
return (value & mask) == (tdata2 & mask);
reg_t tdata2_high = tdata2 >> (xlen/2);
reg_t tdata2_low = tdata2 & ((reg_t(1) << (xlen/2)) - 1);
reg_t value_low = value & ((reg_t(1) << (xlen/2)) - 1);
return (value_low & tdata2_high) == tdata2_low;
}
case MATCH_MASK_HIGH:
{
reg_t mask = tdata2 >> (xlen/2);
return ((value >> (xlen/2)) & mask) == (tdata2 & mask);
reg_t tdata2_high = tdata2 >> (xlen/2);
reg_t tdata2_low = tdata2 & ((reg_t(1) << (xlen/2)) - 1);
reg_t value_high = value >> (xlen/2);
return (value_high & tdata2_high) == tdata2_low;
}
}
assert(0);
Expand Down

0 comments on commit a8c9d9c

Please sign in to comment.