Introduction to UVM
Understand the components of a UVM environment and when the methodology adds value over a simple SystemVerilog testbench.
A methodology built on SystemVerilog
UVM, the Universal Verification Methodology, is a class library and an organization method for SystemVerilog testbenches. It standardizes familiar roles: sequences, driver, monitor, agent, scoreboard, environment, and test.
UVM does not replace protocol knowledge or a reference model. It provides a common structure, phases, reporting, an object factory, and configuration and communication mechanisms.
Main components
A typical environment contains:
- a
sequence_itemrepresenting one transaction; - a
sequenceproducing a series of items; - a
sequencerarbitrating sequences; - a
driverapplying items to an interface; - a
monitorobserving transfers; - an
agentgrouping sequencer, driver, and monitor; - a scoreboard and sometimes a reference model;
- an
envconnecting components; - a
testselecting configuration and starting the scenario.
The driver and sequencer exchange items through a UVM transaction protocol. The monitor usually publishes observed transactions through an analysis port to coverage or a scoreboard.
Build and run phases
Components are created and configured in function phases such as build_phase and connect_phase. Activities that consume simulation time live in run_phase.
class stream_monitor extends uvm_monitor;
`uvm_component_utils(stream_monitor)
uvm_analysis_port #(stream_item) observed;
virtual stream_if vif;
function new(string name, uvm_component parent);
super.new(name, parent);
observed = new("observed", this);
endfunction
task run_phase(uvm_phase phase);
forever begin
@(posedge vif.clk);
if (vif.valid && vif.ready) begin
stream_item item = stream_item::type_id::create("item");
item.data = vif.data;
observed.write(item);
end
end
endtask
endclassThis code shows the structure, but a real monitor must also retrieve its virtual interface from configuration, handle reset, and reconstruct every protocol field.
Factory and configuration
The factory can replace a type with a variant without modifying every creation point. This is useful for injecting a special transaction or enhanced component, provided objects are created with type_id::create.
uvm_config_db passes configuration such as a virtual interface. An overly broad scope or misspelled key can fail late, so check every get and keep paths as local as possible.
When to use UVM
UVM becomes valuable with several interfaces, configuration variants, subsystem-level reuse, or a team sharing the same method. For a small block with ten directed cases, a plain SystemVerilog testbench is often faster and clearer.
A good starting point is to master a layered environment without UVM. The same responsibilities then map naturally to UVM classes.
Key points
- UVM organizes a SystemVerilog testbench with a standard library.
- Sequence, driver, monitor, scoreboard, and environment keep separate roles.
- Function phases build and connect, while
run_phaseadvances time. - Factory and configuration add flexibility but need careful checks.
- UVM helps reuse and large environments, not automatically every block.
📝 Test your knowledge - Chapter quiz