I want to write coverage on the basis of One Hot Encoding.
For example
ABC : coverpoint @ ( ADD) // ADD is [4:0]
{
bins a = {00001};
bins b = {00010};
bins c = {00100};
bins d = {01000};
bins e = {10000};
}
Value of ADD is depend on the no of slaves in our environment . If no of slave is 1 then its value is 1 .But if number of slave is 2 then we generate ADD either 00001 or 00010.In this case bins c,bins d,bins e is not hitted & my coverage is not covering 100%. How i control on bins on the basis of ADD value?
Is another way is possible to write coverage of one hot encoding? Please reply me
, if its is 2 then its value will be 00010 .But when its value will
Many people think they want to control the number of bins they have in a covergroup, but it’s much easier to control the number of covergroups that you have. If each covergroup has 1 bin, then you create as many covergroup instances as you have slaves.
BTW, there will be an enhancement to the 1800-2012 SV LRM that will make it easier to program bin construction, but it will be at least a year before you will see it implemented.
Actually, it only took 6 months to see the new 1800-2012 covergroup syntax implemented. The example now can be written as:
class my_coverage_class #(int WIDTH);
// The bus that requires one hot encoding coverage
bit [WIDTH-1:0] my_bus;
// array to hold one-hot encodings
bit [WIDTH-1:0] onehots[WIDTH];
covergroup onehot_cg;
coverpoint my_bus {
bins selected[WIDTH] = onehots;
}
endgroup
function new;
foreach(onehots[i]) onehots[i] = 1'b1 <<i;
onehot_cg = new;
endfunction
endclass
I know this is old, but I’m trying to get this to work. I’m checking my vendor for support also, but quick question:
I’ve modified the above so that ‘onehots’ holds the typical wildcard/walking 1’s pattern (e.g., ???1, ??1?, ?1??, 1???, which is so ugly for anything wide)
So the loop in new could become:
foreach (onehots[i]) begin
onehots[i] = { WIDTH { 1'bx }};
onehots[i][i] = 1'b1;
end
Then I made ‘bins’ be ‘wildcard bins’. It compiles, but no coverage is generated. Again, I’m checking vendor… but question is:
should this work with ‘wildcard bins’ and what I’ve shown?