Run Phase
Learn how UVM starts time-consuming simulation activity, runs verification components concurrently, and controls when a test finishes.
Learning objectives
- Explain the purpose of
run_phase(). - Understand why
run_phase()is a task phase. - Identify where time-consuming simulation activity belongs.
- Understand how drivers, monitors, and sequences operate concurrently.
- Start a sequence from a UVM test or sequence-oriented component.
- Understand the basic purpose of UVM objections.
- Recognize common run-phase mistakes such as missing objections and infinite processes.
- Debug a test that starts correctly but never produces or finishes as expected.
Step 1: What happens when run_phase starts?
In the previous lessons, you learned that UVM first constructs and connects the verification environment.
The simplified flow is:
build_phase()
|
| create components
v
connect_phase()
|
| connect communication paths
v
end_of_elaboration_phase()
|
| inspect topology
v
run_phase()
|
| simulation activity
v
checking / reporting
Now the testbench is ready to interact with the DUT.
run_phase() is where time-consuming simulation activity happens.
Examples include:
- waiting for clock edges
- driving DUT signals
- monitoring DUT activity
- starting sequences
- waiting for transactions
- performing protocol-related activity
- waiting for reset completion
Step 2: run_phase() is a task
Unlike build_phase() and connect_phase(), run_phase() is a task phase.
A typical implementation looks like this:
task run_phase(uvm_phase phase);
super.run_phase(phase);
// Time-consuming simulation activity goes here.
endtask
Because it is a task, it can consume simulation time.
task run_phase(uvm_phase phase);
super.run_phase(phase);
#10ns;
@(posedge clk);
`uvm_info("RUN",
"Simulation activity occurred",
UVM_LOW)
endtask
This is fundamentally different from build_phase():
build_phase()
function
no simulation time
run_phase()
task
may consume simulation time
run_phase(), not in a function phase.
Step 3: Understand concurrency
One of the most important ideas in UVM is that many verification components can be active at the same time.
Imagine a simple environment:
DUT
^
|
driver drives
|
+------------+------------+
| |
driver monitor
|
v
scoreboard
During simulation:
- The driver can drive transactions.
- The monitor can observe the DUT.
- The scoreboard can receive observed transactions.
- A sequence can generate new stimulus.
These activities are not intended to happen as one long sequential function. UVM components use concurrent task-based behavior to model the naturally concurrent nature of hardware verification.
For example, a monitor may continuously wait for protocol activity:
task run_phase(uvm_phase phase);
forever begin
@(posedge vif.clk);
// Sample and process DUT activity.
end
endtask
At the same time, a driver can be waiting for sequence items:
task run_phase(uvm_phase phase);
forever begin
seq_item_port.get_next_item(req);
// Drive req onto the DUT.
seq_item_port.item_done();
end
endtask
Both processes can be active during the same simulation.
Step 4: Where does stimulus come from?
A common UVM flow is:
test
|
v
sequence
|
v
sequencer
|
v
driver
|
v
DUT
|
v
monitor
|
v
scoreboard
The sequence creates or randomizes transaction objects.
The sequencer provides those transactions to the driver.
The driver converts the transaction into pin-level activity.
The monitor observes the resulting DUT behavior and converts it back into a transaction.
The scoreboard can then compare the observed behavior against the expected result.
You will study sequences, sequencers, and the driver handshake in much greater detail in Lessons 31–35. For now, focus on where the activity begins.
Step 5: Starting a sequence
A test can start a sequence during run time.
A simplified example is:
task run_phase(uvm_phase phase);
bus_sequence seq;
super.run_phase(phase);
seq = bus_sequence::type_id::create("seq");
seq.start(env.agent.sequencer);
endtask
The important operation is:
seq.start(env.agent.sequencer);
This tells the sequence to execute on the specified sequencer.
The sequence can then generate transaction items for the driver.
Step 6: Why objections matter
There is an important question when a test starts running:
How does UVM know when the test is finished?
A run_phase() task may contain a sequence that takes time to complete. UVM needs a mechanism to know whether meaningful simulation activity is still in progress.
This is where phase objections come in.
A simplified pattern is:
task run_phase(uvm_phase phase);
phase.raise_objection(this);
seq.start(env.agent.sequencer);
phase.drop_objection(this);
endtask
The basic idea is:
raise objection
|
| "My test activity is still running."
v
run stimulus
|
| sequence completes
v
drop objection
|
| "My activity is finished."
v
phase can finish
This lesson only introduces the concept. Objections, drain time, phase completion, and common objection bugs are covered in detail later in the curriculum.
Step 7: A simple complete test example
Here is a simplified test that creates an environment and starts a sequence.
class bus_test extends uvm_test;
bus_env env;
`uvm_component_utils(bus_test)
function new(string name = "bus_test",
uvm_component parent = null);
super.new(name, parent);
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
env = bus_env::type_id::create("env", this);
endfunction
task run_phase(uvm_phase phase);
bus_sequence seq;
super.run_phase(phase);
phase.raise_objection(this);
seq = bus_sequence::type_id::create("seq");
seq.start(env.agent.sequencer);
phase.drop_objection(this);
endtask
endclass
Notice how the responsibilities remain separated.
build_phase()
|
+-- create env
run_phase()
|
+-- keep test alive
|
+-- create sequence
|
+-- start sequence
|
+-- finish test activity
This is a much cleaner architecture than putting everything into one phase.
Step 8: Components can have independent run behavior
The test is not the only component that can have a run_phase().
Drivers, monitors, scoreboards, agents, and other components can also implement run-time behavior.
For example, a monitor might continuously observe transactions:
task run_phase(uvm_phase phase);
forever begin
@(posedge vif.clk);
if (vif.valid) begin
bus_transaction txn;
txn = bus_transaction::type_id::create("txn");
txn.addr = vif.addr;
txn.data = vif.data;
ap.write(txn);
end
end
endtask
At the same time, the test might be starting sequences and the driver might be driving transactions.
The resulting behavior is conceptually:
time ---------------------------------------------------->
test: start sequence ------------------ finish
|
sequence: generate transactions --------->
|
driver: drive -------- drive -------- drive --->
|
DUT: process ---- process ---- process ----->
|
monitor: observe ---- observe ---- observe ----->
|
scoreboard: check ------- check ------- check ----->
This is the beginning of understanding UVM as a concurrent verification architecture rather than a collection of sequential functions.
Step 9: Avoid doing too much in the test's run phase
It is tempting to put all verification behavior directly into the test:
task run_phase(uvm_phase phase);
// Drive signals
// Wait for clock
// Check outputs
// Generate transactions
// Collect coverage
// Print results
endtask
This quickly becomes difficult to reuse and maintain.
A better architecture separates responsibilities:
Test
|
| selects scenario
v
Sequence
|
| creates transactions
v
Sequencer
|
| transfers transactions
v
Driver
|
| drives DUT
v
DUT
|
| produces behavior
v
Monitor
|
| observes transactions
v
Scoreboard
|
| checks behavior
v
Result
The test should primarily decide what scenario to run. Reusable components should implement how the protocol is driven, observed, and checked.
Step 10: Common run-phase mistakes
Mistake 1: Putting time-consuming code in a function phase
Do not try to wait for clocks or simulation time inside build_phase() or connect_phase().
Use task-based run-time behavior instead.
Mistake 2: The test finishes immediately
This often happens when the test's run-time activity is not keeping the phase alive correctly.
Check your objection handling and determine whether the sequence actually started.
Mistake 3: A monitor runs forever and the simulation never ends
A monitor often contains:
forever begin
// Monitor activity
end
That is normal for a monitor, but your overall test still needs a correct phase-completion strategy.
Do not assume that every forever loop should terminate on its own.
Mistake 4: The sequence starts, but no transactions reach the DUT
Debug the complete path:
sequence
|
v
sequencer
|
v
driver
|
v
DUT
A failure anywhere in this chain can make the test appear inactive.
Mistake 5: Putting protocol logic directly in the test
This may work for a tiny experiment but creates poor reuse.
Keep reusable protocol behavior inside the appropriate driver, monitor, agent, and sequence components.
Step 11: Debugging a test that does nothing
When simulation starts but you do not see expected activity, debug in this order:
- Did the test start? Add a simple
uvm_infomessage. - Did run_phase execute? Add a message before and after the sequence.
- Did the sequence start? Verify the sequence and sequencer handles.
- Did the driver receive an item? Add a driver-side report.
- Did the driver interact with the DUT? Inspect signals or add a driver message.
- Did the monitor observe the result? Check the monitor.
- Did the scoreboard receive the transaction? Check its analysis path.
- Does the test finish correctly? Check objections and phase completion.
A useful set of temporary messages is:
`uvm_info("TEST", "Starting sequence", UVM_LOW)
`uvm_info("DRIVER", "Received item", UVM_LOW)
`uvm_info("MONITOR", "Observed item", UVM_LOW)
`uvm_info("SCOREBOARD","Received item", UVM_LOW)
Once the transaction path works, remove or reduce unnecessary debug messages.
Step 12: Build, connect, run
You now have a clear division of responsibility across the first run-time stages of UVM.
| Phase | Question it answers | Typical work |
|---|---|---|
build_phase() |
What components should exist? | Create components and retrieve configuration. |
connect_phase() |
How should components communicate? | Connect TLM ports and exports. |
end_of_elaboration_phase() |
Did the final structure look correct? | Inspect and validate topology. |
run_phase() |
What happens during simulation? | Drive, monitor, wait, sequence, and check. |
Step 13: A small run-phase lab
Before moving on, create a tiny experiment with one UVM test.
Your first goal is not to drive a real protocol. Your goal is to prove that you understand simulation activity and phase execution.
Start with:
task run_phase(uvm_phase phase);
phase.raise_objection(this);
`uvm_info("RUN", "Run phase started", UVM_LOW)
#10ns;
`uvm_info("RUN", "10 ns elapsed", UVM_LOW)
phase.drop_objection(this);
endtask
Run the simulation and verify that:
- The run phase starts.
- The simulation advances in time.
- The message appears after the delay.
- The test eventually finishes.
Then replace the delay with a simple sequence start.
Try it yourself
Create a small UVM test and implement a run_phase() that:
- Raises a phase objection.
- Prints a message saying the test has started.
- Waits for one or more clock edges.
- Prints another message showing that simulation time advanced.
- Drops the objection.
Then add a sequence and start it from the test.
Challenge: Add temporary messages to the test, driver, monitor, and scoreboard. Use them to trace one transaction through the environment.
Debug challenge: Temporarily remove the objection and observe what changes. Explain why the simulation may finish before the intended activity completes.
Key takeaways
run_phase()is where time-consuming simulation activity occurs.run_phase()is a task, so it can wait for time, clocks, events, and transactions.- UVM components can perform concurrent activities during simulation.
- Tests commonly start sequences during run time.
- Drivers convert sequence transactions into DUT pin-level activity.
- Monitors observe DUT activity independently of the driver.
- Phase objections help UVM determine when run-time activity is complete.
- A
foreverloop in a monitor is normal, but test completion still needs to be managed correctly. - When debugging, trace the path from test → sequence → sequencer → driver → DUT → monitor → scoreboard.
- Keep scenario intent in tests and sequences; keep reusable protocol behavior inside reusable UVM components.
- The UVM lifecycle is becoming: Create → Configure → Connect → Inspect → Run → Check → Report.