Refer to the code as below, assignment of vif in build_phase() or connet() will result in different behavior. Anyone can explain a bit for this?
Thanks.
class apb_cov extends uvm_component;
virtual apb_master_if vif;
covergroup cg @ (vif.monitor_cb)
option.per_instance = 1;
endgroup // cgfunction new(string name="");
super.new();
cg = new();
endfunction // new
function void build_phase(uvm_phase phase);
super.build_phase();
/*
* If assign vif here, it is ok.
* vif = g_if;
*/endfunction // build_phase
function void connect();
/*
* If assign vif here, it will give runtime error as
* NULL pointer dereference of vif.
* vif = g_if;
*/
endfunction // connect
endclass // apb_cov