3
\$\begingroup\$

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?

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

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
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.