Creating new instances of a covergroup using an array

In reply to vsirsikar:

Hi Dave,
How about array of covergroup inside an interface?
I see it in apb_protocol_monitor_example (coverage cookbook) but when I try to compile code, an error is invoked:

APB_accesses_cg APB_protocol_cg[no_slaves];
              |
ncvlog: *E,SVNOTY (../protocol_monitor/apb_monitor.sv,140|14): Syntactically this identifier appears to begin a datatype but it does not refer to a visible datatype in the current scope.

And this is the code in apb_monitor.sv:

// Functional Coverage for the APB transfers:
//
// Have we seen all possible PSELS activated?
// Have we seen reads/writes to all slaves?
// Have we seen good and bad PSLVERR results from all slaves?
covergroup APB_accesses_cg();

option.per_instance = 1;

RW: coverpoint PWRITE {
  bins read = {0};
  bins write = {1};
}
ERR: coverpoint PSLVERR {
  bins err = {1};
  bins ok = {0};
}

APB_CVR: cross RW, ERR;

endgroup: APB_accesses_cg

// Array of these covergroups
APB_accesses_cg APB_protocol_cg[no_slaves];

Thanks,
P/S: sorry for my bad English

In reply to An Pham:

You can keep the covergroup in another class , and create an array of objects for that class.
this could solve your problem

In reply to shivabachu:

You should be able to declare this array covergroups in a package, interface, or module.

In reply to dave_59:

Hi everyone,
Thanks for your quick replies.
Create a wrapper class for covergroup solved the issue. But it seems that array of covergroup could not be declared inside an interface, or possibly it is the difference between Cadence IUS and Mentor ModelSim.
Thanks,

In reply to An Pham:

Hi Dave,

You mentioned a note for "ref" in this line: covergroup skew_val_cg (ref int skew_val_vl); // note the use of a ref argument

why did you have to use “ref” and what is the use of it ?

Thanks,
Madhu

In reply to mseyunni:

See 19.3 Defining the coverage model: covergroup

In reply to dave_59:

Hi Dave,

I am facing same problem as An Pham.

When i instantiate an array of covergroup inside an interface it says “Syntactically this identifier appears to begin a datatype but it does not refer to a visible datatype in the current scope.”

Any solution to this ?

In reply to vibhatna:

Are you using Questa?

In reply to dave_59:

I am using irun

In reply to vibhatna:

Then you need to take this issue up with Cadence.

In reply to dave_59:

Hi Dave,

To the above class, I added

task test();
foreach(sv_cg[i]) begin
skew_val_vl[i] = 100*i;
sv_cg[i].sample();
end
endtask

and called it for an instance of the class.

When I run vcover report -details <filename.ucdb>, I get 100% result. I also added “option.per_instance=1” to the covergroup definition. Can you tell me, how do I produce overall numbers to accurately reflect my instance coverage?

COVERGROUP COVERAGE:

Covergroup Metric Goal Status


TYPE /por_pub_routing_checker_pkg/skew_val_cg 100.0% 100 Covered
covered/total bins: 4 4
missing/total bins: 0 4
% Hit: 100.0% 100
Coverpoint skew_val_cg::skew_val_vl 100.0% 100 Covered
covered/total bins: 4 4
missing/total bins: 0 4
% Hit: 100.0% 100
bin skew_range_1 4 1 Covered
bin skew_range_2 4 1 Covered
bin skew_range_3 4 1 Covered
bin skew_range_oor 4 1 Covered

Covergroup instance /por_pub_routing_checker_pkg::my_class::sv_cg#1
25.0% 100 Uncovered
covered/total bins: 1 4
missing/total bins: 3 4
% Hit: 25.0% 100
Coverpoint skew_val_vl 25.0% 100 Uncovered
covered/total bins: 1 4
missing/total bins: 3 4
% Hit: 25.0% 100
bin skew_range_1 1 1 Covered
bin skew_range_2 0 1 ZERO
bin skew_range_3 0 1 ZERO
bin skew_range_oor 0 1 ZERO


TOTAL COVERGROUP COVERAGE: 100.0% COVERGROUP TYPES: 1

In reply to dave_59:

Hello Dave,

Can you please give little hint, how the class will recognise the “skew_val_cg” covergroup.
In my case the class is not recognising the covergroup name.

Please guide and help.

Reagrds
Sunil

*In reply to sunils:*It needs to be in the same scope as the class, or you need to put the covergroup in a package and import it.

In reply to dave_59:

Thanks Dave.

-Sunil

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.