Hi all,
I have the two following classes:
class base_obj extends uvm_object;
`uvm_object_utils(base_obj)
function new(string name = "base_obj");
super.new(name);
endfunction
virtual function display();
`uvm_info(get_type_name(), $sformatf("inside base_obj"), UVM_LOW);
endfunction
endclass
class child_obj extends base_obj;
`uvm_object_utils(child_obj)
function new(string name = "child_obj");
super.new(name);
endfunction
function display();
`uvm_info(get_type_name(), "inside child_obj", UVM_LOW);
endfunction
endclass
In my test, I’m instantiating an object of type base_obj, and I’m using the set_inst_override_by_type to override it type with child_obj:
class my_test extends uvm_test;
`uvm_component_utils(my_test)
base_obj obj_b;
function new(string name = "my_test", uvm_component parent = null);
super.new(name, parent);
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
set_inst_override_by_type("obj_b", base_obj::get_type(), child_obj::get_type());
obj_b = base_obj::type_id::create("obj_b");
endfunction
task run_phase(uvm_phase phase);
super.run_phase(phase);
obj_b.display();
endtask
endclass
It did not worked:
UVM_INFO testbench.sv(14) @ 0: reporter [base_obj] inside base_obj
Using
set_type_override("base_obj", "child_obj");
have worked but I would like to override only the specific obj_b instance. What am I missing?
Thanks,
Ruben