Remove type_overrides

I want to do something like this in my sequence


virtual task body();
t1;
t2;
endtask

task t1();
typeA:::type_id::set_type_override(typeB::get_type(),1) // Override trans item typeA with typeB
endtask

task t2();
typeB:::type_id::set_type_override(typeA::get_type(),1) // Revert the override. Override typeB with typeA
endtask

When I run the code, it gives an error “Recursive loop detected while finding override” during sim

What you need to do is replace the original override of typeA back to typeA. Your task t2 just creates another override with replacing the existing one.

typeA:::type_id::set_type_override(typeA::get_type(),1) // Override trans item typeA with typeA

P.S.A.: usefunction void instead of task for non-time consuming subroutines.

In reply to dave_59:

It gives a warning “Original and override type arguments are identical:typeA” and when I do factory.print() after this override, it prints the following

Type Overrides:
Requested Type Override Type


typeA typeB

In reply to sridar:

Apparently, this is a bug that was fixed in UVM 1.2 (You’ll still get warning messages)

Instead of using overrides, the uvm_factory’s create_object_by_type() method and use a config_db setting to select the actual type.