Skip to main content

Module 8 — UVM Basics

VLSI Verification  •  SystemVerilog Series

Module 8 — UVM Basics

The Universal Verification Methodology, from the ground up: why it exists, its layered architecture, the uvm_object/uvm_component split, factory-based construction, config_db, TLM communication, and every core component — sequences, drivers, monitors, agents, environment, scoreboard, test, and phases.

🧩 Advanced ⏱ ~40 min read 💻 Code Examples Included

60Why UVM

Before UVM, teams built testbenches with ad-hoc SystemVerilog class hierarchies, or used competing proprietary methodologies (VMM, OVM, e-based Specman). UVM (built on OVM, standardized by Accellera and later IEEE 1800.2) solved the fragmentation problem: a single, standardized, reusable base-class library and set of conventions for building constrained-random, coverage-driven testbenches.

Problem Without UVMHow UVM Solves It
Every team reinvents driver/monitor/scoreboard patternsStandard base classes (uvm_driver, uvm_monitor, etc.) with proven structure
Hard to reuse verification IP (VIP) across projectsFactory + config_db make components swappable/configurable without editing code
Manual, error-prone testbench-to-DUT wiringTLM ports/exports standardize component communication
No standard simulation lifecycleBuilt-in phasing (build, connect, run, etc.) synchronizes setup and execution
Vendor lock-in (proprietary methodologies)IEEE-standardized, supported across all major simulators
📘 In One Sentence

UVM exists so that verification engineers stop rebuilding the same testbench plumbing from scratch every project, and can instead focus effort on the DUT-specific stimulus, checking, and coverage logic.

61UVM Architecture

A UVM testbench is a layered hierarchy of reusable components, mirroring the DUT's interface structure, with clear separation between stimulus generation, driving, monitoring, and checking.

uvm_test └── uvm_env (environment) ├── uvm_agent (per interface/protocol) │ ├── uvm_sequencer ──TLM──► uvm_driver ──► DUT pins │ └── uvm_monitor ◄──samples── DUT pins ──► analysis_port │ │ ├── uvm_scoreboard ◄────────── analysis_port(s) ───────┘ └── uvm_subscriber (coverage collector) ◄── analysis_port
💡 Key Architectural Idea

Stimulus generation (sequences) is decoupled from stimulus driving (drivers) via the sequencer, and checking (scoreboard) is decoupled from observation (monitor) via analysis ports — this separation is what makes UVM components independently reusable across projects.

62UVM Components

"Component" in UVM specifically refers to classes extending uvm_component — the structural, persistent building blocks of the testbench hierarchy (as opposed to transient uvm_object-based data like transactions).

ComponentBase ClassRole
Driveruvm_driverConverts transactions into pin-level DUT activity
Monitoruvm_monitorObserves pin activity, reconstructs transactions
Sequenceruvm_sequencerArbitrates and feeds transactions to the driver
Agentuvm_agentGroups sequencer+driver+monitor for one interface
Environmentuvm_envGroups agents, scoreboard, coverage collectors
Testuvm_testTop of the hierarchy; configures env and starts sequences
Scoreboarduvm_scoreboard (or uvm_component)Checks DUT behavior against a reference model

63uvm_object

uvm_object is the base class for all transient, data-like UVM classes — transactions, configuration objects, sequences — anything created, used, and destroyed dynamically rather than persisting as part of the fixed testbench structure.

SystemVerilog / UVM
class axi_txn extends uvm_sequence_item; // uvm_sequence_item extends uvm_object rand bit [31:0] addr; rand bit [31:0] data; // mandatory UVM macro -- registers with factory, auto-generates // field-aware copy/compare/print/pack utilities `uvm_object_utils_begin(axi_txn) `uvm_field_int(addr, UVM_ALL_ON) `uvm_field_int(data, UVM_ALL_ON) `uvm_object_utils_end // uvm_object constructor takes a STRING name, not testbench parent function new(string name = "axi_txn"); super.new(name); endfunction endclass
📘 Built-In Utilities

Because everything inherits from uvm_object, UVM can provide generic, reusable utilities like .copy(), .compare(), .print(), .clone(), and factory-based creation for ANY derived class, as long as the field macros or manual overrides are provided.

64uvm_component

uvm_component is the base class for structural, persistent testbench building blocks — drivers, monitors, agents, environments, tests. Unlike uvm_object, its constructor takes a parent handle to establish hierarchy, and it participates in the phasing mechanism.

SystemVerilog / UVM
class axi_driver extends uvm_driver #(axi_txn); `uvm_component_utils(axi_driver) virtual axi_if vif; // uvm_component constructor takes NAME + PARENT (establishes hierarchy) function new(string name, uvm_component parent); super.new(name, parent); endfunction virtual task run_phase(uvm_phase phase); forever begin axi_txn tr; seq_item_port.get_next_item(tr); drive_to_dut(tr); seq_item_port.item_done(); end endtask endclass
Aspectuvm_objectuvm_component
LifetimeTransient — created/destroyed freelyPersistent — built once, lives for the whole test
Constructor Argsstring namestring name, uvm_component parent
Participates in Phasing?NoYes (build_phase, run_phase, etc.)
ExamplesTransactions, sequences, config objectsDriver, monitor, agent, env, test, scoreboard

65Factory

The UVM factory is a registry-based object creation mechanism — instead of directly calling new(), components and objects are created via ::type_id::create(), which allows any registered class to be transparently substituted (overridden) at runtime without editing existing code.

SystemVerilog / UVM
// creating via the factory instead of raw new() axi_driver drv; drv = axi_driver::type_id::create("drv", this); // Factory OVERRIDE -- swap in a derived class WITHOUT touching // the env/agent code that calls create() above class error_injecting_driver extends axi_driver; `uvm_component_utils(error_injecting_driver) // ... overridden behavior with injected errors ... endclass // in the test, BEFORE the env is built: axi_driver::type_id::set_type_override(error_injecting_driver::get_type()); // now EVERY axi_driver::type_id::create() call anywhere in the // testbench transparently returns an error_injecting_driver instead
💡 Why This Matters

The factory is what makes UVM VIP truly reusable: a base environment can be dropped into a new test unmodified, and specific components swapped out per test using overrides — no editing of the reusable environment/agent code required.

66Configuration Database

The uvm_config_db is a global, hierarchical key-value store used to pass configuration data (virtual interfaces, knobs, objects) top-down through the testbench hierarchy without hardcoding paths or manually threading arguments through every constructor.

SystemVerilog / UVM
// SET -- typically done in the top-level test or testbench module uvm_config_db #(virtual axi_if)::set(null, "*", "vif", top_if); // args: (context, instance_path_wildcard, field_name, value) // GET -- typically done in a component's build_phase class axi_driver extends uvm_driver #(axi_txn); virtual axi_if vif; function void build_phase(uvm_phase phase); super.build_phase(phase); if (!uvm_config_db #(virtual axi_if)::get(this, "", "vif", vif)) `uvm_fatal("NOVIF", "virtual interface not set in config_db") endfunction endclass
🚫 The #1 UVM Runtime Error

Forgetting the uvm_config_db::set() call in the top module — or getting the instance path wildcard wrong — is the single most common cause of a "virtual interface is null / not set" fatal error at simulation start. Always get() with a fatal check as shown above so the failure is immediate and obvious.

67TLM

Transaction-Level Modeling (TLM) ports/exports/analysis-ports are UVM's standardized inter-component communication mechanism — components exchange whole transactions (not signal-level pin toggling) through typed, connectable interfaces.

SystemVerilog / UVM
// Monitor broadcasts observed transactions via an analysis_port // -- ANY NUMBER of subscribers (scoreboard, coverage) can connect, // unlike a normal port which is 1-to-1 class axi_monitor extends uvm_monitor; uvm_analysis_port #(axi_txn) ap; function new(string name, uvm_component parent); super.new(name, parent); ap = new("ap", this); endfunction virtual task run_phase(uvm_phase phase); axi_txn tr; forever begin collect_transaction(tr); ap.write(tr); // broadcast to ALL connected subscribers end endtask endclass // Scoreboard implements the receiving side class axi_scoreboard extends uvm_scoreboard; uvm_analysis_imp #(axi_txn, axi_scoreboard) imp; function void write(axi_txn tr); // called automatically when monitor.ap.write() fires // compare against reference model endfunction endclass // wiring in the environment's connect_phase: function void connect_phase(uvm_phase phase); monitor.ap.connect(scoreboard.imp); endfunction
📘 seq_item_port / seq_item_export

The driver-sequencer connection uses a different TLM flavor: seq_item_port (driver side) and seq_item_export (sequencer side), with request/response semantics (get_next_item/item_done) rather than the broadcast-style analysis port used for monitor→scoreboard communication.

68Sequences

A uvm_sequence generates a stream of transactions and sends them to a driver through a sequencer — sequences are where randomized, scenario-specific stimulus logic lives, kept cleanly separate from the driver's pin-wiggling responsibilities.

SystemVerilog / UVM
class axi_write_seq extends uvm_sequence #(axi_txn); `uvm_object_utils(axi_write_seq) function new(string name = "axi_write_seq"); super.new(name); endfunction virtual task body(); axi_txn tr; repeat (10) begin tr = axi_txn::type_id::create("tr"); start_item(tr); // requests sequencer arbitration assert(tr.randomize() with { is_write == 1; }); finish_item(tr); // sends to driver, waits for item_done() end endtask endclass // started from a test: axi_write_seq seq = axi_write_seq::type_id::create("seq"); seq.start(env.agent.sequencer);
💡 start_item / finish_item

These bracket exactly where sequencer arbitration and randomization happen — start_item() waits for the sequencer to grant this sequence access, and finish_item() sends the (typically just-randomized) item to the driver and blocks until item_done() is called back.

69Drivers

A uvm_driver pulls transactions from the sequencer and converts them into actual pin-level activity on the DUT interface, cycle by cycle — it's the only component that should ever directly wiggle DUT signals for stimulus.

SystemVerilog / UVM
class axi_driver extends uvm_driver #(axi_txn); `uvm_component_utils(axi_driver) virtual axi_if vif; function new(string name, uvm_component parent); super.new(name, parent); endfunction virtual task run_phase(uvm_phase phase); forever begin axi_txn tr; seq_item_port.get_next_item(tr); // pull next item from sequencer drive_transfer(tr); // pin-level driving happens here seq_item_port.item_done(); // signal completion back to sequence end endtask task automatic drive_transfer(axi_txn tr); @(vif.cb); vif.cb.addr <= tr.addr; vif.cb.wdata <= tr.data; vif.cb.we <= tr.is_write; vif.cb.valid <= 1'b1; @(vif.cb iff vif.cb.ready); vif.cb.valid <= 1'b0; endtask endclass

70Monitors

A uvm_monitor passively observes DUT interface pins (never drives them), reconstructs transactions from the observed signal activity, and broadcasts them via an analysis port for scoreboards and coverage collectors to consume.

SystemVerilog / UVM
class axi_monitor extends uvm_monitor; `uvm_component_utils(axi_monitor) virtual axi_if vif; uvm_analysis_port #(axi_txn) ap; function new(string name, uvm_component parent); super.new(name, parent); ap = new("ap", this); endfunction virtual task run_phase(uvm_phase phase); forever begin axi_txn tr = axi_txn::type_id::create("tr"); @(vif.cb iff (vif.cb.valid && vif.cb.ready)); tr.addr = vif.cb.addr; // PASSIVE sampling only -- never drives vif signals tr.data = vif.cb.wdata; ap.write(tr); // broadcast reconstructed transaction end endtask endclass
⚠️ Passive, Always

A monitor should never drive any DUT signal — its only job is observation. This separation is what lets the same monitor be reused whether the agent is configured active (driving stimulus) or passive (checking-only, e.g. for a bus already driven by another VIP).

71Agents

A uvm_agent packages the sequencer, driver, and monitor for one DUT interface/protocol into a single reusable unit, with an is_active knob to switch between fully active (drives + monitors) and passive (monitor-only) operation.

SystemVerilog / UVM
class axi_agent extends uvm_agent; `uvm_component_utils(axi_agent) axi_sequencer sequencer; axi_driver driver; axi_monitor monitor; function new(string name, uvm_component parent); super.new(name, parent); endfunction function void build_phase(uvm_phase phase); super.build_phase(phase); monitor = axi_monitor::type_id::create("monitor", this); if (get_is_active() == UVM_ACTIVE) begin // only build driver/sequencer if active sequencer = axi_sequencer::type_id::create("sequencer", this); driver = axi_driver::type_id::create("driver", this); end endfunction function void connect_phase(uvm_phase phase); if (get_is_active() == UVM_ACTIVE) driver.seq_item_port.connect(sequencer.seq_item_export); endfunction endclass

72Environment

A uvm_env is the container above agents — it groups one or more agents plus shared components like the scoreboard and coverage collector, and typically represents "the whole reusable verification environment for this DUT."

SystemVerilog / UVM
class axi_env extends uvm_env; `uvm_component_utils(axi_env) axi_agent agent; axi_scoreboard scoreboard; function new(string name, uvm_component parent); super.new(name, parent); endfunction function void build_phase(uvm_phase phase); super.build_phase(phase); agent = axi_agent::type_id::create("agent", this); scoreboard = axi_scoreboard::type_id::create("scoreboard", this); endfunction function void connect_phase(uvm_phase phase); agent.monitor.ap.connect(scoreboard.imp); endfunction endclass
📘 Reuse Goal

A well-built uvm_env should be droppable into many different tests unmodified — all per-test variation (which sequences run, which knobs are set) belongs in the test class, not the environment.

73Scoreboard

A scoreboard checks DUT correctness by comparing actual observed outputs (from monitors) against expected outputs (from a reference model or predicted values) — the component where pass/fail correctness checking actually happens.

SystemVerilog / UVM
class axi_scoreboard extends uvm_scoreboard; `uvm_component_utils(axi_scoreboard) uvm_analysis_imp #(axi_txn, axi_scoreboard) imp; axi_txn expected_q[$]; // queue of expected transactions from a reference model function new(string name, uvm_component parent); super.new(name, parent); imp = new("imp", this); endfunction // called automatically whenever the monitor broadcasts a transaction function void write(axi_txn actual); axi_txn expected; if (expected_q.size() == 0) begin `uvm_error("SCBD", "unexpected transaction, no prediction queued") return; end expected = expected_q.pop_front(); if (!expected.compare(actual)) `uvm_error("SCBD", "MISMATCH: expected vs actual differ") else `uvm_info("SCBD", "transaction matched", UVM_HIGH) endfunction endclass

74Test

A uvm_test sits at the very top of the hierarchy — it builds (or configures) the environment, applies test-specific factory overrides, and starts the sequence(s) that define this particular test scenario.

SystemVerilog / UVM
class axi_base_test extends uvm_test; `uvm_component_utils(axi_base_test) axi_env env; function new(string name = "axi_base_test", uvm_component parent = null); super.new(name, parent); endfunction function void build_phase(uvm_phase phase); super.build_phase(phase); env = axi_env::type_id::create("env", this); endfunction virtual task run_phase(uvm_phase phase); axi_write_seq seq = axi_write_seq::type_id::create("seq"); phase.raise_objection(this); // see Module 9: Objections seq.start(env.agent.sequencer); phase.drop_objection(this); endtask endclass // A specific test scenario just extends the base test and swaps sequences class axi_error_test extends axi_base_test; `uvm_component_utils(axi_error_test) // override run_phase to start an error-injecting sequence instead endclass

75Phases

UVM phasing synchronizes the setup and execution lifecycle across every component in the hierarchy automatically — build first, then connect, then run, then cleanup — so components don't need custom hand-written synchronization to know when it's safe to, say, access a child that hasn't been constructed yet.

PhaseTypeTypical Use
build_phaseFunction (top-down)Construct child components via the factory
connect_phaseFunction (bottom-up)Connect TLM ports/exports between components
end_of_elaboration_phaseFunctionFinal setup/sanity checks after full hierarchy exists
start_of_simulation_phaseFunctionLast chance for setup right before time advances
run_phaseTask (consumes simulation time)Main stimulus generation and checking activity
extract_phaseFunctionExtract results/scoreboard data after run_phase ends
check_phaseFunctionFinal correctness checks (e.g. no pending transactions)
report_phaseFunctionPrint final pass/fail summary
SystemVerilog / UVM
// build_phase runs TOP-DOWN: test's build_phase completes before // env's build_phase runs, which completes before agent's, etc. // connect_phase runs BOTTOM-UP: agents connect before env-level // connections happen -- this ordering is automatic and requires // no manual synchronization code from the user function void build_phase(uvm_phase phase); super.build_phase(phase); // ALWAYS call super first in build_phase // ... create child components here ... endfunction
💡 Interview Tip

"Why is run_phase a task and not a function?" — Because it's the only phase (among the standard ones) allowed to consume simulation time (via #delay, @(posedge clk), wait, etc.); build/connect and the other structural phases must complete instantaneously at time 0 so the entire hierarchy is fully built and wired before any stimulus begins.

🎯 Module 8 Recap

  • UVM standardizes testbench structure so verification IP is reusable across projects instead of rebuilt from scratch each time.
  • uvm_object = transient data (transactions, sequences); uvm_component = persistent structural hierarchy (driver, monitor, agent, env, test).
  • The factory (::type_id::create()) enables transparent class substitution via overrides, without touching existing code.
  • config_db passes configuration (especially virtual interfaces) top-down through the hierarchy — a null/unset vif is the most common UVM runtime error.
  • TLM analysis ports let a monitor broadcast to any number of subscribers (scoreboard, coverage) with a single write() call.
  • Data flow: sequence generates transactions → sequencer arbitrates → driver drives pins → monitor passively observes → scoreboard checks correctness.
  • Agent bundles sequencer+driver+monitor with an active/passive switch; environment bundles agents + scoreboard + coverage; test configures everything and starts sequences.
  • Phasing (build → connect → run → check → report) automatically synchronizes setup order across the entire hierarchy — build_phase runs top-down, connect_phase runs bottom-up.

📚 Next up — Module 9: Advanced UVM (callbacks, objections, virtual sequences, register model, sequence library, report server, factory overrides, resource database)

↑ Back to Table of Contents

Comments

Popular posts from this blog

Module 1 — SystemVerilog Basics

VLSI Verification  •  SystemVerilog Series Module 1 — SystemVerilog Basics A complete, example-driven walkthrough of SystemVerilog fundamentals: data types, variables vs nets, arrays of every flavor, strings, enums, structs, unions, and typedef — the building blocks every verification engineer needs before UVM. 🧩 Beginner → Intermediate ⏱ ~25 min read 💻 Code Examples Included 📑 Table of Contents Introduction to SystemVerilog Verilog vs SystemVerilog Data Types: 2-State vs 4-State Logic Variables and Nets Arrays: Packed vs Unpacked Dynamic Arrays Queues Associative Arrays Strings Enumerations Structures Unions Typedef 1 Introduction to SystemVerilog SystemVerilog (IEEE 1800) is a unified hardware description and verification language (HDVL). It extends Verilog (IEEE 1364) with powerful constructs for design (interfaces, always_comb/always_ff, enhanced d...

Clock Domain Crossing (CDC): A Complete Beginner's Guide to Metastability, Synchronizers & Safe Data Transfer

Clock Domain Crossing (CDC): A Complete Beginner's Guide to Metastability, Synchronizers & Safe Data Transfer Modern System-on-Chip (SoC) designs rarely operate with a single clock. Instead, different modules such as CPUs, GPUs, memory controllers, communication interfaces, and peripherals often run at different clock frequencies or even use completely independent clock sources . When data moves from one clock domain to another, timing uncertainty can cause serious problems such as metastability , data corruption , and unpredictable system behaviour . This challenge is known as Clock Domain Crossing (CDC) . CDC is one of the most important topics in ASIC Design , RTL Design , ASIC Verification , FPGA Design , and SoC Architecture . Every modern chip—from smartphones to automotive processors—uses CDC techniques to ensure reliable communication between multiple clock domains. In this article, we'll explore CDC fundamentals, metastability, synchronization techniques, asynchro...

GPU Memory System & Interconnect: How Data Travels Inside a Modern GPU

GPU Memory System & Interconnect: How Data Travels Inside a Modern GPU Modern GPUs deliver incredible computing power by processing thousands of operations simultaneously. While compute cores often receive the spotlight, the real performance of a GPU depends heavily on how efficiently data moves between memory and compute units. A GPU memory system is designed to provide extremely high bandwidth while keeping latency as low as possible. This is achieved through a collection of specialized hardware components working together, including the Memory Controller, HBM/GDDR memory, Crossbar, Network-on-Chip (NoC), DMA Engine, PCIe Interface, and NVLink. In this article, we'll explore each component in detail and understand how they collectively enable high-performance parallel computing. Why Does GPU Memory Matter? Every GPU application—from gaming and graphics rendering to AI model training and scientific simulations—requires continuous movement of enormous amounts of data. For examp...

AXI Verification Interview Questions and Real-World Debugging

AMBA Protocol Series · Part 10 of 10 AXI Verification Interview Questions and Real-World Debugging Common protocol violations, how to read them off a waveform, and a curated set of interview questions with concise, correct answers — the capstone of the core 10-day series. AMBA Protocol Series: From APB & AHB to AXI — A Complete Guide for VLSI Engineers This wraps up the core 10-day series. Everything here draws directly on Days 1–9 — if any answer below feels unfamiliar, that's a good signal for which earlier post to revisit. (If you want to go further, see the 20-day extended list at the end of this post.) In This Article Common Protocol Violations Debugging From a Waveform Interview Questions and Answers Series Recap Extending the Series 1. Common Protocol Violations VALID deasserted before handshake — a source drops VALID before READY ever went high (violates the Day 8 stabi...

Timing Basics in Static Timing Analysis (STA): Delay Models, Sequential Timing, and Wire Delays

Timing Basics in Static Timing Analysis (STA) Static Timing Analysis (STA) is one of the most important verification techniques used in modern VLSI design. Before a chip is manufactured, engineers must verify that every signal reaches its destination within the required clock period. Even if a design passes functional simulation, it may still fail after fabrication because of timing violations. Unlike simulation, Static Timing Analysis mathematically analyzes every timing path without applying input test vectors. This makes STA significantly faster and capable of analyzing millions of timing paths efficiently. Table of Contents What is Static Timing Analysis? Why STA is Required Propagation Delay Contamination Delay Cell Delay Models Combinational Gate Delay Sequential Timing Setup Time Hold Time Wire Delay RC Delay Model PVT Corners Worked Examples Interview Questions Key Takeaways What is Static Timing Analysis? Static Ti...

Cache Basics and Cache Mapping Techniques

  Cache Basics and Cache Mapping Techniques  Modern processors execute billions of instructions every second. However, processor speed has increased much faster than main memory (RAM) speed. This difference, known as the memory wall , creates a performance bottleneck because the CPU often has to wait for data from slower memory. To solve this problem, computer systems use cache memory —a small, high-speed memory located between the CPU and the main memory. In this article, we will understand the fundamentals of cache memory, the principle of locality, cache organization, and the three major cache mapping techniques. What is Cache Memory? Cache memory is a small, high-speed memory that stores copies of frequently accessed data from the main memory. Since accessing cache is much faster than accessing RAM, the CPU first checks whether the required data is available in the cache. If the data is found in the cache, it is called a cache hit . Otherwise, the CPU fetches the dat...

CMOS Power & Scaling Explained: Dynamic Power, Leakage Power, Short-Circuit Power & Technology Scaling

  CMOS Power & Scaling Explained: Dynamic Power, Leakage Power, Short-Circuit Power & Technology Scaling Day 6 | CMOS Design Fundamentals | The Silicon Stack As integrated circuits continue to become smaller, faster, and more powerful, power consumption has emerged as one of the biggest challenges in modern VLSI design. While early digital circuits primarily focused on functionality and speed, today's processors, AI accelerators, smartphones, and IoT devices must deliver high performance while operating within strict power and thermal limits. A modern System-on-Chip (SoC) may contain billions of CMOS transistors , each switching billions of times per second. Even a tiny amount of power consumed by each transistor adds up to significant energy consumption across the entire chip. Excessive power not only drains batteries but also generates heat, reduces reliability, and limits performance. Understanding where CMOS power comes from and how it can be reduced is therefore ...