Reputation: 327
I am writing a covergroup in my .sv file within a class that I am using for randomizing some inputs.I keep getting error :
An embedded coverage group not instantiated in the 'new' method
Then i am calling the run_coverage function in my initial block. I am not sure about it.
covergroup cg_for_arrays(ref logic [7:0]array, input int min, int max);
coverpoint cp_array
{
bins s = {min,max};
}
endgroup
function void run_coverage();
cg_for_arrays = new(array1,1,255);
cg_for_arrays.sample();
endfunction
Upvotes: 0
Views: 2913
Reputation: 42738
The error message is very clear. You are only allowed to construct a covergroup defined inside a class inside the constructor of that class. See section 19.4 Using covergroup in classes in the SystemVerilog IEEE 1800-2012 LRM.
Upvotes: 1