Construction of embedded covergroup (defined in a class)

Is this a tool issue or a SystemVerilog language issue?
Compilation with code below yielded the following:
“Construction of embedded covergroup (defined in a class) is not supported except in constructor ‘new()’ of covergroup’s parent class”
virtual function void build();
super.build();
m_xactn=counter_xactn::type_id::create(“m_xactn”, this);
this.cntr_cvg = new(); // *** TOOL SAYS NO ON THIS *** ?Q*&&?QW???
endfunction : build

function new(string name, uvm_component parent);
	super.new(name,parent);
	m_name=get_type_name();
	m_name=m_name.toupper();

// m_xactn=counter_xactn::type_id::create(“m_xactn”, this);
// // m_aport = new(“m_aport”, this);
// this.cntr_cvg = new(); // *** TOOL WANTS THIS // ONLY OK ON THIS
endfunction : new

endclass : counter_monitor_cvg

An embedded covergroup variable may only be assigned in the new method. An embedded coverage group can be explicitly instantiated in the new method. If it is not, then the coverage group is not created and no data will be sampled.

In reply to dave_59:

Dave,
Thanks. Why this restriction on covergroup? Are there other things that “have to be in the new()” instead of the “build”?

In reply to ben@SystemVerilog.us:

Three things that the language requires to be in new()

  • An implicit or explicit call to super.new() as the first statement to handle non-default constructor arguments.
  • Assignments to const class members that do not already have declaration initializations.
  • Embedded covergroup constructors.

I believe the embedded covergroup restriction has to do the fact that the covergroup is really part of the class type, and its construction has to be in synchronization with the class construction. And there are problems with per-class-type covergroup collection as well of the construction of all covergroups is not synchronized.

In reply to dave_59:

Please help to explain. why is there a restriction on embedded covergroups that they cannot be created with an instance name, hence multiple instances of covergroup cannot be created.

Ideally within a class you would not need multiple instances of the same covergroup.
Not sure if there is any particular requirement where you would need multiple instances of covergroup within a class.