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;
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();
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
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.
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.
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):