In reply to chr_sue:
Here is my code:
------------------ Agent ------------------
class agent extends uvm_agent;
`uvm_component_utils(agent)
protected uvm_active_passive_enum is_active = UVM_ACTIVE;
monitor mon;
driver drv;
// driver_2 drv2;
//monitor_2 mon2;
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction
function void build();
uvm_report_info(get_full_name(),"Build", UVM_LOW);
mon = monitor::type_id::create("mon",this);
drv = driver::type_id::create("drv",this);
// ag2 = agent::type_id::create("ag2",this);
// mon2 = monitor_2::type_id::create("mon2",this);
// drv2 = driver_2::type_id::create("drv2",this);
endfunction
endclass
--------------------------- Agent 2 derived from Agent-------------
class agent2 extends agent;
`uvm_component_utils(agent2)
protected uvm_active_passive_enum is_active = UVM_ACTIVE;
monitor2 mon2;
driver2 drv2;
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction
function void build();
uvm_report_info(get_full_name(),"Build", UVM_LOW);
mon2 = monitor2::type_id::create("mon2",this);
drv2= driver2::type_id::create("drv2",this);
endfunction
endclass
---------------- env --------------------
class env extends uvm_env;
`uvm_component_utils(env)
agent ag1;
agent2 ag2;
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction
function void build();
uvm_report_info(get_full_name(),"Build", UVM_LOW);
ag1 = agent::type_id::create("ag1",this);
ag2 = agent2::type_id::create("ag2",this);
endfunction
endclass
---------------- testcase------------------
class test2 extends uvm_test;
`uvm_component_utils(test2)
env t_env;
function new (string name="test2", uvm_component parent=null);
super.new (name, parent);
driver::type_id::set_inst_override(driver2::get_type(),"top.t_env.ag2.drv2");
factory.print();
t_env = new("t_env",this);
endfunction : new
endclass
Output :
Instance Overrides:
Requested Type Override Path Override Type
driver top.t_env.ag2.drv2 driver2