UVM factory overriding

Hi All,
please find the code snippet below:

class tx_agent_cfg extends uvm_object;
  bit active;
  virtual intf intf_h;
endclass

class ext_tx_agent_cfg extends tx_agent_cfg;
  bit[2:0] x;
endclass

class tx_agent extends uvm_agent;
  tx_agent_cfg tx_cfg;
  //monitor handle
  //driver handle
  //sequencer handle
endclass

class ext_tx_agent extends uvm_agent;
  ext_tx_agent_cfg tx_cfg;
  //monitor handle
  //driver handle
  //sequencer handle
  function void build_phase(uvm_phase phase);
    if(!$cast(tx_cfg,super.tx_cfg)
       `uvm_fatal("EXT_AGENT","Casting failed for tx_cfg")
  endfunction
endclass

class base_test extends uvm_test;
  //env handle
  //setting of interface to agents
endclass

class ext_base_test extends base_test;
  function void build_phase(uvm_phase phase);
    factory.set_type_override_by_name("tx_agent_cfg","ext_tx_agent_cfg",1);
  endfunction
endclass

So in test level overriding the class tx_agent_cfg with ext_tx_agent_cfg in build phase.
But here when I try to use ‘x’ in the ext_base_test it is giving compilation errors saying that x is not found in env_h.tx_agent.tx_cfg.

please help me in this situation

In reply to avpchandra:

Hi,

I’m assuming your extended test is using Original Agent and Agent Config class (and not extended one). In this case even if you use UVM Factory override mechanism to create extended class objects on parent handles, you cannot access extended class properties from parent class handles.

Using UVM Factory override creates extended objects, but existing infrastructure of your test bench contains parent handles only.

To better use concept of inheritance you would like to create extended Agents and Configs in your extended test, where you can access existing parent properties as well as newly added extended class properties. And if you need change in behavior for your existing testbench code, polymorphism/callbacks could be planned beforehand!