Uvm factory registration disambiguation

Kindly support with the following question:

Considering a verification environment that imports 2 packages, pkg_A and pkg_B.

Both packages contain some common class definitions (i.e. same class name, class properties, etc.):

pkg_A.sv                                                               

class some_name; 

`uvm_object_utils(some_name)

pkg_B.sv

class some_name;

`uvm_object_utils(some_name)

This makes the same class name to be registered to the factory twice, leading to the :

UVM_WARNING @ 0: reporter [TPRGED] Type name some_name already registered with factory. No string-based lookup support for multiple types with the same type name.

Consider that both pkg_A and pkg_B have numerous class with same name.

How can this be fixed?

Thank you

The best fix would be to rename the classes so that they are unique. Typically, a naming convention would be used to ensure uniqueness, such as ‘pkg_name_class_name’.

If this can’t be accomplish, then you won’t be able to use string-based lookups. This normally isn’t an issue as you would typically refer to the class based on it’s type.

In reply to Brass:

This is a limitation of the UVM macros; it does not consider package names as part of the type name. You have several options

  1. As suggested, make the class names unique in each package. Even though SystemVerilog allows classes with the same name, if you have control over both packages, try to make the names of UVM classes unique. This also makes importing with wildcards much easier as well.
  2. Don’t use string based name lookups, use type base lookups. This is also more efficient and less error prone because the types are checked at compile time. You can either ignore the warnings or use `uvm_object_param_utils which simply does not register a string name with the factory.
  3. Don’t use the `uvm_object_utils macros and directly use the uvm_object_registry class instead. See this link for more details.
typedef uvm_object_registry#(some_name,"pkg_A::some_name") type_id;
static function type_id get_type();
return type_id::get();
endfunction

In reply to cgales:

Thank you for your answer.
The respective packages are automatically generated and although this is indeed a solution, I’m trying to see if there’s a more convenient one.

In reply to dave_59:

Respectful thanks, Dave .
Looking into it.

In reply to Brass:

Another option that was just pointed out that I would put ahead of option 2.

`uvm_object_utils(pkg_A::some_name)

This eliminates the need for option 3