@@ -121,21 +121,20 @@ interface core_ibex_pmp_fcov_if import ibex_pkg::*; #(
121121 assign pmp_iside2_nomatch = ~| pmp_iside2_match;
122122 assign pmp_dside_nomatch = ~| pmp_dside_match;
123123
124- assign misaligned_pmp_err_last = load_store_unit_i.fcov_ls_first_req ?
125- load_store_unit_i.data_pmp_err_i :
126- misaligned_pmp_err_last;
127-
128124 // Store the Data Channel PMP match info from the first request to calculate boundary cross
129125 always @ (posedge clk_i or negedge rst_ni) begin
130126 if (! rst_ni) begin
131- pmp_dside_match_last <= '0 ;
127+ pmp_dside_match_last <= '0 ;
128+ misaligned_pmp_err_last <= 1'b0 ;
132129 end else if (load_store_unit_i.fcov_ls_first_req) begin
133- pmp_dside_match_last <= pmp_dside_match;
130+ pmp_dside_match_last <= pmp_dside_match;
131+ misaligned_pmp_err_last <= load_store_unit_i.data_pmp_err_i;
134132 end
135133 end
136134
137135 assign pmp_iside_boundary_cross = | (pmp_iside_match ^ pmp_iside2_match);
138- assign pmp_dside_boundary_cross = | (pmp_dside_match ^ pmp_dside_match_last);
136+ assign pmp_dside_boundary_cross = | (pmp_dside_match ^ pmp_dside_match_last) &
137+ load_store_unit_i.fcov_ls_second_req;
139138
140139 for (genvar i_region = 0 ; i_region < PMPNumRegions; i_region + = 1 ) begin : g_pmp_region_fcov
141140 pmp_priv_bits_e pmp_region_priv_bits;
@@ -513,7 +512,7 @@ interface core_ibex_pmp_fcov_if import ibex_pkg::*; #(
513512 iff (fcov_csr_write && cs_registers_i.csr_addr_i == CSR_MSECCFG ) {
514513 // Trying to enable RLB when RLB is disabled and locked regions present will result
515514 // with an ignored write
516- bins sticky = binsof (cp_rlb) intersect { 1 } && binsof (cp_wdata_rlb) intersect { 0 }
515+ bins sticky = binsof (cp_rlb) intersect { 0 } && binsof (cp_wdata_rlb) intersect { 1 }
517516 iff (cs_registers_i.g_pmp_registers.any_pmp_entry_locked);
518517 }
519518
@@ -640,16 +639,26 @@ interface core_ibex_pmp_fcov_if import ibex_pkg::*; #(
640639 ignore_bins unsupported_priv_lvl =
641640 binsof (cs_registers_i.mstatus_q.mpp) intersect { PRIV_LVL_H , PRIV_LVL_S } ||
642641 binsof (cs_registers_i.priv_mode_id_o) intersect { PRIV_LVL_H , PRIV_LVL_S } ;
642+
643+ // Cannot have mprv set in U mode (as it is cleared when executing an `mret` which takes the
644+ // hart into U mode).
645+ illegal_bins no_mrpv_in_umode =
646+ binsof (cs_registers_i.priv_mode_id_o) intersect { PRIV_LVL_U } ;
643647 }
644648
645- pmp_instr_edge_cross : cross if_stage_i.instr_is_compressed_id_o ,
649+ pmp_instr_edge_cross : cross if_stage_i.instr_is_compressed_out ,
646650 pmp_iside_req_err, pmp_iside2_req_err
647- iff (pmp_iside_boundary_cross);
651+ iff (pmp_iside_boundary_cross) {
652+ // Compressed instruction cannot see an error over the boundary as it only ever does
653+ // a single 16-bit fetch.
654+ illegal_bins no_iside2_err_on_compressed =
655+ binsof (if_stage_i.instr_is_compressed_out) intersect { 1'b1 } &&
656+ binsof (pmp_iside2_req_err) intersect { 1'b1 } ;
657+ }
648658
649659 misaligned_lsu_access_cross : cross misaligned_pmp_err_last,
650- load_store_unit_i.fcov_ls_mis_pmp_err_2,
651- pmp_dside_boundary_cross;
652-
660+ load_store_unit_i.fcov_ls_mis_pmp_err_2
661+ iff (pmp_dside_boundary_cross);
653662 endgroup
654663
655664 `DV_FCOV_INSTANTIATE_CG (pmp_top_cg, en_pmp_fcov)
0 commit comments