I want to create multiple instances of a covergroup based on a parameter (preferably with different names so as to sample each instance accordingly). And then I want to sample those covergroups using sample() function. Is it possible to create them using for loop? I tried with generate loop, but got error since coverage collector is class based coverage & not a module.
Pseudo code of what I want:
covergroup cg_unit(int i);
coverpoint(signal[i])
{ bins xyz={1'b1}; }
endgroup
function new();
for(int i=0;i<PARAM;i++)
begin
cg_unit[i] = new(i); //It shouldn't necessarily be an array, but I want different names for each instance
end
endfunction
...
task write();
for(int i=0;i<PARAM;i++)
begin
cg_unit[i].sample();
end
endtask
Each covergroup has an
option.name, which you can access, but I don't recommend writing it, because every group is already named uniquely. What you're asking sounds like one of the following, but if you already had a separate coverage collector for each instance, then the problem is already solved.or
FYI neither of these examples require "_comment" to be derived from a parameter