is there a way to guard the creation of the an explicitly named bin as seen here
coverpoints_bins: coverpoint signal_a
bins a1 = {1};
bins a2 = {2};
bins a4 = {4}; <--- create bin a4 only if parameter "CREATE_A4 is 1"
for example something like this :
coverpoints_bins: coverpoint signal_a
bins a1 = {1};
bins a2 = {2};
bins a4 = {4} create_iff(CREATE_A4 == 1);
note: create_iff is just some pseudocode function to guard against the creation of bins unless the condition is true
because to my knowledge the iff
condition does not guard against the creation of the bins but iff
only serves to guard against a bin hit
You can use the with
clause to select bins
bins a4 = {4} with (CREATE_A4 == 1);
This will likely generate a warning message saying you have an empty bin set. Another way of doing this is using a bin set array.
int my_bins[];
...
if (CREATE_A4 == 1) // execute this before constructing the covergroup
my_bins = {1,2,4};
else
my_bins = {1,2};
...
coverpoints_bins: coverpoint signal_a
bins a[] = my_bins;