I used a reusable embedded covergroup in a class, which has an argument as a ref variable. This covergroup is then used in separate classes. However, after the simulation is completed, the coverage results are only displayed in the embedded covergroup class. I need to obtain coverage results for the separate instances. Below, I will show the code I am working with.
Embedded Covergroup
common_coverge.svh
class common_coverage;
covergroup data_cg (ref logic [31:0] data);
CP_DATA : coverpoint data {
bins zerobin = {0};
bins endValue = {32'hffffffff};
}
endgroup
function new(ref logic [31:0] data);
this.data_cg = new(data);
endfunction: new
endclass
tx_funcational_coverage.svh
class tx_functional_coverage extends uvm_subscriber #(tx_seq_item);
`uvm_component_utils(tx_functional_coverage)
logic [31:0] data;
common_coverage tx_cover;
function new(string name="tx_functional_coverage",uvm_component parent);
super.new(name,parent);
tx_cover = new(this.data);
endfunction: new
virtual function void write(tx_seq_item t);
t.get_data(this.data);
tx_cover.data_cg.sample();
endfunction: write
endclass : tx_functional_coverage
rx_functional_coverage.svh
class rx_functional_coverage extends uvm_subscriber #(rx_seq_item);
`uvm_component_utils(rx_functional_coverage)
logic [31:0] data;
common_coverage rx_cover;
function new(string name="rx_functional_coverage",uvm_component parent);
super.new(name,parent);
rx_cover = new(this.data);
endfunction: new
virtual function void write(rx_seq_item t);
t.get_data(this.data);
rx_cover.data_cg.sample();
endfunction: write
endclass : rx_functional_coverage