From adcae5bc1988d28878bcda415544c1828119c17a Mon Sep 17 00:00:00 2001 From: Dev Tyagi Date: Wed, 2 Sep 2026 22:23:20 +0530 Subject: [PATCH] rvfi: fix non-zero mem_rmask on non-memory instructions When an instruction performs no memory access, its rvfi_mem_rmask should be zero. Previously, it defaulted to 4'b1111 (via lsu_type defaulting to 2'b00) and was only zeroed out for stores (data_we_o). This meant every non-memory instruction reported a read mask of 4'b1111, which formally violates the RVFI specification by claiming four bytes were read from an arbitrary address. This gates the assignment of both rvfi_stage_mem_rmask and rvfi_stage_mem_wmask with lsu_req, ensuring they are strictly zeroed when the instruction does not actually issue a memory request. Fixes #2476 --- rtl/ibex_core.sv | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rtl/ibex_core.sv b/rtl/ibex_core.sv index 19ec6f51ff..386123bd3f 100644 --- a/rtl/ibex_core.sv +++ b/rtl/ibex_core.sv @@ -2082,8 +2082,8 @@ module ibex_core import ibex_pkg::*; import ibex_cheriot_pkg::*; #( rvfi_stage_rs3_addr[i] <= rvfi_rs3_addr_d; rvfi_stage_pc_rdata[i] <= pc_id; rvfi_stage_pc_wdata[i] <= pc_set ? branch_target_ex : pc_if; - rvfi_stage_mem_rmask[i] <= data_we_o ? 4'b0000 : rvfi_mem_mask_int; - rvfi_stage_mem_wmask[i] <= data_we_o ? rvfi_mem_mask_int : 4'b0000; + rvfi_stage_mem_rmask[i] <= (lsu_req && !data_we_o) ? rvfi_mem_mask_int : 4'b0000; + rvfi_stage_mem_wmask[i] <= (lsu_req && data_we_o) ? rvfi_mem_mask_int : 4'b0000; rvfi_stage_rs1_rdata[i] <= rvfi_rs1_data_d; rvfi_stage_rs2_rdata[i] <= rvfi_rs2_data_d; rvfi_stage_rs3_rdata[i] <= rvfi_rs3_data_d;