From 67f737add0d53e8803a87dd2edb6f882278b001b Mon Sep 17 00:00:00 2001 From: YazanHussnain-10x Date: Fri, 4 Oct 2024 19:15:21 +0500 Subject: [PATCH] resolve error in NAPOT match option --- model/riscv_step.sail | 8 ++++++-- model/riscv_sys_control.sail | 8 ++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/model/riscv_step.sail b/model/riscv_step.sail index a11d41f2f..e89906857 100644 --- a/model/riscv_step.sail +++ b/model/riscv_step.sail @@ -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: */ diff --git a/model/riscv_sys_control.sail b/model/riscv_sys_control.sail index 54f3d7b9e..331242d0f 100644 --- a/model/riscv_sys_control.sail +++ b/model/riscv_sys_control.sail @@ -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]) }, @@ -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];