3

I am trying to create a parameterized covergroup in my testbench as follows:

covergroup CG (input int id); 

    cp1 : coverpoint tb.gen_block_mem[id].var_x[3:0];

endgroup : CG 

CG CG_0  = new(0);
CG CG_1  = new(1);

This fails in elaboration as the id variable is not a constant. Is there a SystemVerilog workaround for this so that I can instantiate covergroups just like parameterized modules?

toolic
  • 5,637
  • 5
  • 20
  • 33

1 Answers1

2

Assuming tb.gen_block_mem is a generate block, you'll have to put the covergroup in another generate block

for(genvar id=0;id<MY_P;id++) begin : cg_block
 covergroup CG; 
  cp1 : coverpoint tb.gen_block_mem[id].var_x[3:0];
 endgroup : CG 
 CG cg  = new;
end : cg_block
dave_59
  • 7,557
  • 1
  • 14
  • 26