Can I pass the handle of an uvm_component via uvm_config_db?

Hi,

For some reason, my end-test-checking sequence needs to access my monitor and pull some information from there.

I tried to pass the monitor handle through uvm_config_db like this:

In env:

function connect_phase(uvm_phase phase);
    super.connect_phase(phase);
    uvm_config_db #(uvm_monitor)::set(uvm_top, "*", "ref_handle_mmon", naxi_magent.m_mon); //the agent and its monitor is constructed in build_phase
  endfunction

In my end-test checking sequence: (This sequence is called in shutdown_phase)

...
uvm_monitor mmon;
...
task body();
...
if(!uvm_config_db #(uvm_monitor)::get(null, get_full_name(), "ref_handle_mmon",mmon )) begin
      `uvm_fatal("eot_seq", "Master mon handle unfound")
    end
...

Both uvm_config_db set and get are successful, but after the get, the handle mmon is still showing as null and i am unable to access that monitor.
I assume the reason behind this is that since uvm_monitor is a uvm_component, instead of the monitor handle, an unconstructed monitor object is passed to uvm_config_db.

Thus I wonder if I can actually pass the handle of that component to uvm_config_db and let end-test-checking sequence be able to access that monitor?

Thanks in advance!

Hao

In reply to peterjin:
Can you check naxi_magent.m_mon before calling set() to make sure it is not null?
Also, you should pass null instead of uvm_top as the first argument.

In reply to dave_59:

In reply to dave_59:
Hi Dave,
Thanks for the suggestion!
Yes, naxi_magent.m_mon is already created before calling set(). And after some further debug, I start to wonder if the problem is related with factory type override.
In my testbench, both naxi_magent and m_mon is factory overrode.
For naxi_magent

class naxi_master_agent extends uvm_agent; //parent class
  naxi_master_monitor m_mon;
  ...
endclass
class naxi_master_agent_param#(PARAM) extends naxi_master_agent; //child class
  naxi_master_monitor_param #(PARAM) m_mon;
  ...
  virtual function build_phase(uvm_phase phase);
    m_mon = naxi_master_monitor_param#(PARAM)::type_id::create("m_mon", this);
  endfunction
  ...
endclass

For m_mon, this is class is extended two times

class naxi_master_monitor extends uvm_monitor; //parent class
...
endclass
class naxi_master_monitor_param#(PARAM) extends naxi_master_monitor; //child class
...
endclass
class l2_naxi_master_monitor#(PARAM)extends naxi_master_monitor_param#(PARAM);//grand-child class
...
endclass

Place where override happens (In env’s build phase)

set_type_override_by_type(naxi_master_agent::get_type(), naxi_master_agent_param#(PARAM)::get_type() );
    set_type_override_by_type(naxi_master_monitor_param#(PARAM)::get_type(),l2_naxi_master_monitor#(PARAM)::get_type());
    naxi_magent = naxi_master_agent::type_id::create("naxi_magent",this);
    naxi_sagent = naxi_slave_agent::type_id::create("naxi_sagent",  this);

In the test_class, I tried to directly assign the monitor handle to end-test-checking sequence. In the following code, naxi_msqr is a non-factory overriden type.

virtual task shutdown_phase(uvm_phase phase);
    ...
    eot_seq =  l2_eot_sequence::type_id::create("eot_seq");//creating the end_test_checking sequence
    eot_seq.naxi_msqr=l2m_env.naxi_magent.m_seqr; //this assignment is good
    eot_seq.mmon=l2m_env.naxi_magent.m_mon;       //this handle assignment is bad
    eot_seq.start(null);
    ...
endtask

However, as we can see from vcs’s simulator, mmon handle in end_test_checking sequence is still null. In contrast, the handle assignment of naxi_msqr, that non-overriden class, is good. (Plase let me know if the picture behind it doesn’t display)

In eot_seq

class l2_eot_sequence extends uvm_sequence #(uvm_sequence_item);
  uvm_sequencer_base      naxi_msqr;
  uvm_monitor             mmon;
  l2_naxi_master_monitor#(PARAM)  grandchild_mmon;
  ...
  task body();
     $cast(ref_handle_mmon,mmon);
  ...
  endtask
  ...
endclass

I wonder if the bad handle assignment issue is caused by factory override?

Thanks a lot for your help!

Hao