diff --git a/cv32e40p/env/uvme/cov/uvme_rv32x_hwloop_covg.sv b/cv32e40p/env/uvme/cov/uvme_rv32x_hwloop_covg.sv index 9678860afc..4f34828011 100644 --- a/cv32e40p/env/uvme/cov/uvme_rv32x_hwloop_covg.sv +++ b/cv32e40p/env/uvme/cov/uvme_rv32x_hwloop_covg.sv @@ -99,7 +99,7 @@ class uvme_rv32x_hwloop_covg # ( local bit [(ILEN-1):0] insn_list_in_hwloop_``TYPE [HWLOOP_NB][$]; \ local bit [(ILEN-1):0] mc_insn_list_in_hwloop_``TYPE [HWLOOP_NB][$]; \ local bit [31:0] irq_vect_``TYPE [HWLOOP_NB][$]; \ - local bit lpend_has_pending_irq_``TYPE [HWLOOP_NB] = '{default:0}; \ + local bit prev_is_lpend_``TYPE [HWLOOP_NB] = '{default:0}; \ local bit done_insn_list_capture_``TYPE [HWLOOP_NB] = '{default:0}; \ local bit done_insn_list_capture_d1_``TYPE [HWLOOP_NB] = '{default:0}; \ local s_hwloop_cov hwloop_cov_``TYPE [HWLOOP_NB] = '{default:0}; @@ -121,9 +121,12 @@ class uvme_rv32x_hwloop_covg # ( int enter_hwloop_sub_cnt = 0; bit pending_irq = 0; bit pending_irq_ack = 0; + bit is_init_mmode_mret = 0; logic [31:0] valid_irq_prev = 32'h0; logic [31:0] prev_irq_onehot_priority = 0, prev_irq_onehot_priority_always = 0; bit prev_irq_onehot_priority_is_0 = 0; + bit prev_is_trap = 0; + bit irq_period = 0; // track irq handling period throught the simulation dcsr_cause_t dcsr_cause; exception_code_t exception_code; @@ -485,11 +488,14 @@ class uvme_rv32x_hwloop_covg # ( end // UPDATE_HWLOOP_STAT \ for (int i=0; i= 0); \ @@ -524,7 +530,10 @@ class uvme_rv32x_hwloop_covg # ( else if (hwloop_stat_``TYPE``.hwloop_type == NESTED && hwloop_stat_``TYPE``.track_lp_cnt[0] == 0 && in_nested_loop0) begin \ in_nested_loop0 = 0; continue; \ end \ - if (!done_insn_list_capture_``TYPE``[i]) begin \ + if (!done_insn_list_capture_``TYPE``[i] && has_trap_due2_dbg_match_trig) begin \ + // bypass and do nothing \ + end \ + else if (!done_insn_list_capture_``TYPE``[i]) begin \ if (is_illegal) insn_list_in_hwloop_``TYPE``[i].push_back(INSN_ILLEGAL); \ else if (is_ebreakm) insn_list_in_hwloop_``TYPE``[i].push_back(INSN_EBREAKM); \ else insn_list_in_hwloop_``TYPE``[i].push_back(cv32e40p_rvvi_vif.insn); \ @@ -545,7 +554,7 @@ class uvme_rv32x_hwloop_covg # ( check_ebreakm_entry(i); \ end \ if (is_pc_equal_lpend(hwloop_stat_``TYPE``.hwloop_csr, i, 0, cv32e40p_rvvi_vif.pc_rdata) && hwloop_stat_``TYPE``.track_lp_cnt[i] != 0) begin \ - if (pending_irq_ack && cv32e40p_rvvi_vif.trap) lpend_has_pending_irq_``TYPE``[i] = 1; \ + prev_is_lpend_``TYPE``[i] = 1; \ hwloop_stat_``TYPE``.track_lp_cnt[i]--; \ done_insn_list_capture_``TYPE``[i] = 1; \ assert(hwloop_stat_``TYPE``.track_lp_cnt[i] >= 0); \ @@ -747,7 +756,7 @@ class uvme_rv32x_hwloop_covg # ( end \ hwloop_evt_loc_``TYPE``[i][MC_INSN].delete(); \ hwloop_cov_``TYPE``[i].en_cov_mc_insn = 0; \ - lpend_has_pending_irq_``TYPE``[i] = 0; \ + prev_is_lpend_``TYPE``[i] = 0; \ done_insn_list_capture_``TYPE``[i] = 0; \ done_insn_list_capture_d1_``TYPE``[i] = 0; \ hwloop_cov_``TYPE``[i] = hwloop_cov_init[i]; \ @@ -783,7 +792,7 @@ class uvme_rv32x_hwloop_covg # ( endfunction : check_exception_entry function void check_ebreakm_entry(int lp_idx); - if (cv32e40p_rvvi_vif.csr_dcsr_ebreakm && cv32e40p_rvvi_vif.insn == TB_INSTR_EBREAK) begin + if (is_ebreakm) begin if (lp_idx) begin `IF_CURRENT_IS_MAIN_HWLOOP(1, DBG_EBREAKM) end else begin `IF_CURRENT_IS_MAIN_HWLOOP(0, DBG_EBREAKM) end end @@ -821,8 +830,8 @@ class uvme_rv32x_hwloop_covg # ( cv32e40p_rvvi_vif.csr_trig_execute && cv32e40p_rvvi_vif.csr_trig_pc == cv32e40p_rvvi_vif.pc_rdata // debug trig match assert trap ) begin is_trap = 0; - wait (!cv32e40p_rvvi_vif.trap); // bypass and do nothing has_trap_due2_dbg_match_trig = 1; + wait (!cv32e40p_rvvi_vif.trap); // bypass and do nothing end else if ((cv32e40p_rvvi_vif.csr_dcsr_step || !pending_irq_ack) && !is_dbg_mode && !is_irq) begin // set excep flag only if no pending irq is serving, not in irq and not in dbg mode is_trap = 1; @@ -850,7 +859,7 @@ class uvme_rv32x_hwloop_covg # ( end forever begin : SET_PENDING_IRQ_ACK @(cv32e40p_rvvi_vif.valid_irq); - if (cv32e40p_rvvi_vif.valid_irq < valid_irq_prev) begin + if (cv32e40p_rvvi_vif.valid_irq < valid_irq_prev && !irq_period) begin // currently not cover on nested irq pending_irq_ack = 1; end valid_irq_prev = cv32e40p_rvvi_vif.valid_irq; @@ -888,20 +897,24 @@ class uvme_rv32x_hwloop_covg # ( is_irq = 0; end end // IRQ_EXIT - forever begin : SIGNALS_CHG_WHEN_IS_IRQ_ASSERT - @(posedge is_irq); - if (is_ebreakm) begin // TBD: will ebreakm assert trap? - for (int j=0; j