Skip to content

Commit

Permalink
add remaining mcontrol6 match options
Browse files Browse the repository at this point in the history
  • Loading branch information
YazanHussnain-10x committed Oct 4, 2024
1 parent 980af42 commit 9fcaa74
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 16 deletions.
35 changes: 27 additions & 8 deletions model/riscv_sys_control.sail
Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,14 @@ function instrDataMatch(cur_priv : Privilege, addr : xlenbits, data : xlenbits,
let matchOption : bits(4) = MCtrl6[match_opt];
/* Decide content to match address/data based on select bit */
let tdata2_content : xlenbits = match (MCtrl6[select]) {
0b0 => addr,
0b1 => data
0b0 => { size_matched = true; addr },
0b1 => {
size_matched = match matchSize_of_bits(MCtrl6[size]) {
ANY => true,
_ => (match_size == matchSize_of_bits(MCtrl6[size])),
};
data
}
};
/* Data matched according to the select match options */
data_matched = match (matchOpt_of_bits(matchOption)) {
Expand All @@ -595,14 +601,27 @@ function instrDataMatch(cur_priv : Privilege, addr : xlenbits, data : xlenbits,
let idx : {'n, (1 <= 'n < xlen). int('n)} = find_first_zero(tdata2_content);
tdata2_x.tdata2[i][(xlen - 1) .. (xlen - idx)] == tdata2_content[(xlen - 1) .. (xlen - idx)]
},
MOPT_GE => { (tdata2_x.tdata2[i][(sizeof(xlen) - 1) .. 0] >=_u tdata2_content) },
MOPT_LT => { (tdata2_x.tdata2[i][(sizeof(xlen) - 1) .. 0] <_u tdata2_content) },
MOPT_GE => { (tdata2_content >=_u tdata2_x.tdata2[i][(sizeof(xlen) - 1) .. 0]) },
MOPT_LT => { (tdata2_content <_u tdata2_x.tdata2[i][(sizeof(xlen) - 1) .. 0]) },
MOPT_MASK_LOW => {
let intemrd_cmpr_val : half_xlenbits = tdata2_content[((sizeof(xlen) / 2) - 1) .. 0] & tdata2_x.tdata2[i][(sizeof(xlen) - 1) .. (sizeof(xlen) / 2)];
intemrd_cmpr_val == tdata2_x.tdata2[i][((sizeof(xlen) / 2) - 1) .. 0]
},
MOPT_MASK_HIGH => {
let intemrd_cmpr_val : half_xlenbits = tdata2_content[(sizeof(xlen) - 1) .. (sizeof(xlen) / 2)] & tdata2_x.tdata2[i][(sizeof(xlen) - 1) .. (sizeof(xlen) / 2)];
intemrd_cmpr_val == tdata2_x.tdata2[i][((sizeof(xlen) / 2) - 1) .. 0]
},
MOPT_NOT_EQUAL => { (tdata2_x.tdata2[i] != tdata2_content) },
MOPT_NOT_MASK_LOW => {
let intemrd_cmpr_val : half_xlenbits = tdata2_content[((sizeof(xlen) / 2) - 1) .. 0] & tdata2_x.tdata2[i][(sizeof(xlen) - 1) .. (sizeof(xlen) / 2)];
intemrd_cmpr_val != tdata2_x.tdata2[i][((sizeof(xlen) / 2) - 1) .. 0]
},
MOPT_NOT_MASK_HIGH => {
let intemrd_cmpr_val : half_xlenbits = tdata2_content[(sizeof(xlen) - 1) .. (sizeof(xlen) / 2)] & tdata2_x.tdata2[i][(sizeof(xlen) - 1) .. (sizeof(xlen) / 2)];
intemrd_cmpr_val != tdata2_x.tdata2[i][((sizeof(xlen) / 2) - 1) .. 0]
},
_ => false
};
size_matched = match matchSize_of_bits(MCtrl6[size]) {
ANY => true,
_ => (match_size == matchSize_of_bits(MCtrl6[size])),
};
if ((((MCtrl6[m] == 0b1) & (cur_priv == Machine)) | /* Trigger is enabled in M-mode */
((MCtrl6[s] == 0b1) & (cur_priv == Supervisor)) | /* Trigger is enabled in S-mode */
((MCtrl6[u] == 0b1) & (cur_priv == User)) ) & /* Trigger is enabled in U-mode */
Expand Down
9 changes: 1 addition & 8 deletions model/riscv_sys_regs.sail
Original file line number Diff line number Diff line change
Expand Up @@ -918,14 +918,7 @@ function legalize_tdata1(o : xlenbits, v : xlenbits) -> xlenbits = {
/* m | uncertainen | s | u | execute | store | load */
new_value[6 .. 0] = MCtrl6.bits[6 .. 0];
/* match */
if (
match_option == MOPT_EQUAL |
match_option == MOPT_GE |
match_option == MOPT_LT |
match_option == MOPT_NAPOT
)
then { new_value[10 .. 7] = v[10 .. 7] }
else { new_value[10 .. 7] = o[10 .. 7] };
new_value[10 .. 7] = v[10 .. 7];
/* size | action | chain */
new_value[18 .. 11] = (MCtrl6[size] @ trigger_action[3 .. 0] @ MCtrl6[chain]);
/* hit0 | select */
Expand Down
3 changes: 3 additions & 0 deletions model/riscv_xlen.sail
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ type xlen_bytes : Int = 2 ^ log2_xlen_bytes
type xlen : Int = xlen_bytes * 8
type xlenbits = bits(xlen)

type half_xlen_bytes : Int = 2 ^ (log2_xlen_bytes - 1)
type half_xlen : Int = half_xlen_bytes * 8
type half_xlenbits = bits(half_xlen)
// Variable versions of the above types. Variables and types
// are disjoint in Sail so they are allowed to have the same name.
// This saves typing `sizeof()` everywhere.
Expand Down

0 comments on commit 9fcaa74

Please sign in to comment.