Hi this is the signal bit[1:0] a[63:0][14:0];how to create coverpoint for it. I coded as below but we cannot use for loop inside cover group.
define COVERPOINT_3(i)(j) coverpoint a[i][j] { bins a_``idx = {[0:63]};}
class dom;
covergroup cg1;
for(int i=0;i<=64;i=i++)
begin
for(int j=0;j<=15;j=j++)
begin
COVERPOINT_3(i)(j)
end
end
endgroup
endclass
my intention is to create coverpoints as a[0][1], a[0][2] …a[64][15];
You can create an array of covergroups
bit[1:0] a[63:0][14:0];
event sample_ev;
covergroup cg_element(int x,y) @sample_ev;
option.per_instance = 1; // prevents merging bins
coverpoint a[x][y];
endgroup
cg_element cg_array[64][15];
initial foreach(cg_array[i,j]) cg_array[i][j] = new(i,j);
class c;
bit[1:0] a[63:0][14:0];
event sample_ev;
covergroup cg_element(int x,y) @sample_ev;
option.per_instance = 1; // prevents merging bins
coverpoint a[x][y];
endgroup
cg_element cg_array[64][15];
initial foreach(cg_array[i,j]) cg_array[i][j] = new(i,j);
endclass
throwing error Following verilog source has syntax error :
token ’ cg_element’ should be a valid type. Please declare it
virtual if it is an Interface.
Because of the tight connection between covergroups embedded in classes, you cannot construct an array of class embedded covergroups.
You can create an array of covergroups instances of covergroup declared outside a class.
module top;
covergroup cg_element(bit [1:0] element, event e) @e;
option.per_instance = 1; // prevents merging bins
coverpoint element;
endgroup
class c;
bit[1:0] a[63:0][14:0];
event sample_ev;
cg_element cg_array[64][15];
function new;
foreach(cg_array[i,j]) cg_array[i][j] = new(a[i][j],sample_ev);
endfunction
endclass
c h = new;
endmodule
Can we declare cover group inside class, i mean without using module can we achieve this
You can declare a covergroup inside a module/interface/package/class. You cannot create an array of a covergroups declared inside a class–there is no syntax that allows it( the covergroup name is used as the instance name). But you can create an array of classes with a covergroup declared inside it.
1 Like