I was going through Source Code to understand Factory Registration .
Class uvm_component_registry ( uvm_object_registry ) has 2 parameters , type parameter T and string parameter Tname .
String Registration utilizes both parameters ::
// Within class uvm_component_registry / uvm_object_registry
typedef uvm_component_registry #( T , Tname ) this_type ; // [A]
local static this_type me = get() ;
// Within static function get() ::
if ( me == null ) begin
me = new() ;
factory.register( me ) ; // Factory Registration
....................
Factory Registration takes place via following 2 properties [ Associative Array ] ::
protected uvm_object_wrapper m_type_names [ string ] ; // Used for String Registration
protected bit m_types [ uvm_object_wrapper ] ; // Used for Type Registration
Now during string registration ::
// Within Factory function register with I/P Argument :: uvm_object_wrapper obj ; // Base type handle !!
m_type_names[ obj.get_type_name() ] = obj ;
// When create_component_by_name() is called via run_test() ::
wrapper = m_type_names[requested_type_name]; // **.
// LHS is :: uvm_object_wrapper wrapper ;
So essentially string index utilizes the string Argument Tname , whereas RHS obj
( points to extended object of class uvm_*_registry class ) [b]utilizes both parameters ( Since it’s of type ‘this_type’ ( Refer [A] above ) )**
**Hence String - Registration uses both type parameter ‘T’ as well as String
parameter ‘Tname’ during String Registration .
Therefore function create_component_by_name() uses both type parameter 'T'
as well as String parameter 'Tname'**
[Q] What about create() function ( which uses Type - based Factory ) ?
create() function internally calls create_component_by_type() .
OR Is it independent of string parameter Tname ??
I observe that Type Registration is done via function register() in uvm_factory ::
// Within Factory function register with I/P Argument :: uvm_object_wrapper obj ; // Base type handle !!
m_types[ obj ] = 1 ; // obj is of type 'this_type'
But unlike array m_type_names which is read back ( Refer [ B ] above )
to create appropriate component , m_types isn’t read anywhere in Code