Hello,
it would be really helpfull to understand more if you share exact Error which you are getting.
However,few things are missing in above code
- you need to create array/define array size before you new each cg instance. because when you say “skew_cg[i]” it doesnt know skew_cg is array or not!!
- Last time when i tried to create array of cover-group and define cover-group inside class i was getting compilation issue as tool was not able to resolve the cover-group definition. thats why wrote cover-group outside class.
so try below code, I am sure it will work.
covergroup skew_val_cg (int skew_val_vl);
coverpoint skew_val_vl {
bins skew_range_1 = {[124:0]};
bins skew_range_2 = {[325:125]};
bins skew_range_3 = {[526:326]};
bins skew_range_oor = {[1100:929]};
}
endgroup : skew_val_cg
class sample_class extends uvm_component;
int skew_val_vl[20];
skew_val_cg cg_inst[20];
function new(string name, uvm_component parent = null);
super.new(name, parent);
foreach(skew_val_vl[i])
cg_inst[i] = new(skew_val_vl[i]);
endfunction // new
endclass : sample_class