I have an array of pointers, say ptr[192], each of its element can take 3 values 0,1,2.
How do i define the coverage for the complete array? Can I do something like:
I ran into the same issue. How do we make your solution work for a case where we want to cross the individual coverpoints (of the array) with some other coverpoint? We can’t cross coverpoints from different covergroups right?
The tool we’re using doesn’t support array of covergroups :). I also felt it’s easier to look at coverage results if the coverage of the whole array is in one covergroup as opposed to looking at an array of covergroups. I’m just trying to write coverage for a multidimensional array and I’m trying to avoid typing all the entries of the array.
In reply to itsmyturn:
SystemVerilog does not support arrays of covergroups embedded in classes. If that is your issue, you can define the covergroup outside the class, or you can create an array of classes with the covergroup embedded. Unfortunately, SystemVerilog covegroups were only designed to deal with integral types, not arrays.
It would really help to see the examples of what you are trying to cover.
My covergroup is inside a module and not a class. I’m trying to cover all values of this counter variable(for all combinations of the higher dimensions).
logic [4:0][7:0][2:0] counter;
The [4:0] dimension is one hot (so, it can hold 5 values)
The [7:0] dimension is one hot (so, it can hold 8 values)
The [2:0] can be any value (it’s not decoded) and is what will be my coverpoint variable.
So, I’m trying to see if there’s a way of writing these 40 coverpoints without typing each of them. Please let me know if what I wrote above isn’t clear. Thanks for the help.
As per my understanding, taking “array of covergroup inside a class, with covergroup definition outside class” is a valid SystemVerilog semantic.
Can you please confirm about the same? Also, it would be great if you can point to or copy paste the LRM description for the same. I could not find the exact mention about this in LRM.
A covergroup declaration within a class is an embedded covergroup declaration. An embedded covergroup declaration declares an anonymous covergroup type and an instance variable of the anonymous type. The covergroup_identifier defines the name of the instance variable.
There’s no syntax that allows you to declare any array of instance variables with this anonymous type.
You can instantiate an array of covergroups anywhere you can instantiate a single covergroup instance. The only restriction is you can’t declare a covergroup inside a class and instantiate an array of that same covergroup.
You cannot cross coverpoints between different coverpoints. You can put the coverpoint xyz inside the same covergroup by making it another argument of ptr_val_cg.
bit [1:0] ptr[192];
covergroup ptr_val_cg(ref bit [1:0] ptr, int xy);
coverpoint ptr { bins ptr_val = {0,1,2};}
cross ptr,xy
endgroup
class cov_mon
ptr_val_cg ptr_cg[192];
int xyz;
function new();
foreach (ptr[i])
ptr_cg[i] = new(ptr[I],xyz);
endfunction
endclass