Why Do We Need Phases?
The Problem: Imagine trying to test a car before the engine is installed. Disaster, right? Without phases, your testbench components would try to work before they're ready.
The Solution: Phases are like a step-by-step instruction manual. They make sure your testbench builds itself in the right order, connects all the pieces, runs the test, and cleans up afterward.
The UVM Phase Schedule
Tip: Function phases execute in zero-time. Run phases consume simulation time.
UVM phases are a timing system. Without them, a Monitor might try to read signals before the interface is connected, or a Driver might send data while your design is still resetting.
The 9 Standard Phases (Detailed)
Phases are executed in a fixed sequence. Most are non-blocking functions
(executing in zero simulation time). Only the run_phase (and its
sub-phases) is a task that can consume simulation time.
1. build_phase (Function, Top-Down)
- The Goal: To physically construct the testbench component hierarchy (The Topology).
- The Action: Components use
type_id::createto instantiate child components and queryuvm_config_db. - Why Top-Down? Precedence flows from parent to child. Parents must exist first to configure children (e.g., Active/Passive).
2. connect_phase (Function, Bottom-Up)
- The Goal: Wiring components using TLM ports/exports.
- The Action: Assigning virtual interface handles and connecting monitors to scoreboards.
- Why Bottom-Up? Children (building blocks) should be fully connected internally before being integrated into parents.
3. end_of_elaboration_phase (Function, Bottom-Up)
- The Goal: Final structural verification.
- The Action: Checking connectivity and topology validity before simulation starts.
4. start_of_simulation_phase (Function, Bottom-Up)
- The Goal: Pre-simulation preparation.
- The Action: Displaying logging banners, printing factory overrides, or recording initial register states.
5. run_phase (Task, Parallel)
- The Goal: The primary simulation engine.
- The Action: The only phase where the "clock" ticks. Drivers drive, Monitors sample.
- Key Behavior: All
run_phasetasks start simultaneously across the hierarchy.
6. extract_phase (Function, Bottom-Up)
- The Goal: Collecting post-simulation artifacts.
- The Action: Pulling final stats, coverage counts, or error flags.
7. check_phase (Function, Bottom-Up)
- The Goal: Validating the test outcome.
- The Action: Comparing expected vs actual results (e.g. Scoreboard empty check).
8. report_phase (Function, Bottom-Up)
- The Goal: Summarizing the total result.
- The Action: Printing "TEST PASSED" or "TEST FAILED".
9. final_phase (Function, Top-Down)
- The Goal: Resource cleanup.
- The Action: Closing files or releasing system handles.