Skip to content

Commit

Permalink
resolve error in NAPOT match option
Browse files Browse the repository at this point in the history
  • Loading branch information
YazanHussnain-10x committed Oct 5, 2024
1 parent d0c9bb0 commit 67f737a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 6 additions & 2 deletions model/riscv_step.sail
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,16 @@ function step(step_no : int) -> bool = {
match ext_fetch_hook(fetch()) {
/* extension error */
F_Ext_Error(e) => {
ext_handle_fetch_check_error(e);
if not(instrDataMatch(cur_privilege, PC, zero_extend(0b0), ANY, INSTR_MATCH)) then {
ext_handle_fetch_check_error(e);
};
(RETIRE_FAIL, false)
},
/* standard error */
F_Error(e, addr) => {
handle_mem_exception(addr, e);
if not(instrDataMatch(cur_privilege, PC, zero_extend(0b0), ANY, INSTR_MATCH)) then {
handle_mem_exception(addr, e);
};
(RETIRE_FAIL, false)
},
/* non-error cases: */
Expand Down
8 changes: 4 additions & 4 deletions model/riscv_sys_control.sail
Original file line number Diff line number Diff line change
Expand Up @@ -599,8 +599,8 @@ function instrDataMatch(cur_priv : Privilege, addr : xlenbits, data : xlenbits,
data_matched = match (matchOpt_of_bits(matchOption)) {
MOPT_EQUAL => { (tdata2_x.tdata2[i] == tdata2_content) },
MOPT_NAPOT => {
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)]
let idx : {'n, (1 <= 'n < xlen). int('n)} = find_first_zero(tdata2_x.tdata2[i]);
tdata2_x.tdata2[i][(xlen - 1) .. idx] == tdata2_content[(xlen - 1) .. idx]
},
MOPT_GE => { (tdata2_content >=_u tdata2_x.tdata2[i][(xlen - 1) .. 0]) },
MOPT_LT => { (tdata2_content <_u tdata2_x.tdata2[i][(xlen - 1) .. 0]) },
Expand All @@ -614,8 +614,8 @@ function instrDataMatch(cur_priv : Privilege, addr : xlenbits, data : xlenbits,
},
MOPT_NOT_EQUAL => { (tdata2_x.tdata2[i] != tdata2_content) },
MOPT_NOT_NAPOT => {
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)]
let idx : {'n, (1 <= 'n < xlen). int('n)} = find_first_zero(tdata2_x.tdata2[i]);
tdata2_x.tdata2[i][(xlen - 1) .. idx] != tdata2_content[(xlen - 1) .. idx]
},
MOPT_NOT_MASK_LOW => {
let intemrd_cmpr_val : half_xlenbits = tdata2_content[(half_xlen - 1) .. 0] & tdata2_x.tdata2[i][(xlen - 1) .. half_xlen];
Expand Down

0 comments on commit 67f737a

Please sign in to comment.