module tb;
logic [1:0] a,b;
logic sel;
covergroup c;
option.per_instance = 1;
coverpoint a{
wildcard bins a_={2'b??} with (sel);
}
coverpoint b{
wildcard bins b_={2'b??} iff (!sel);
}
endgroup
c ci;
initial begin
ci=new();
repeat(10) begin
a=$random;
b=$random;
sel=$random;
$display("%d %d %d",a,b,sel);
ci.sample();
#1;
end
end
endmodule
Coverage is not showing when I am using with
, but when I use iff
in place of with
, it's working. What I am doing wrong?
The with
clause in a bin expression gets evaluated once at the point when the covergroup
gets constructed and determines the set of which bin values that get created as part of a coverpoint
. Since sel
is uninitialized at that point, there are no bins created for coverpoint a
.
The iff
clause in a bin expression gets evaluated each time the covergroup
gets sampled and is effectively a sample enable expression. It has no effect on the selection of bin values created.
Most likely using iff
matches your intended behavior.