Hi all, I defined three
cross
in this code. I would to calculate total and covered bins for all three crosses. Is there a predefined function to do it?
If I have one cross in my covergroup, I do:
pl_cov.get_coverage(covered,total);
How can I do with three crosses?
module Coverage();
import pl_pkg::*;
event smpl;
covergroup pl_coverage @(PL_MONITOR.M_clk);
option.per_instance = 1;
EVENT_TYPE: coverpoint PL_MONITOR.M_Event_type {
bins cp_no_pcon = {NO_PCON};
bins cp_cmd = {CMD};
bins cp_dataout = {DATAOUT};
bins cp_rtt = {RTT};
bins cp_datain = {DATAIN};
bins cp_rsp = {RSP};
bins cp_gpio = {GPIO};
}
WDP: coverpoint PL_MONITOR.M_Wdp_Type {
bins cp_wdp_cmd = {WDP_CMD};
bins cp_wdp_do = {WDP_DO};
}
RDP: coverpoint PL_MONITOR.M_Rdp_Type {
bins cp_rdp_cmd_rsp = {RDP_CMD_RSP};
bins cp_rdp_tm_rsp = {RDP_TM_RSP};
bins cp_rdp_qr_rsp = {RDP_QR_RSP};
bins cp_rdp_rtt = {RDP_RTT};
bins cp_rdp_di = {RDP_DI};
}
GPIO_Ev: coverpoint PL_MONITOR.M_Force_powerloss_n {
bins cp_gpio_event = {1'b0};
}
CROSS1: cross EVENT_TYPE, WDP;
CROSS2: cross EVENT_TYPE, RDP;
CROSS3: cross EVENT_TYPE, GPIO_Ev;
endgroup
pl_coverage pl_cov = new();
function void get_cross_coverage(output int sum_covered, sum_total);
int covered1, covered2, covered3;
int total1, total2, total3;
begin
pl_cov.CROSS1.get_coverage(covered1, total1);
pl_cov.CROSS2.get_coverage(covered2, total2);
pl_cov.CROSS3.get_coverage(covered3, total3);
sum_covered = covered1 + covered2 + covered3;
sum_total = total1 + total2 + total3;
end
endfunction
function void get_cross_perc_coverage(output real total_percentage, input number_of_cross);
real perc1, perc2, perc3;
begin
perc1 = pl_cov.CROSS1.get_coverage();
perc2 = pl_cov.CROSS2.get_coverage();
perc3 = pl_cov.CROSS3.get_coverage();
total_percentage = (perc1 + perc2 + perc3) / number_of_cross;
end
endfunction
endmodule