Regarding UVM Factory Macros

When does following lines executed ?

uvm_component_utils and uvm_object_utils ?

Both constructs are factory regsitration macros.
uvm_component_utils is used to register uvm_components with the factory a component is a construct which is used to establish the UVM testbench. It is created at runtime 0 and exists until the end of the simulation.
uvm_object.utils is used to register uvm_objects with the factory. uvm_objects are dynamic objects which are created at any time and their liftime will normally not last until the end of the simulation. They disappear after they are processed.

1 Like

Although @chr_sue is correct about the purpose of these macros , his answer to your question about execution needs some improvement.

These macros create declarations for static variables and methods. The static declarations get executed once at time 0, before any processes (initial/always blocks) start. The methods get executed when see things like

packetB#(2)::type_id::set_inst_override(
extended_packetB#(2)::get_type(),”env.my_agent.*”);

You should read this:

1 Like

Thanks @dave_59. So, can we say that uvm_factory macros get executed during simulation time at time 0ns ? Or, are those lines executed during elaboration time after compilation ?

Macros expand to code at compilation. In the case of UVM factory macros, they expand to a lot of code (See this link as an example). Some of that code get executed at elaboration (parameterization). Some of that code gets executed at time 0 (static variable initialization). And some of that code gets executed if and when called (functions).