Module 3: Phases and Transactions | Lesson 26

Phase Ordering Pitfalls

Learn how UVM phase ordering affects configuration, component creation, TLM connections, simulation activity, and final checking—and how to debug phase-related failures systematically.

Learning objectives

  • Explain why UVM phase ordering matters.
  • Understand the difference between top-down and bottom-up phase traversal.
  • Identify which tasks belong in build, connect, run, check, and report phases.
  • Recognize configuration timing problems.
  • Recognize component creation and TLM connection ordering problems.
  • Understand why final checking must happen after run-time activity.
  • Debug tests that fail because a phase executes at an unexpected time.
  • Develop a systematic phase-debugging workflow.

Step 1: Why does phase ordering matter?

UVM phases are not just labels. They establish a predictable order for constructing, connecting, running, checking, and reporting a verification environment.

Consider the basic lifecycle:

BUILD


|
v
CONNECT
|
v
END OF ELABORATION
|
v
RUN
|
v
EXTRACT
|
v
CHECK
|
v
REPORT
|
v
FINAL

Each stage depends on work performed earlier.

For example:

Cannot connect a component
    if it does not exist.


Cannot run a driver correctly
if its configuration is missing.

Cannot check final results
before simulation activity has completed.
Key idea: Phase ordering creates dependencies. When a component expects something to exist before it runs, the required work must happen in an earlier phase.

Step 2: The most important phase responsibilities

Before debugging phase problems, memorize the responsibility of each major phase.

Phase Main question Typical work
build_phase() What should exist? Create components and retrieve configuration.
connect_phase() How should components communicate? Connect TLM ports, exports, and other interfaces.
end_of_elaboration_phase() Does the final structure look correct? Inspect topology and perform structural checks.
run_phase() What happens during simulation? Drive, monitor, wait, and execute sequences.
extract_phase() What final data should be collected? Organize final results.
check_phase() Did verification pass? Perform final checks.
report_phase() What happened? Summarize verification results.
final_phase() What final actions are required? Perform final lifecycle actions.

Step 3: Build phase is top-down

One important detail is how UVM traverses the component hierarchy during different phases.

Build phase is top-down.

That means parent components are built before their child components.

For example:

uvm_test_top
 |
 v
env
 |
 v


agent
|
+------> driver
|
+------> monitor

The conceptual order is:

test.build_phase()
    |
    v


env.build_phase()
|
v
agent.build_phase()
|
+------> driver.build_phase()
|
+------> monitor.build_phase()

This makes sense because a parent creates its immediate children.

For example:

function void build_phase(uvm_phase phase);


super.build_phase(phase);

agent = bus_agent::type_id::create("agent", this);

endfunction

Then the agent can create its own children.

Mental model: Build moves from the outside toward the inside of the testbench hierarchy.

Step 4: Connect phase works after components exist

By the time connect_phase() runs, the components that need to communicate should already have been created.

For example:

function void build_phase(uvm_phase phase);


super.build_phase(phase);

agent = bus_agent::type_id::create("agent", this);
scoreboard = bus_scoreboard::type_id::create(
"scoreboard", this);

endfunction

function void connect_phase(uvm_phase phase);
super.connect_phase(phase);

agent.monitor.ap.connect(
scoreboard.analysis_export);

endfunction

The dependency is obvious:

build


|
| agent exists
| scoreboard exists
v
connect
|
| connect agent.monitor to scoreboard
v
ready for simulation

If the scoreboard is optional and was not created, the connection cannot be made.

Step 5: Pitfall #1 — Configuration retrieved too late

Suppose an agent needs to know whether it should be active or passive.

The configuration is intended to affect which components are created:

uvm_active_passive_enum is_active;

The agent might use that configuration during build:

function void build_phase(uvm_phase phase);


super.build_phase(phase);

if (is_active == UVM_ACTIVE) begin
driver = bus_driver::type_id::create(
"driver", this);
end

monitor = bus_monitor::type_id::create(
"monitor", this);

endfunction

If the configuration value is not available when build executes, the agent cannot reliably make that decision.

This is why Lesson 20 introduced the configuration database before the build-phase lesson.

Configuration
  |
  | available before build
  v


build_phase()
|
| uses configuration
v
correct hierarchy
Common symptom: A component unexpectedly behaves as active, passive, disabled, or uses a default value. Check when and where the configuration was set.

Step 6: Pitfall #2 — Creating components in the wrong phase

Suppose someone tries to create a component during run_phase():

task run_phase(uvm_phase phase);


bus_monitor monitor;

monitor = bus_monitor::type_id::create(
"monitor", this);

endtask

This is poor UVM architecture.

The component hierarchy should normally be established during build.

Creating components during run time can make the environment difficult to reason about and can break assumptions made by other components that expect the hierarchy to already exist.

Prefer:

build_phase()
|
+-- create monitor
|
v


connect_phase()
|
+-- connect monitor
|
v
run_phase()
|
+-- monitor becomes active

Step 7: Pitfall #3 — Connecting before the required component exists

Consider this connection:

agent.monitor.ap.connect(
scoreboard.analysis_export);

Both sides of the connection must be valid.

A typical failure looks conceptually like:

agent created


scoreboard missing
|
v
connect_phase()
|
v
connection cannot be established

When you see a null-handle or connection-related failure, do not immediately blame the connect() statement.

Ask first:

  1. Was the parent component created?
  2. Was the child component created?
  3. Was the optional configuration correct?
  4. Is the expected TLM port present?
  5. Is the receiving implementation present?

Step 8: Connect phase is not run phase

A common beginner mistake is mixing structural setup with simulation behavior.

For example, this does not belong in connect_phase():

function void connect_phase(uvm_phase phase);


super.connect_phase(phase);

@(posedge vif.clk);

start_transaction();

endfunction

The problem is that connect_phase() is a function phase.

It should establish connections, not wait for simulation activity.

Use:

connect_phase()
|
+-- TLM connections


run_phase()
|
+-- clock waits
+-- stimulus
+-- monitoring
+-- time-consuming behavior

Step 9: Pitfall #4 — Checking before the test is actually complete

Imagine a scoreboard expects 100 transactions.

During simulation it receives transactions:

1 ... 2 ... 3 ... 4 ... 5 ...

If a final check occurs while only five transactions have arrived, the scoreboard might incorrectly conclude that the test is incomplete or has failed.

The correct lifecycle is:

run_phase()
|
| generate and observe all expected activity
v


run completes
|
v
extract/check
|
| evaluate final state
v
report

This is one reason phase completion and objections matter.

The test must not allow the run-time phase to finish before the intended verification activity has completed.

Important: A correct check_phase() cannot compensate for a test that ended before all required stimulus and observations occurred.

Step 10: Top-down vs bottom-up traversal

Another source of confusion is assuming every phase traverses the component hierarchy in the same direction.

For the common UVM phases covered so far, a useful beginner-level model is:

Phase Traversal idea
build_phase() Top-down
connect_phase() Bottom-up
end_of_elaboration_phase() Bottom-up
start_of_simulation_phase() Bottom-up
run_phase() Concurrent task activity
extract_phase() Bottom-up
check_phase() Bottom-up
report_phase() Bottom-up
final_phase() Bottom-up

Do not treat this table as something to memorize mechanically. Use it to understand the architectural reason behind the ordering.

For example, build needs to happen top-down because parents create children.

Run is different because components become active concurrently rather than simply executing one component after another.

Step 11: Pitfall #5 — Assuming run_phase() is sequential

Suppose your environment contains:

test


env
├── agent
│   ├── driver
│   └── monitor
└── scoreboard

It is tempting to imagine:

test.run_phase()
finishes
    |
    v


driver.run_phase()
finishes
|
v
monitor.run_phase()
finishes

That is not the right mental model.

Run-time behavior is concurrent. Components can wait and operate independently.

time -------------------------------------------------->


test:       start sequence -------------------- finish

driver:         wait -- drive -- wait -- drive -->

monitor:        wait -- observe -- wait -- observe -->

scoreboard:          check -- check -- check -------->

This concurrency is one of the major reasons UVM works well for hardware verification.

Step 12: Pitfall #6 — Forgetting that phase functions should not consume time

These phases are function phases:

build_phase()


connect_phase()
end_of_elaboration_phase()
extract_phase()
check_phase()
report_phase()
final_phase()

Do not place time-consuming operations such as these inside them:

#10ns;


@(posedge clk);
wait (ready);
``

Use task-based run-time behavior instead.

task run_phase(uvm_phase phase);


@(posedge vif.clk);

// Time-consuming activity.

endtask
Debug clue: If your simulator reports a problem around a clock wait or delay inside a phase function, check whether the operation belongs in a task-based phase.

Step 13: A phase-ordering debugging workflow

When a UVM test fails unexpectedly, avoid changing several components at once.

Instead, determine which phase first behaves incorrectly.

  1. Check build. Does the expected hierarchy exist?
  2. Check configuration. Did components receive the values they need?
  3. Check connect. Are the required TLM connections established?
  4. Check topology. Does the final hierarchy match the design?
  5. Check run. Does simulation activity actually occur?
  6. Check observations. Does the monitor see the expected transactions?
  7. Check checking. Does the scoreboard receive and evaluate those transactions?
  8. Check completion. Does the test remain alive long enough?
  9. Check reporting. Does the final result accurately describe what happened?

A useful debugging chain is:

Configuration
 |
 v


Build
|
v
Hierarchy
|
v
Connect
|
v
Topology
|
v
Run
|
v
Observed transactions
|
v
Checking
|
v
Report

Step 14: Add phase tracing while debugging

Temporary phase messages can help determine where execution reaches.

function void build_phase(uvm_phase phase);


super.build_phase(phase);

`uvm_info("PHASE",
"Entered build_phase",
UVM_LOW)

// Build code.

endfunction

You can do the same for other phases:

function void connect_phase(uvm_phase phase);


super.connect_phase(phase);

`uvm_info("PHASE",
"Entered connect_phase",
UVM_LOW)

// Connection code.

endfunction

And for run time:

task run_phase(uvm_phase phase);


`uvm_info("PHASE",
"Entered run_phase",
UVM_LOW)

// Run-time activity.

endtask

This creates a simple timeline in the simulator log.

Entered build_phase


Entered connect_phase
Entered run_phase
...
run activity
...
check phase
report phase
final phase

Once the problem is found, remove or reduce temporary tracing.

Step 15: A realistic phase-ordering failure

Imagine your scoreboard reports:

Expected 10 transactions


Received 0 transactions
Test PASS

That result should immediately make you suspicious.

Do not start rewriting the scoreboard.

Trace backward:

Did scoreboard receive anything?
    |
    no
    |


Did monitor publish anything?
|
no
|
Did monitor observe DUT activity?
|
no
|
Did driver drive transactions?
|
no
|
Did sequence start?
|
no
|
Did run_phase execute correctly?
|
?

Then move further backward:

Was the sequencer created?


Was the driver created?
Was the agent created?
Was configuration correct?
Did build_phase create the hierarchy?
Did connect_phase establish the required connections?

This is much more effective than randomly changing code.

Professional debugging habit: Find the first broken link in the lifecycle. Everything after that point may only be a symptom.

Step 16: The phase dependency map

Think of the UVM environment as a dependency chain:

Configuration
  |
  v


BUILD
|
| components exist
v
CONNECT
|
| communication paths exist
v
END OF ELABORATION
|
| topology verified
v
RUN
|
| transactions and DUT activity
v
EXTRACT
|
| final data collected
v
CHECK
|
| correctness determined
v
REPORT
|
| results communicated
v
FINAL

If an earlier stage fails, later stages may appear broken even though they are functioning correctly.

For example:

Missing configuration
    |
    v


incorrect build decision
|
v
missing driver
|
v
no stimulus
|
v
monitor sees nothing
|
v
scoreboard sees nothing

The scoreboard is not necessarily the source of the problem.

Try it yourself

Work through these debugging scenarios.

Scenario 1: Missing driver

Your test runs, but no transactions reach the DUT.

Check:

  1. Was the agent created?
  2. Was the driver created?
  3. Was the agent configured as active?
  4. Did the sequence start?

Scenario 2: Empty scoreboard

The driver appears to work, but the scoreboard receives nothing.

Check:

  1. Does the monitor exist?
  2. Does the monitor observe transactions?
  3. Does the monitor publish through its analysis port?
  4. Was the analysis port connected in connect_phase()?

Scenario 3: Test finishes too early

The sequence starts, but the simulator finishes before all transactions complete.

Check:

  1. Does the run phase remain active long enough?
  2. Are objections handled correctly?
  3. Does the sequence actually complete?
  4. Are all expected observations available before final checking?

Scenario 4: Wrong configuration

The environment is missing a component that should exist.

Check:

  1. Where was the configuration value set?
  2. Was it set before the component attempted to retrieve it?
  3. Was the hierarchy path correct?
  4. Did build_phase() retrieve the expected value?

Challenge: For each scenario, identify the first phase where the expected behavior could have gone wrong.

Step 17: The complete UVM phase mental model

You have now learned the major phase responsibilities across Lessons 21–26.

BUILD


Create and configure the hierarchy.

CONNECT
Connect existing components.

END OF ELABORATION
Inspect the completed structure.

RUN
Perform time-consuming simulation activity.

EXTRACT
Collect final information.

CHECK
Determine correctness.

REPORT
Summarize the verification result.

FINAL
Perform final lifecycle actions.

The most important lesson is not memorizing phase names.

It is understanding dependency and responsibility.

Core UVM rule: Create before connecting. Connect before running. Run before final checking. Check before final reporting.

Step 18: What you should be able to debug now

After completing this module section, you should be able to look at a UVM failure and ask:

Is the hierarchy correct?
    |


Is configuration correct?
|
Are components connected?
|
Does run-time activity occur?
|
Are transactions observed?
|
Are transactions checked?
|
Is the test completing correctly?
|
Is the final result trustworthy?

This is the foundation of practical UVM debugging.

Instead of asking:

"Why is my scoreboard broken?"

you should begin asking:

"At which stage of the verification lifecycle


did the expected behavior first disappear?"

Final practice exercise

Draw the complete lifecycle of a simple UVM environment:

test


|
v
env
|
+-- agent
|    +-- driver
|    +-- monitor
|
+-- scoreboard

For each phase, write down what should happen:

  1. Build: identify every component that must be created.
  2. Connect: identify every TLM path that must be connected.
  3. End of elaboration: identify what topology information you would inspect.
  4. Run: identify which components consume simulation time.
  5. Check: identify what evidence determines pass or fail.
  6. Report: identify what information should appear in the final result.

Debug challenge: Intentionally introduce one error into the environment—for example, omit a component creation, remove a TLM connection, or provide an incorrect configuration value. Run the test and use the phase dependency map to identify where the failure begins.

Key takeaways

  • UVM phases create a predictable lifecycle for the verification environment.
  • build_phase() is primarily responsible for creating and configuring components.
  • Build traversal is top-down because parents create their children.
  • connect_phase() establishes communication between components that already exist.
  • Configuration must be available at the point where a component needs it.
  • run_phase() is where concurrent, time-consuming simulation activity occurs.
  • Final checking must happen after the required run-time activity has completed.
  • Function phases should not contain time-consuming operations.
  • A failure in an early phase can create misleading symptoms in later phases.
  • Debug the first broken link in the lifecycle rather than immediately modifying the final component that reports the error.
  • The core dependency is: Configure → Create → Connect → Inspect → Run → Extract → Check → Report → Finalize.