With this wildcard method, I am able to achieve desired coverage, but let’s say if I have 32 bit register and want to write coverage on that, then wildcard will be messy,
I can not use 32’b???..??? (?/X for 32 bits). So, I tried with following code,
It’s hard to find a generic algorithm for the bins in your code, but there are a couple approaches you can take.
You can use a bin set expression to create a list of matching bin values
bit [12:0] rate[8][] = '{ {12'b????_????_?010,12'b????_????_?110}.
{12'b????_????_??01}.
...
}; // you can use whatever procedural code you want to
// construct this array before constructing the covergroup
covergroup client_rate;
option.per_instance = 1;
RX_CLIENT_RATE : coverpoint i_rx_config
{
wildcard bins RATE_0 = rate[0];
wildcard bins RATE_1 = rate[1];
wildcard bins RATE_2 = rate[2];
wildcard bins RATE_3 = rate[3];
wildcard bins RATE_4 = rate[4];
wildcard bins RATE_5 = rate[5];
wildcard bins RATE_6 = rate[6];
wildcard bins RATE_7 = rate[7];
endgroup
You can send your coverpoint values through a function and use its return value to select a bin.
bit [12:0] rate[8][] = '{ {12'b????_????_?010,12'b????_????_?110}.
{12'b????_????_??01}.
...
}; // you can use whatever procedural code you want to
// construct this array before constring the covergroup
covergroup client_rate;
option.per_instance = 1;
RX_CLIENT_RATE : coverpoint somefunc(i_rx_config)
{
bins RATE[8] = {[0:7]};
}
endgroup
function int somefunc(bit [12:0] samp);
return ... some value between 0 and 7
Above code serves my purpose and able to use same define multiple times by just passing different reference to the define.
Now let say I have 8 different client_cfg(client_cfg[8]) and I am passing different cfg instance in define reference. but client_cfg 0 to 6 support RATE_0 to RATE_9 and client_cfg only support RATE_0 to RATE_5. So I my coverage goal is not achieving 100% as RATE_6 to RATE_9 are not present for client_cfg[7], client_cfg[8] and client_cfg[9].
Do we have any method to not define bins if certain condition is not matched/satisfied?
The is no way to evaluate an expression as part of a macro, and there is no way to conditionally create a named bin within a coverpoint. You can control the size of an array of bins, and the values in each bin at construction.