what is the difference between create and create_by_type/name methods and in which scenario i have to use create_by_type/name methods ?
Differences
Aspect | create | create_by_type | create_by_name |
---|---|---|---|
Defined In | uvm_object (virtual method) | uvm_factory | uvm_factory |
Called By | User via type_id::create | Factory internally or advanced users | Factory internally or advanced users |
Input | Name, parent (for components) | Type proxy, name, parent | String name, instance name, parent |
Override Support | Type and instance overrides | Type overrides only | Name-based overrides |
Use Case | Standard object/component creation | Type-based creation (no string lookup) | Name-based creation (string lookup) |
Parameterized Classes | Supported (via type_id) | Supported (via type proxy) | Not supported (no string name) |
Common Usage | Primary method in testbenches | Rare, mostly internal or for debugging | Rare, mostly internal or for debugging |
1 Like
can type_id::create do every work that can done by create_*_by_type/name ??
type_id::create is the method for most UVM object creation needs and supports factory overrides and type-safe instantiation. However, for scenarios requiring string-based dynamic type selection,
create_by_name is essential, and type_id::create cannot substitute for it. For create_by_type, type_id::create is generally a better choice due to its simplicity and equivalent functionality.
1 Like