Hello,
I would like to define a base coverage class that have implementation of monitoring registers accesses,
and each time a new register captured, the base class will call a virtual function “sample_register_coverage();”
this function is implemented in each child and collect relevant coverage.
base class code:
class base_coverage extends uvm_component;
uvm_analysis_imp #(uvm_reg_item, base_coverage) in_ap;
`uvm_component_utils(base_coverage)
function new(string name, uvm_component parent= null);
super.new(name, parent);
in_ap = new("in_ap", this);
endfunction : new
function void write(uvm_reg_item t);
uvm_reg r;
$cast(r,t.element);
reg_addr = r.get_address();
reg_data = r.get();
sample_register_coverage();
endfunction
virtual function void sample_register_coverage();
`uvm_info(get_type_name(), "base_coverage::sample_register_coverage ", UVM_MEDIUM)
endfunction : sample_register_coverage
endclass
Child1 class code:
class coverage_child1 extends base_coverage;
`uvm_component_utils(coverage_child1)
function new(string name, uvm_component parent= null);
super.new(name, parent);
endfunction : new
function void sample_register_coverage();
`uvm_info(get_type_name(), "coverage_child1::sample_register_coverage ", UVM_MEDIUM)
endfunction : sample_register_coverage
endclass
I have more then 1 child, but for now lets assume I have the same code within all children, the only different is the name.
instances of coverage classed in the environment:
class env extends uvm_component;
base_coverage base_cov;
coverage_child1 cov_child1;
coverage_child2 cov_child2;
reg_monitor reg_mon;
`uvm_component_utils(env)
function new(string name, uvm_component parent= null);
super.new(name, parent);
endfunction : new
function void build_phase(uvm_phase phase);
super.build_phase(phase);
base_cov = base_coverage::type_id::create("base_cov",this);
cov_child1 = coverage_child1::type_id::create("cov_child1 ",this);
cov_child2 = coverage_child2::type_id::create("cov_child2 ",this);
reg_mon = reg_monitor::type_id::create("reg_mon",this);
endfunction : build_phase
function void connect_phase(uvm_phase phase);
reg_mon.reg_ap.connect(base_cov.in_ap);
endfunction : connect_phase
endclass
My issue is that I see in my prints (and also when tried to collect coverage)
that the sample_register_coverage is done on the base only.
I’m not entering to the children’s sample_register_coverage at all.
As I checked in some exapmles I think that the “virtual” defined well.
maybe I have a misunderstood with the base and children connection / instances ?
I mean, Can I create a base and run on the base my “write” function and within the “write” call a virtual function? Is that supposed to be okay ?
Thanks in advance.