Creating new instances of a covergroup using an array

Hello Dave,

I need little bit more guidance in knowing the error which i am finding after putting in the same scope as per guide:


 class coverage extends uvm_subscriber #(my_seq_item);
   
  `uvm_component_utils(coverage)

 my_seq_item tx_cfg;
 
 tx_cfg_cg one[16];
 
function new(string name = "coverage", uvm_component parent);
	  super.new(name, parent);

          foreach (one[i]) 
          
          one[i] = new(tx_cfg.AttrID[i]);

endfunction : new

function void write(T t);
	  tx_cfg = t;
	  tx_cfg.sample();
	  
endfunction : write

endclass

covergroup tx_cfg_cg (ref int tx_cfg.AttrID);
    
       coverpoint tx_cfg.AttrID {
	
	bins B0 = {8'h21};
	bins B1 = {8'h22};
	bins B2 = {8'h23};
	bins B3 = {8'h24};
	bins B4 = {8'h25};
	bins B5 = {8'h12};
    }
  
  endgroup

The error i am getting is: Line number:4 Invalid type: tx_cfg_cg. Please check the type of the variable one.

Please help.

Thanks and Regards
Sunil Sharma

How to get array of coverpoints?

In reply to sunils:

Types must be declared before use. Move the covergroup declaration before the class that uses it.

Hi,

 I have used same scenario in my code. It is working fine. But it is not showing coverage for every instance of covergroup individually in dve tool. It is showing overall coverage of all the instances of covergroup in coverage tool. Can you help me with that?

Thanks,
Mansi Kelawala

In reply to mansi.kelawala:
This is a Mentor sponsored methodology forum not for tool specific help. Please contact your vendor for support.

In reply to mansi.kelawala:

Did you set
option.per_instance = 1;

Then you should see the coverage numbers per instance.
If you did and it is showing still the average coverage numbers then it is an tool issue.

In reply to dave_59:

Hi Dave,
how to write the same covergroup if i want to have many coverpoints inside. can you please show with same example?

With Regards
Ajay

In reply to Ajay2112:

In reply to dave_59:
Hi Dave,
how to write the same covergroup if i want to have many coverpoints inside. can you please show with same example?
With Regards
Ajay

i now understand that ‘ref’ should be written only once. i.e. at the start of argument when passing multiple arguments.

ex-covergroup skew_val_cg (ref int cp1, int cp2, int cp3); // ref argument, only once
coverpoint cp1 {
bins skew_range_1 = {[124:0]};
}
coverpoint cp2 {
bins something = {range};
}
coverpoint cp3 {
bins ~~~~;
}
endgroup : skew_val_cg