Debugging source of Warnings during Factory registration


`include "uvm_macros.svh"
`include "uvm_pkg.sv"
 
 import uvm_pkg::* ;

`define COMP function new( string name , uvm_component parent );\
                 super.new(name,parent);\
             endfunction


 module  Registering_Matching_Types_L3  ;

   class  Type_Comp #( type T = int )  extends  uvm_test ;

  typedef  uvm_component_registry #( Type_Comp #( T ) , "Type_Comp" ) type_id ;  //  NOTE  ::  Same 'Tname'  for  different  Specialization  !!

      `COMP 
     
      function   void    build_phase  (  uvm_phase  phase )  ;
         `uvm_info(get_name , $sformatf(" In build_phase() ") , UVM_NONE )
      endfunction

   endclass

    //  Specialization  for  Registration  !!

    Type_Comp #( int )   type_int ; 
    
    Type_Comp #( bit signed [31:0] )   type_bit_sign ; 

    initial  begin
  
      run_test("Type_Comp") ;

    end

  endmodule

I get Warning Messages as the String Registration is same for all Specializations of class Type_Comp

I went through Source Code for function register of class uvm_factory ::


   function void uvm_default_factory::register (uvm_object_wrapper obj);  //  obj  points  to  Extended  uvm_component / uvm_object  !!

  if (obj == null) begin
    uvm_report_fatal ("NULLWR", "Attempting to register a null object with the factory", UVM_NONE);
  end
  if (obj.get_type_name() != "" && obj.get_type_name() != "<unknown>") begin

    if (m_type_names.exists(obj.get_type_name()))  //    This  is  Simple  to  Understand  . Basically  Tname  for  Components  should  be  Unique
      uvm_report_warning("TPRGED", {"Type name '",obj.get_type_name(),
        "' already registered with factory. No string-based lookup ",
        "support for multiple types with the same type name."}, UVM_NONE);
    else 
      m_type_names[obj.get_type_name()] = obj;
  end

  if (m_types.exists(obj)) begin        //   Need  help  here  !!

    if (obj.get_type_name() != "" && obj.get_type_name() != "<unknown>")
      uvm_report_warning("TPRGED", {"Object type '",obj.get_type_name(),
                         "' already registered with factory. "}, UVM_NONE);
  end
  else begin
    m_types[obj] = 1;
    .......................

  

My Question is when would :: if (m_types.exists(obj)) begin be True ??

 **Can  someone  provide a  example  when  I could  see the  Warning  during  Type  Registration  ?**

I expected that since ‘int’ and ‘bit signed [31:0]’ are Matching types
I would Observe Warning Message during Type Registration , but I don’t

In reply to TC_2017:

This is leftover from OVM when some tools did not support the typedef uvm_component_registry mechanism for factory registration. It needed to construct an object and have the static initialization call uvm_factory::register.

I suppose register() can still be used to register a class with the factory from outside that class. I can think of a number of ways you might inadvertently register the same class twice.

In reply to dave_59:

I can think of a number of ways you might inadvertently register the same class twice.

Could you please elaborate on it via a code snippet .

In reply to TC_2017:

Too rare to worry about in my option.