Functional coverage - regmodel

Hi Folks,

I am trying to collect ocverage info from uvm regmodel. I can see that the coverage data is getting generated but it reports 0% covered. But I know for sure that the registers are being accessed.
I was wondering if they are actually being sampled properly or not. If it has do with my env or tool related.

class top_revision_t extends uvm_reg;
rand uvm_reg_field MAJOR;
rand uvm_reg_field MINOR;

covergroup wr_cg;
option.per_instance=1;
MAJOR_0 : coverpoint MAJOR.value[0];
MAJOR_1 : coverpoint MAJOR.value[1];
endgroup

covergroup rd_cg;
option.per_instance=1;
MINOR_0 : coverpoint MINOR.value[0];
MINOR_1 : coverpoint MINOR.value[1];
endgroup

protected virtual function void sample(uvm_reg_data_t data, byte_en, bit is_read, uvm_reg_map map);
super.sample(data, byte_en, is_read, map);
if(!is_read) wr_cg.sample();
if(is_read) rd_cg.sample();
endfunction

function new(input string name=“top_revision_t”);
super.new(name, 32, build_coverage(UVM_CVR_FIELD_VALS));
wr_cg=new;
rd_cg=new;
endfunction : new

endclass : top_revision_t


And in my env I do this:
uvm_reg::include_coverage(“*”, UVM_CVR_ALL);
regmodel.build();
regmodel.set_coverage(UVM_CVR_FIELD_VALS);
regmodel.lock_model();

Does anyone see any problem with this?

Thanks
Subramaniam

Hi!
I suppose that the problem lie in ‘super.new(…)’ usage.
Try this:


function new(string name = "top_revision_t");
  super.new(name, 32, UVM_NO_COVERAGE);
  this.add_coverage(build_coverage(UVM_CVR_FIELD_VALS));
  if(has_coverage(UVM_CVR_FIELD_VALS)) begin
    wr_cg=new;
    rd_cg=new;
  end
endfunction

Best regards,
Dmitrii.

In reply to ssubramaniam:

Hi,

Sampling of coverage model is implicitly disabled. you have to enable it explicitly in test.
uvm_reg::set_coverage()

Regards,
tejastv

In reply to tejastv:

You don’t have to Switch on coverage by Setting set_coverage.
Dmitri, you are swtching-off coverage explicitly by setting

super.new(name, 32, UVM_NO_COVERAGE);


But the constructor of your register should look like this:

function new(string name = "reg_tx_address");
    super.new(name, 16, build_coverage(UVM_CVR_REG_BITS));
    if (has_coverage(UVM_CVR_REG_BITS))
       reg_tx_addr_cg = new();
endfunction


where reg_tx_address is a Register. The Argument to build_coverage is one of the coverage models the UVM is offering.

In reply to chr_sue:

In reply to tejastv:
Dmitri, you are swtching-off coverage explicitly by setting

super.new(name, 32, UVM_NO_COVERAGE);

Exactly. But then i have invoked ‘add_coverage’ method. That’s why my solution will be work in the example above.

In reply to Dmitrii:

You don’t switching-on the coverage. You are adding a coverage model, but this does not take effect because of the switched-off coverage for the super class.

In reply to chr_sue:

I don’t have much time to dive into deep of uvm source code now, but my solution works with this lines from example above (but i’m doing it in the test, instead in the env):

uvm_reg::include_coverage("*", UVM_CVR_ALL);
regmodel.build();
regmodel.set_coverage(UVM_CVR_FIELD_VALS);

You may try it yourself with uvm 1.2.