Suppose I have the coverpoints and crosses shown in the code below. Can you please let me know why is my code not working and any alternative that I could try.
Hi Sohan,
Please check my last comment. That is working fine. I just want to know why can’t I use an array instead of explicitly mentioning individual addresses. The example I shared above is giving compilation errors.
why are you clubbing 4 addresses in 1 bin?
These addresses are for registers (32 bits) in a byte addressed memory. So, 0008_0000 - 0008_003 belongs to single register.
I am having a similar situation wherein I need to ignore the array of bins in cross coverage. I tried with the “with” clause but it is not working. It is resulting in a compilation error stating An expression with an unpacked array datatype is not allowed in this context [SystemVerilog]. Any suggestions here?
It would help to provide a minimal, complete, reproducible example like below. This correctly removes three bins <pos[1]/f0>,<pos[2]/f0>, and <pos[3]/f0> from the cross:
class wrapper_cg;
covergroup cg_test(int DS, string name_cg, int ignore_bitpos_f0[3]) with function sample(int bit_pos, bit fi_val);
option.per_instance = 1;
option.name = name_cg;
BIT_POS : coverpoint bit_pos {
bins pos[] = {[0:(DS-1)]} ;
}
FORCED_VALUE : coverpoint fi_val {
bins f0 = {0};
bins f1 = {1};
}
BIT_POS_X_FORCED_VALUE : cross BIT_POS, FORCED_VALUE {
ignore_bins ign_bins = (binsof(BIT_POS) with (BIT_POS inside {ignore_bitpos_f0}) && binsof(FORCED_VALUE) intersect {0});
}
endgroup: cg_test
function new(int ds, string n, int ign_bitpos_f0[3]);
this.cg_test = new(ds, n, ign_bitpos_f0);
endfunction
endclass
// test
module top;
wrapper_cg cg_wrapper [];
initial begin
// create an array of cover group wrapper class
cg_wrapper = new[50];
foreach (cg_wrapper[i]) begin
cg_wrapper[i] = new(5, $sformatf("cg_%0d",i), '{1, 2, 3});
end
end
endmodule
Thank you for your reply.
I did follow the above approach to ignore the cross coverage bins but it is not working as expected. Instead of 3 bins, only one bin (pos[1]/f0) is ignored.