Covergroups in ovm_subscriber

hello,

Im starting to get familiar with ovm and I am having some trouble integrating covergroups inside a subscriber. here is my subscriber code:

class my_subscriber extends ovm_subscriber #(my_transaction);

`ovm_component_utils(my_subscriber)
bit cmd;
int addr;
int data;

covergroup cover_bus;
coverpoint cmd;
coverpoint addr {bins a[8] = {[0:255]};}
coverpoint data {bins d[8] = {[0:255]};}
option.per_instance = 1;
endgroup: cover_bus

function new(string name, ovm_component parent);
super.new(name, parent);
endfunction: new

function void write(my_transaction t);
cmd = t.cmd;
addr = t.addr;
data = t.data;
cover_bus.sample();

ovm_report_info("David", "Transaction received");

endfunction: write

endclass: my_subscriber

When the analysis port calls the write function it executes the ovm_report_info() correctly but for some reason the covergroup is not created, it is never updated even though the function sample() had to be called. I am sure I am missing something so if somebody can help me out it would be great. Im using QuestaSim 10b just in case it is relevant.

Thanks

You need to initialize/construct the covergroup with a call to new().

Add this to the constructor of my_subscriber:

cover_bus = new();

In reply to dwikle:

Thank you! I completely forgot about that