UVM Phase Overview
Learn how UVM controls the lifecycle of a verification environment, when components are created and connected, and where simulation activity belongs.
Learning objectives
- Explain why UVM uses phases to control the testbench lifecycle.
- Identify the major UVM phases and their purpose.
- Distinguish function phases from task phases.
- Understand why components are created in
build_phaseand connected inconnect_phase. - Understand why time-consuming stimulus normally belongs in
run_phase. - Trace a simple UVM testbench from construction to end of simulation.
- Recognize common phase-ordering mistakes before debugging a larger testbench.
Step 1: Why does UVM need phases?
A UVM testbench contains many components that must be created, configured, connected, started, and eventually shut down.
Without a predictable lifecycle, one component might try to use another component before it exists or before its connections have been established.
UVM solves this problem with phases. Phases give components a common sequence of lifecycle steps.
A simplified view is:
Build the testbench
|
v
Connect the testbench
|
v
Prepare for simulation
|
v
Run stimulus and checking
|
v
Collect results
|
v
Report results
|
v
Finish
Step 2: The UVM phase flow
UVM has several predefined phases. You do not need to memorize every phase on your first day, but you should understand the overall flow.
uvm_test_top
|
v
build_phase
|
v
connect_phase
|
v
end_of_elaboration_phase
|
v
start_of_simulation_phase
|
v
run_phase
|
v
extract_phase
|
v
check_phase
|
v
report_phase
|
v
final_phase
The most important beginner phases are:
- build_phase — create and configure components.
- connect_phase — connect TLM ports and exports.
- end_of_elaboration_phase — inspect or finalize the constructed hierarchy.
- start_of_simulation_phase — perform final pre-run setup.
- run_phase — execute time-consuming simulation activity.
- extract_phase — extract final information from components.
- check_phase — perform final checks.
- report_phase — summarize verification results.
- final_phase — perform final cleanup.
Step 3: Function phases vs. task phases
One of the most important concepts in UVM phases is that some phases are implemented as functions, while others can consume simulation time and are implemented as tasks.
Function phases
Phases such as build_phase and connect_phase
are function-based.
function void build_phase(uvm_phase phase);
super.build_phase(phase);
agent = bus_agent::type_id::create("agent", this);
endfunction
A function cannot consume simulation time. You should not put
#10ns, @(posedge clk), or other
time-consuming activity inside a function.
Task phases
The run_phase is task-based and can consume simulation time.
task run_phase(uvm_phase phase);
phase.raise_objection(this);
repeat (10) begin
#10ns;
`uvm_info("TEST", "Running stimulus", UVM_LOW)
end
phase.drop_objection(this);
endtask
This distinction explains why component construction belongs in
build_phase, while clock-driven stimulus belongs in
run_phase.
build_phase. Build is for constructing the testbench;
time-consuming simulation activity belongs in task phases.
Step 4: Build phase — create the testbench
During build_phase, UVM components create their child
components and retrieve configuration information.
For example, an environment can create an agent:
function void build_phase(uvm_phase phase);
super.build_phase(phase);
agent = bus_agent::type_id::create("agent", this);
endfunction
This creates:
env
└── agent
An agent can then create its driver and monitor:
function void build_phase(uvm_phase phase);
super.build_phase(phase);
driver = bus_driver::type_id::create("driver", this);
monitor = bus_monitor::type_id::create("monitor", this);
endfunction
By the end of build, the component hierarchy should exist.
build_phase answers the question
"What does my testbench contain?"
Step 5: Connect phase — connect the testbench
After components have been created, their communication interfaces can be connected.
For example:
function void connect_phase(uvm_phase phase);
super.connect_phase(phase);
agent.monitor.ap.connect(scoreboard.analysis_export);
endfunction
The important sequence is:
build_phase
|
| create components
v
connect_phase
|
| connect components
v
run_phase
|
| use the connections
v
simulation
This is why a component should not assume that its TLM connections
are available during its build_phase.
connect_phase answers the question
"How do the components communicate?"
Step 6: Run phase — simulation happens here
The run_phase is where the testbench performs
time-consuming simulation activity.
This can include:
- Starting sequences.
- Driving transactions.
- Waiting for clock edges.
- Monitoring DUT activity.
- Waiting for responses.
- Running protocol checks.
For example:
task run_phase(uvm_phase phase);
phase.raise_objection(this);
sequence.start(agent.sequencer);
phase.drop_objection(this);
endtask
The objection mechanism is important because UVM needs to know when the test has finished its time-consuming work.
You will study objections in detail later in Lesson 50.
run_phase does not automatically mean "the test is
finished when this task returns." UVM uses objections to coordinate
when the run phase is allowed to end.
Step 7: What happens after run?
Once the run-time portion of the test has completed, UVM moves through the post-run phases.
extract_phase
Components can extract information collected during simulation.
check_phase
Components can perform final consistency checks and determine whether expected conditions were satisfied.
report_phase
The testbench can summarize the verification result.
function void report_phase(uvm_phase phase);
`uvm_info(
"REPORT",
"Verification completed",
UVM_LOW
)
endfunction
final_phase
The final phase provides an opportunity for final cleanup.
Step 8: A complete component lifecycle
Put the major concepts together with a simple component:
class bus_agent extends uvm_agent;
`uvm_component_utils(bus_agent)
bus_driver driver;
bus_monitor monitor;
function new(
string name = "bus_agent",
uvm_component parent = null
);
super.new(name, parent);
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
driver = bus_driver::type_id::create("driver", this);
monitor = bus_monitor::type_id::create("monitor", this);
endfunction
function void connect_phase(uvm_phase phase);
super.connect_phase(phase);
// TLM connections go here.
endfunction
task run_phase(uvm_phase phase);
// Time-consuming activity can occur here.
endtask
endclass
Notice how each phase has a different responsibility:
| Phase | Question it answers |
|---|---|
build_phase |
What components exist? |
connect_phase |
How do components communicate? |
end_of_elaboration_phase |
Is the constructed hierarchy ready? |
start_of_simulation_phase |
What final setup is needed before simulation? |
run_phase |
What happens during simulation? |
extract_phase |
What information should be extracted? |
check_phase |
Did the expected conditions occur? |
report_phase |
What is the verification result? |
final_phase |
What final cleanup is required? |
Step 9: One important UVM detail — phases are hierarchical
UVM phases are executed across the component hierarchy.
You do not normally call another component's
build_phase() or run_phase() yourself.
Instead, UVM's phase mechanism invokes the appropriate phase methods throughout the hierarchy.
uvm_test_top
|
+-- env
| |
| +-- agent
| |
| +-- driver
| +-- monitor
|
+-- scoreboard
When the build phase runs, each component gets an opportunity to build its own children. When the connect phase runs, components establish their communication connections. When the run phase starts, components can perform time-consuming activity concurrently.
Step 10: Common phase mistakes
Mistake 1: Creating components in run_phase
Components should normally be constructed during
build_phase, not after simulation has already started.
Mistake 2: Connecting components in run_phase
TLM connections should normally be established during
connect_phase.
Mistake 3: Putting delays in build_phase
Build is a function phase and cannot consume simulation time.
Mistake 4: Starting stimulus before the environment is ready
A sequence should not rely on a driver or sequencer that has not been created and connected.
Mistake 5: Assuming run_phase automatically controls test completion
UVM uses objections to control the lifetime of the run phase. Forgetting an objection can cause a test to end too early; forgetting to drop one can cause a simulation to continue indefinitely.
Step 11: The beginner's phase map
If you remember only one diagram from this lesson, remember this:
CONSTRUCTION
|
v
+--------------+
| build_phase |
+--------------+
|
v
+---------------+
| connect_phase |
+---------------+
|
v
+-------------------------+
| end_of_elaboration |
+-------------------------+
|
v
+-------------------------+
| start_of_simulation |
+-------------------------+
|
v
RUN
|
v
+--------------+
| run_phase |
+--------------+
|
v
+--------------+
| extract |
+--------------+
|
v
+--------------+
| check |
+--------------+
|
v
+--------------+
| report |
+--------------+
|
v
+--------------+
| final |
+--------------+
|
v
END
The practical rule is simple:
- Build it.
- Connect it.
- Run it.
- Check it.
- Report it.
The next lessons will take these steps apart and show exactly what belongs in each phase.
Try it yourself
Create a simple UVM environment containing a test, environment, agent, driver, and monitor.
- Draw the component hierarchy.
- Mark which components are created in
build_phase. - Mark which connections belong in
connect_phase. - Identify which activities require simulation time.
- Place those activities in
run_phase. - Add a simple
report_phasemessage.
#10ns delay inside
build_phase. Observe the compiler error. Then move the
delay to run_phase and explain why the second version works.
Key takeaways
- UVM phases provide a predictable lifecycle for the entire testbench hierarchy.
build_phaseis primarily for creating and configuring components.connect_phaseis primarily for establishing TLM connections.run_phaseis where time-consuming simulation activity normally occurs.- Function phases cannot consume simulation time; task phases can.
- Post-run phases such as
check_phaseandreport_phasehelp determine and communicate verification results. - Understanding phase responsibilities makes UVM debugging much easier.