My requirement is to override multiple instances of configuration class with different types(extended from same configuration base class), which is extended from uvm_transaction. Method(s) “set_inst_override_by_type/name” is working fine for classes extended from uvm_components. uvm user-guide is not saying that these method will not work for classes extended from uvm_transaction/object.
Method set_type_override_type is working fine to override type of class extended from uvm_object/transaction. But this will not resolve my problem, as want to override multiple instances of same type with multiple types.
Can any one answer, why methods “set_inst_override_by_type/name” are not working for overriding classes extended from uvm_object / uvm_transaction ?
Here is similar example which replicates problem. class A_ovr is successfully overridden as it is extended from uvm_component in-directly, but class B_ovr and B_override are extended from uvm_object and not able to override using same method.
class A extends uvm_agent;
`uvm_component_utils(A)
function new (string name="A", uvm_component parent);
super.new(name, parent);
`uvm_info(get_full_name, $sformatf("A new"), UVM_LOW);
endfunction : new
virtual function hello();
`uvm_info(get_full_name, $sformatf("HELLO from Original A class"), UVM_LOW);
endfunction : hello
endclass : A
--------------------------------------------------------------
class A_ovr extends A;
`uvm_component_utils(A_ovr)
function new (string name="A_ovr", uvm_component parent);
super.new(name, parent);
`uvm_info(get_full_name, $sformatf("A_ovr new"), UVM_LOW);
endfunction : new
function hello();
`uvm_info(get_full_name, $sformatf("HELLO from override A_ovr class"), UVM_LOW);
endfunction : hello
endclass : A_ovr
--------------------------------------------------------------
class B extends uvm_object;
`uvm_object_utils(B)
function new (string name="B");
super.new(name);
`uvm_info(get_full_name, $sformatf("B new"), UVM_LOW);
endfunction : new
virtual function hello();
`uvm_info(get_full_name, $sformatf("HELLO from Original B class"), UVM_LOW);
endfunction : hello
endclass : B
---------------------------------------------------------------
class B_ovr extends B;
`uvm_object_utils(B_ovr)
function new (string name="B_ovr");
super.new(name);
`uvm_info(get_full_name, $sformatf("B_ovr new"), UVM_LOW);
endfunction : new
function hello();
`uvm_info(get_full_name, $sformatf("HELLO from override B_ovr class"), UVM_LOW);
endfunction : hello
endclass : B_ovr
--------------------------------------------------------------
class B_override extends B_ovr;
`uvm_object_utils(B_override)
function new (string name="B_override");
super.new(name);
`uvm_info(get_full_name, $sformatf("B_override new"), UVM_LOW);
endfunction : new
function hello();
`uvm_info(get_full_name, $sformatf("HELLO from override B_override class"), UVM_LOW);
endfunction : hello
endclass : B_override
--------------------------------------------------------------
class environment extends uvm_env;
`uvm_component_utils_begin(environment)
`uvm_component_utils_end
A a1;
B b1, b2;
function new(string name="environment", uvm_component parent);
super.new(name, parent);
endfunction : new
function void build_phase(uvm_phase phase);
super.build_phase(phase);
a1 = A::type_id::create("a1", this);
b1 = B::type_id::create("b1");
b2 = B::type_id::create("b2");
a1.hello(); // This will print from overridden class A_ovr.
b1.hello(); // This will print from base class B.
b2.hello(); // This will print from base class B.
endfunction : build_phase
endclass : environment
--------------------------------------------------------------
class test extends uvm_test;
`uvm_component_utils(test)
environment env;
function new(string name = "test", uvm_component parent = null);
super.new(name, parent);
endfunction : new
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
env = environment::type_id::create("env", this);
`uvm_info(get_full_name, $sformatf("TEST set_inst_override_by_type"), UVM_LOW);
factory.set_inst_override_by_type(A::get_type(), A_ovr::get_type(), {get_full_name, ".", "env.a1"}); // Working
factory.set_inst_override_by_type(B::get_type(), B_ovr::get_type(), {get_full_name, ".", "env.b1"}); // Not working
factory.set_inst_override_by_type(B::get_type(), B_override::get_type(), {get_full_name, ".", "env.b2"}); // Not working
// Alternative way is also not working !!!
// `uvm_info(get_full_name, $sformatf("TEST set_inst_override_by_name"), UVM_LOW);
// factory.set_inst_override_by_name("A", "A_ovr", {get_full_name, ".", "env.a1"}); // Working
// factory.set_inst_override_by_name("B", "B_ovr", {get_full_name, ".", "env.b1"}); // Not working
// factory.set_inst_override_by_name("B", "B_override", {get_full_name, ".", "env.b2"}); // Not working
factory.print(); // This will print info about overridden classes.
endfunction : build_phase
endclass : test
====================================================================================