BitFlow

UVM basics: the Universal Verification Methodology explained

What UVM is and how a UVM testbench is built: sequence items, sequences, drivers, monitors, agents, scoreboards, the environment and the test, plus the phases that run them.

By BitFlow · · 9 min read

What UVM is

UVM (Universal Verification Methodology) is a standard class library for SystemVerilog, maintained by Accellera and standardised as IEEE 1800.2. It gives every verification team the same building blocks for testbenches: components that generate stimulus, drive it into the design, watch what comes out and check it.

A plain Verilog testbench is one module that pokes inputs and checks outputs. That works for a counter, but not for a PCIe controller verified by ten engineers over a year. UVM's point is reuse: an agent written for one AXI interface plugs into every block that has one.

The pieces of a UVM testbench

ComponentJob
Sequence item (uvm_sequence_item)One transaction: a bus write, a packet. Fields are usually rand so they can be randomized.
Sequence (uvm_sequence)Generates a stream of sequence items: the stimulus scenario.
Sequencer (uvm_sequencer)Hands items from the running sequences to the driver.
Driver (uvm_driver)Turns each transaction into pin-level wiggles on the interface.
Monitor (uvm_monitor)Watches the pins and turns activity back into transactions; never drives anything.
Agent (uvm_agent)Bundles sequencer, driver and monitor for one interface. Passive agents only monitor.
Scoreboard (uvm_scoreboard)Compares what the design did with what a reference model predicts.
Environment (uvm_env)Holds the agents, scoreboards and coverage for a block.
Test (uvm_test)Builds the environment, configures it and picks which sequences run.

Components pass transactions through TLM ports (analysis ports from monitors to scoreboards), and get configuration from the uvm_config_db, including the virtual interface that connects classes to the design's pins.

A sequence item and a driver

class bus_item extends uvm_sequence_item;
  rand bit [7:0]  addr;
  rand bit [31:0] data;
  rand bit        write;
  `uvm_object_utils(bus_item)
  function new(string name = "bus_item"); super.new(name); endfunction
endclass

class bus_driver extends uvm_driver #(bus_item);
  `uvm_component_utils(bus_driver)
  virtual bus_if vif;
  function new(string name, uvm_component parent); super.new(name, parent); endfunction
  task run_phase(uvm_phase phase);
    forever begin
      seq_item_port.get_next_item(req);
      @(posedge vif.clk);
      vif.addr <= req.addr; vif.wdata <= req.data; vif.we <= req.write; vif.valid <= 1;
      @(posedge vif.clk); vif.valid <= 0;
      seq_item_port.item_done();
    end
  endtask
endclass

Phases

Every component runs through the same phases, so the whole testbench is built and started in a predictable order:

  • build_phase: create child components (top-down).
  • connect_phase: connect ports between them.
  • run_phase: the time-consuming part where stimulus runs. A test raises an objection to keep the simulation alive and drops it when done.
  • check_phase / report_phase: final checks and the summary.

How to learn it

UVM sits on top of SystemVerilog classes, randomization and coverage, which sit on top of solid Verilog. Learn in that order: write self-checking Verilog testbenches first, then SystemVerilog constrained-random stimulus and covergroups, then UVM. Most UVM interview questions are really about those foundations.

Questions

What is UVM in verification?

UVM (Universal Verification Methodology) is a standardized SystemVerilog class library (IEEE 1800.2) for building reusable, constrained-random testbenches out of sequences, drivers, monitors, agents, scoreboards and environments.

What is the difference between a driver and a monitor in UVM?

A driver converts transactions into signal activity on the design's pins. A monitor only observes the pins and converts activity back into transactions for scoreboards and coverage; it never drives signals.

What is a UVM agent?

An agent groups the sequencer, driver and monitor for one interface. An active agent drives stimulus; a passive agent only monitors.

Do I need to know SystemVerilog before UVM?

Yes. UVM is written in SystemVerilog and relies on classes, randomization, interfaces and coverage, so those should be learned first.

Was this article helpful?

Keep going