Skip to content

Commit

Permalink
Fix issue found in random test
Browse files Browse the repository at this point in the history
Signed-off-by: dd-baoshan <[email protected]>
  • Loading branch information
dd-baoshan committed Jun 19, 2024
1 parent b928395 commit 4bc5cfa
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions cv32e40p/env/uvme/cov/uvme_rv32x_hwloop_covg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,7 @@ class uvme_rv32x_hwloop_covg # (
if (is_init_mmode_mret && pending_irq_ack) begin
is_init_mmode_mret = 0;
pending_irq_ack = 0;
wait(0); // stop this thread
end
end // INIT_MACHINE_MODE
forever begin : IRQ_PERIOD
Expand Down Expand Up @@ -963,6 +964,8 @@ class uvme_rv32x_hwloop_covg # (
enter_hwloop_sub_cnt++;
if (is_trap && is_dbg_mode && !cv32e40p_rvvi_vif.csr_dcsr_step && enter_hwloop_sub_cnt == 1) begin : TRAP_DUETO_DBG_ENTRY // exception trap and debug are b2b cycles (except debug step)
has_pending_trap_due2_dbg = 1;
enter_hwloop_sub = 0; enter_hwloop_sub_cnt = 0;
is_ebreak = 0; is_ecall = 0; is_illegal = 0; is_trap = 0;
end // TRAP_DUETO_DBG_ENTRY
else if (pc_is_mtvec_addr() && !is_mcause_irq()) begin : EXCEPTION_ENTRY
for (int i=0; i<HWLOOP_NB; i++) begin
Expand All @@ -983,8 +986,8 @@ class uvme_rv32x_hwloop_covg # (
if (prev_is_lpend_main[0] && prev_is_trap) hwloop_stat_main.track_lp_cnt[0]++;
if (prev_is_lpend_main[1] && prev_is_trap) hwloop_stat_main.track_lp_cnt[1]++;
has_pending_trap_due2_irq = 1;
is_ebreak = 0; is_ecall = 0; is_illegal = 0; is_trap = 0;
enter_hwloop_sub = 0; enter_hwloop_sub_cnt = 0;
is_ebreak = 0; is_ecall = 0; is_illegal = 0; is_trap = 0;
pending_irq = 0;
`uvm_info(_header, $sformatf("DEBUG - EXCEPTION Entry is replaced with IRQ Entry (higher priority)"), UVM_DEBUG);
`IF_CURRENT_IS_MAIN_HWLOOP(0, IS_IRQ)
Expand All @@ -1002,13 +1005,9 @@ class uvme_rv32x_hwloop_covg # (
// [optional] todo: mie has effect on irq during exception. Current hwloop tests do not exercise nested irq with mie enabled

check_exception_exit();
if (!(is_ebreak || is_ecall || is_illegal || has_pending_trap_due2_dbg || has_pending_trap_due2_irq)) begin
if (!(is_trap || is_ebreak || is_ecall || is_illegal || has_pending_trap_due2_dbg || has_pending_trap_due2_irq)) begin
enter_hwloop_sub = 0; enter_hwloop_sub_cnt = 0;
end
else if (has_pending_trap_due2_dbg) begin
enter_hwloop_sub = 0; enter_hwloop_sub_cnt = 0;
is_ebreak = 0; is_ecall = 0; is_illegal = 0; is_trap = 0;
end
prev_pc_rdata_sub = cv32e40p_rvvi_vif.pc_rdata;

end // ENTER_HWLOOP_SUB
Expand All @@ -1029,7 +1028,7 @@ class uvme_rv32x_hwloop_covg # (
if (has_pending_trap_due2_irq) begin
assert(prev_pc_rdata_main == cv32e40p_rvvi_vif.pc_rdata);
if (pc_is_mtvec_addr() || (cv32e40p_rvvi_vif.trap && is_trap)) begin is_trap = 1; enter_hwloop_sub = 1; has_pending_trap_due2_irq = 0; continue; end // if pc is exception related
else begin is_ebreak = 0; is_ecall = 0; is_illegal = 0; is_trap = 0; enter_hwloop_sub = 0; has_pending_trap_due2_irq = 0; continue; end // if pc is non-exception related
else begin is_ebreak = 0; is_ecall = 0; is_illegal = 0; is_trap = 0; enter_hwloop_sub = 0; has_pending_trap_due2_irq = 0; end // if pc is non-exception related
end
if (is_dbg_mode) begin
if (prev_is_lpend_main[0] && prev_is_trap && !is_ebreakm) hwloop_stat_main.track_lp_cnt[0]++;
Expand All @@ -1039,7 +1038,7 @@ class uvme_rv32x_hwloop_covg # (
if (has_pending_trap_due2_dbg) begin // e.g exception event intercept with debug step
assert (!dcsr_cause_t'(cv32e40p_rvvi_vif.csr_dcsr_cause) != STEP); // this is not mean for step debug
if (pc_is_mtvec_addr() || (cv32e40p_rvvi_vif.trap && is_trap)) begin is_trap = 1; enter_hwloop_sub = 1; has_pending_trap_due2_dbg = 0; continue; end // if pc is exception related
else begin is_ebreak = 0; is_ecall = 0; is_illegal = 0; is_trap = 0; enter_hwloop_sub = 0; has_pending_trap_due2_dbg = 0; continue; end // if pc is non-exception related
else begin is_ebreak = 0; is_ecall = 0; is_illegal = 0; is_trap = 0; enter_hwloop_sub = 0; has_pending_trap_due2_dbg = 0; end // if pc is non-exception related
end
if (cv32e40p_rvvi_vif.csr_dcsr_ebreakm && cv32e40p_rvvi_vif.insn == TB_INSTR_EBREAK) is_ebreakm = 1; else is_ebreakm = 0;
if (cv32e40p_rvvi_vif.trap) prev_is_trap = 1; else prev_is_trap = 0;
Expand Down

0 comments on commit 4bc5cfa

Please sign in to comment.