How to find out if a class type has been overridden in UVM factory?

Some of the tests override the sequence item class in my env. In the sequence, I need to find out what type the sequence item has been overridden with in the factory. There could be other applications for this too. Is there a way to find this out?

In reply to kamzamani:

It depends on at what point you want this information and what you want to do with the information.

If the object is already created you can use the identification methods built into uvm_object like get_type and get_type_name.

If the object has not been created yet and you want to know what would be created, the uvm_factory has a set of debug methods (debug_create_by_type & debug_create_by_name) that dump out a report of what overrides have been set. It also has find_override_by_type & find_override_by_name that returns what would have been returned by get_type and get_type_name.

In reply to dave_59:

In reply to kamzamani:
It depends on at what point you want this information and what you want to do with the information.
If the object is already created you can use the identification methods built into uvm_object like get_type and get_type_name.
If the object has not been created yet and you want to know what would be created, the uvm_factory has a set of debug methods (debug_create_by_type & debug_create_by_name) that dump out a report of what overrides have been set. It also has find_override_by_type & find_override_by_name that returns what would have been returned by get_type and get_type_name.

Actually I am dealing with two types of objects: one is a config obj and the other one is a sequence item. Neither of them are created in the sequence I am writing. Both are created and used in a totally different driver/uvc. However, my sequence needs to make decisions based on what type of objects are being used by that uvc.

So I don’t know if get_type/get_type_name are any good in my sequence because those two objects are not created in my sequence. The only way I can have knowledge of them in my sequence is through the factory.

And about those debug_create_* methods, do they return any info about the overridden class? Or do they print out this info in the log file? If the latter, that is of no use to me.

debug_create_by_type
pure virtual function uvm_object create_object_by_name (
string requested_type_name,
string parent_inst_path = "",
string name = ""
)
pure virtual function uvm_component create_component_by_name (
string requested_type_name,
string parent_inst_path = "",
string name,
uvm_component parent
)
pure virtual function void debug_create_by_type (
uvm_object_wrapper requested_type,
string parent_inst_path = "",
string name = ""
)


Let’s use an example:


class cfg extends uvm_object;
....
endclass

class cfgA extends cfg;
....
endclass

In the test, cfg may get overridden by cfgA. Ideally I am looking for something like this that returns, maybe a string:

string class_name;
factory.get_type_name("cfg", class_name); //my ideal method that tells me what class is used for cfg
if (class_name == "cfgA") begin
.....
end
else begin
....
end

In reply to kamzamani:

You can use find_override_by_name.

if (factory.find_object_by_name("cfg","path_where_will_be_creating_object") == cfgA::type_id::get_type()) begin
    ...
end

In reply to dave_59:

find_override_by_name worked like a charm. Exactly what I was looking for. Thank you!