Reputation: 5931
In a design there is a bus with 4 bits, thus alfa[3:0]
, and I want to make a covergroup that shows if all bit have been both 0 and 1.
One way to do this coule be to write it out like:
covergroup alfa_cv @(posedge clk);
coverpoint alfa[0];
coverpoint alfa[1];
coverpoint alfa[2];
coverpoint alfa[3];
endgroup
alfa_cv alfa_covergroup = new;
But is there an easier way to make coverpoints to cover each of the bits in a bus?
Upvotes: 0
Views: 4916
Reputation: 1992
As everyone mentioned over here, you don't need to write a covergroup for this purpose, as the toggle coverage will take care of it.
However, if you want to write a covergroup then you can directly use alfa
as coverpoint, as follow.
covergroup alfa_cv @(posedge clk);
coverpoint alfa;
endgroup
Upvotes: 0
Reputation: 42698
Usually code coverage includes toggle coverage. You shouldn't have to create a covergroup for this. But you can create an array of covergroups
covergroup cg(input int index, ref bit [31:0] bus) @(posedge clk);
each_bit: coverpoint bus[index];
option.per_instance = 1;
endgroup
cg cgbits[32];
for (int index=0; index<$size(alfa);index++)
cgbits[index] = new(index,alfa);
Upvotes: 1