Skip to content

Commit

Permalink
Merge pull request #2565 from silabs-robin/rvfi_instr_if_clicptr
Browse files Browse the repository at this point in the history
RVFI INSTR IF - Heed `clicptr` in `is_instr_bus_valid`
  • Loading branch information
silabs-robin authored Dec 16, 2024
2 parents 76311ec + 237b3a9 commit bb392a2
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions lib/uvm_agents/uvma_rvfi/uvma_rvfi_instr_if.sv
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,9 @@ interface uvma_rvfi_instr_if_t


// -------------------------------------------------------------------
// Local variables
// Signals
// -------------------------------------------------------------------

int unsigned irq_cnt; // number of taken interrupts
int unsigned nmi_instr_cnt; // number of instructions after nmi
int unsigned single_step_cnt; // number of instructions stepped
Expand Down Expand Up @@ -275,6 +276,10 @@ interface uvma_rvfi_instr_if_t

asm_t instr_asm;

wire is_exception_cause_instr_acc_fault = (rvfi_trap.exception_cause == EXC_CAUSE_INSTR_ACC_FAULT);
wire is_exception_cause_integrity_fault = (rvfi_trap.exception_cause == EXC_CAUSE_INSTR_INTEGRITY_FAULT);
wire is_exception_cause_bus_fault = (rvfi_trap.exception_cause == EXC_CAUSE_INSTR_BUS_FAULT);

// -------------------------------------------------------------------
// Begin module code
// -------------------------------------------------------------------
Expand Down Expand Up @@ -335,7 +340,7 @@ interface uvma_rvfi_instr_if_t
end

always_comb begin
is_mret = is_mret_f();
is_mret = match_instr(INSTR_OPCODE_MRET, INSTR_MASK_FULL);
end

always_comb begin
Expand Down Expand Up @@ -437,7 +442,15 @@ interface uvma_rvfi_instr_if_t
end

always_comb begin
is_instr_bus_valid = is_instr_bus_valid_f();
is_instr_bus_valid = (
(
!is_exception_cause_bus_fault &&
!is_exception_cause_integrity_fault &&
!is_exception_cause_instr_acc_fault
) ||
rvfi_trap.clicptr
//Note: `clicptr` pertains to the fetch of the next instr. See the user manual.
);
end

always_comb begin
Expand Down Expand Up @@ -623,6 +636,7 @@ interface uvma_rvfi_instr_if_t

modport passive_mp (clocking mon_cb);


// -------------------------------------------------------------------
// Functions
// -------------------------------------------------------------------
Expand All @@ -637,9 +651,11 @@ interface uvma_rvfi_instr_if_t
logic [ XLEN-1:0] instr_ref,
logic [ XLEN-1:0] instr_mask
);

return rvfi_valid && is_instr_bus_valid && ((rvfi_insn & instr_mask) == instr_ref);

return (
rvfi_valid &&
is_instr_bus_valid &&
((rvfi_insn & instr_mask) == instr_ref)
);
endfunction : match_instr

// Check if instruction is of a certain type, without verifying the instr word is valid
Expand Down Expand Up @@ -841,10 +857,6 @@ function automatic logic is_dret_f();
return match_instr(INSTR_OPCODE_DRET, INSTR_MASK_FULL);
endfunction : is_dret_f

function automatic logic is_mret_f();
return match_instr(INSTR_OPCODE_MRET, INSTR_MASK_FULL);
endfunction : is_mret_f

function automatic logic is_uret_f();
return match_instr(INSTR_OPCODE_URET, INSTR_MASK_FULL);
endfunction : is_uret_f
Expand Down Expand Up @@ -967,13 +979,6 @@ function automatic logic is_pma_fault_f();
(rvfi_trap.cause_type == 'h 0);
endfunction : is_pma_fault_f

function automatic logic is_instr_bus_valid_f();
return !( (rvfi_trap.exception_cause == EXC_CAUSE_INSTR_ACC_FAULT) ||
(rvfi_trap.exception_cause == EXC_CAUSE_INSTR_INTEGRITY_FAULT) ||
(rvfi_trap.exception_cause == EXC_CAUSE_INSTR_BUS_FAULT)
);
endfunction : is_instr_bus_valid_f

function automatic logic [31:0] rvfi_mem_addr_word0highbyte_f();
logic [31:0] addr = rvfi_mem_addr[31:0];
case (1)
Expand Down

0 comments on commit bb392a2

Please sign in to comment.