Part 3 · Factory & Configuration · Intermediate

UVM Factory Hub: Registration, type_id, and create()

Hub - factory registry concept, registration macros, type_id::create pattern, factory vs direct new, create-time resolution, and factory debug workflows.

Overview

The UVM factory is a global constructor registry with override resolution . Classes register once; every create() call goes through the same lookup path so tests can substitute behavior without editing environment code.

Master three ideas: registration , type_id::create() , and create-time override resolution . Break any one and overrides silently fail.

Sub-lessons in this topic

  1. factory-registry-concept - what the factory stores and when it resolves types.

  2. registration-macros - component vs object utils and what macros generate.

  3. type-id-create-pattern - canonical create() usage for components and objects.

  4. factory-vs-direct-new - why new() bypasses overrides and breaks reuse.

  5. create-time-resolution - lookup order from request to constructed instance.

  6. factory-overview-debug - introspection and triage when types look wrong.

diagram
[FACTORY][UVM] factory lifecycle map

elaboration:
  `uvm_component_utils(T)  -> static registration into uvm_factory

test build_phase:
  set_type_override / set_inst_override  -> policy registered

env build_phase:
  base_driver::type_id::create("drv", this)
      -> factory resolves requested type + overrides
      -> calls new() on resolved class
      -> inserts child into parent hierarchy
systemverilog
class my_env extends uvm_env;
  `uvm_component_utils(my_env)
  base_driver drv;

  function void build_phase(uvm_phase phase);
    super.build_phase(phase);
    drv = base_driver::type_id::create("drv", this);
  endfunction
endclass

Key takeaways

  • Factory registration makes a type discoverable and overridable.

  • type_id::create() is the only supported build path for replaceable UVM types.

  • Overrides apply at create time — not retroactively on existing objects.

Common pitfalls

  • Treating factory as optional sugar instead of mandatory infrastructure.

  • Registering types but building with direct new() in env code.

  • Debugging overrides before confirming create() was used everywhere.


Applied factory standards

Use a short review gate before merging env changes that introduce new component types.

Release checklist

diagram
[FACTORY][UVM] factory hygiene gate

registration:
  - every replaceable class has correct utils macro
  - type_id::create used in all env build paths

policy:
  - overrides registered in test before super.build_phase
  - no hidden new() in agents/drivers/monitors

debug:
  - factory.print available behind +UVM_FACTORY_DEBUG
  - end_of_elaboration logs actual get_type_name() for key nodes
  • Ban new() for uvm_component in code review — factory path only.

  • Keep registration macros adjacent to class declarations.

  • Document which types are intentionally non-overridable.

diagram
[FACTORY] ownership boundaries

test owns:
  - override policy (type and instance scope)
  - timing of override registration

env owns:
  - requested base types in create() calls
  - stable instance names for override paths

VIP owns:
  - registration of extension classes
  - Liskov-safe derivative implementations