UVM vs SystemVerilog: The Real Advantages, Shown in Code (Tested)
In short: UVM is not a new language but a class library, plus a set of rules, written in SystemVerilog. Plain SystemVerilog can verify a design, but every team builds its testbench a different way. UVM gives every testbench the same parts (agents, sequences, scoreboards), a config database, a factory to swap parts, phases and reporting, so you can reuse a testbench and write new tests without editing it.
“Why not just use SystemVerilog?” is a fair question, and the honest answer is that for a tiny block you can. The difference shows when the same testbench has to serve fifty tests, three projects and five engineers.
In this lesson we test the same tiny memory twice: once in plain SystemVerilog and once in UVM, with each advantage turned into a check you can see. I ran both on Synopsys VCS.
Start here: the simplest example
A memory with a one-clock read latency, tested in plain SystemVerilog. Two writes, two reads, a PASS or FAIL line per read.
// tav_uvmsv_simple.sv : a plain SystemVerilog testbench, the "before UVM" picture (UVM 1.2 reporting only)
// The Art of Verification | theartofverification.com
// Run on Synopsys VCS X-2025.06-SP1 with UVM 1.2 (EDA Playground), 1 Dec 2026.
// EDA Playground: Synopsys VCS, UVM 1.2, top module "tav_top".
`timescale 1ns/1ns
`include "uvm_macros.svh"
// The design: a tiny memory with a one-clock read latency
module tav_mem (input logic clk, en, wr, input logic [7:0] addr, wdata, output bit [7:0] rdata);
bit [7:0] mem [256];
always @(posedge clk) begin
if (en && wr) mem[addr] <= wdata;
if (en && !wr) rdata <= mem[addr];
end
endmodule
module tav_top;
import uvm_pkg::*;
logic clk = 0, en = 0, wr = 0;
logic [7:0] addr, wdata;
bit [7:0] rdata, d;
always #5 clk = ~clk;
tav_mem u_mem (.*);
// Stimulus, driving and checking all live in this one module
task automatic tav_write(input [7:0] a, input [7:0] v);
@(negedge clk) en = 1; wr = 1; addr = a; wdata = v;
@(negedge clk) en = 0;
endtask
task automatic tav_read(input [7:0] a, output [7:0] v);
@(negedge clk) en = 1; wr = 0; addr = a;
@(negedge clk) en = 0;
v = rdata;
endtask
initial begin
tav_write(8'h10, 8'hA0);
tav_write(8'h20, 8'hA1);
tav_read (8'h10, d);
`uvm_info("TAV_SIMPLE", $sformatf("read 'h10 = %h (expect a0) %s", d, (d == 8'hA0) ? "PASS" : "FAIL"), UVM_NONE)
tav_read (8'h20, d);
`uvm_info("TAV_SIMPLE", $sformatf("read 'h20 = %h (expect a1) %s", d, (d == 8'hA1) ? "PASS" : "FAIL"), UVM_NONE)
$finish;
end
endmodule
Here is what VCS printed:
UVM_INFO testbench.sv(43) @ 60: reporter [TAV_SIMPLE] read 'h10 = a0 (expect a0) PASS
UVM_INFO testbench.sv(45) @ 80: reporter [TAV_SIMPLE] read 'h20 = a1 (expect a1) PASS
- It works: both reads returned what was written.
- But look at where everything lives: stimulus, pin driving, timing and checking are all in one module. A second test means copying or editing that module.
Nothing is wrong with this for a quick check. The UVM version below does the same job, split into parts that can each be reused or changed on their own.
What you will learn
- What UVM adds on top of SystemVerilog, and what it does not.
- How agents, sequences and scoreboards split up the work.
- How
uvm_config_dband the factory change a testbench without editing it. - How phases and reporting keep every testbench predictable.
- When plain SystemVerilog is still the right choice.
Cheat sheet: what UVM gives you
| Advantage | Plain SystemVerilog | UVM |
|---|---|---|
| Structure | Your own, different on every project | Agent, driver, monitor, sequencer, scoreboard, env, test |
| Stimulus | Tasks called from an initial block | Sequences, started on a sequencer by the test |
| Settings | Parameters, globals or plusargs | uvm_config_db, set from above, read anywhere below |
| Swapping parts | Edit the code | Factory override from the test |
| Order of setup | Whatever the initial blocks do | Phases: build, connect, run, report |
| Messages | $display | `uvm_info with verbosity, IDs and counts |
Analogy: plain SystemVerilog is building every kitchen from raw timber. UVM is a set of standard cabinets and fittings: you still design the kitchen, but every cabinet fits every wall, and any carpenter knows how they go together.
Going further: the same test in UVM, 7 checks
tav_wr_rd_seqholds the stimulus, and reads its length fromuvm_config_db.tav_agentis built twice: active (sequencer, driver, monitor) and passive (monitor only).tav_sbmodels the memory and compares every read. The test swaps it fortav_sb_verbosethrough the factory.- Planted bug:
+BUG=1makes the monitor sample read data one clock too early.
Run it yourself: both files are on GitHub, with the expected output.
// tav_uvmsv_uvm.sv : the same memory test in UVM, each advantage as a self-check (UVM 1.2)
// The Art of Verification | theartofverification.com
// Run on Synopsys VCS X-2025.06-SP1 with UVM 1.2 (EDA Playground), 1 Dec 2026.
// EDA Playground: Synopsys VCS, UVM 1.2, top module "tav_top".
// Paste this whole file into testbench.sv and leave design.sv empty.
//
// What is in here:
// tav_mem / tav_mem_if the same tiny memory as the simple example, behind an interface
// tav_item, tav_wr_rd_seq the transaction and a sequence (stimulus lives here, not in the test)
// tav_drv, tav_mon, tav_agent a reusable agent (active or passive)
// tav_sb, tav_sb_verbose a scoreboard, and a child of it swapped in by the factory
// tav_env, tav_uvmsv_test the environment and the test: 7 self-checks
//
// Run options:
// (none) all 7 checks pass, 0 errors
// +BUG=1 the monitor samples read data one clock too early, so the scoreboard sees 2 mismatches (check 3 fails)
`timescale 1ns/1ns
`include "uvm_macros.svh"
module tav_mem (input logic clk, en, wr, input logic [7:0] addr, wdata, output bit [7:0] rdata);
bit [7:0] mem [256];
always @(posedge clk) begin
if (en && wr) mem[addr] <= wdata;
if (en && !wr) rdata <= mem[addr];
end
endmodule
interface tav_mem_if (input logic clk);
logic en = 0, wr = 0;
logic [7:0] addr, wdata;
bit [7:0] rdata;
endinterface
package tav_uvmsv_pkg;
import uvm_pkg::*;
`include "uvm_macros.svh"
string tav_trace; // phase order, filled by the test
class tav_item extends uvm_sequence_item;
`uvm_object_utils(tav_item)
bit wr;
bit [7:0] addr, data;
function new(string name = "tav_item"); super.new(name); endfunction
function string convert2string();
return $sformatf("%s addr=%h data=%h", wr ? "WR" : "RD", addr, data);
endfunction
endclass
// Advantage: stimulus lives in a sequence, and its length comes from config_db
class tav_wr_rd_seq extends uvm_sequence #(tav_item);
`uvm_object_utils(tav_wr_rd_seq)
int tav_num = 2;
function new(string name = "tav_wr_rd_seq"); super.new(name); endfunction
task body();
tav_item it;
// config_db, looked up through the sequencer's path (uvm_test_top.env.agt.seqr)
void'(uvm_config_db#(int)::get(m_sequencer, "", "tav_num", tav_num));
for (int i = 0; i < tav_num; i++) begin
it = tav_item::type_id::create("it");
start_item(it);
it.wr = (i < tav_num / 2); // first half writes, second half reads
it.addr = 8'h10 * ((i % (tav_num / 2)) + 1);
it.data = it.wr ? (8'hA0 + i) : 8'h00;
finish_item(it);
end
endtask
endclass
class tav_drv extends uvm_driver #(tav_item);
`uvm_component_utils(tav_drv)
virtual tav_mem_if vif;
function new(string name, uvm_component parent); super.new(name, parent); endfunction
function void build_phase(uvm_phase phase);
if (!uvm_config_db#(virtual tav_mem_if)::get(this, "", "vif", vif))
`uvm_fatal("TAV_DRV", "no virtual interface in config_db")
endfunction
task run_phase(uvm_phase phase);
forever begin
seq_item_port.get_next_item(req);
@(negedge vif.clk) vif.en = 1; vif.wr = req.wr; vif.addr = req.addr; vif.wdata = req.data;
@(negedge vif.clk) vif.en = 0;
seq_item_port.item_done();
end
endtask
endclass
class tav_mon extends uvm_monitor;
`uvm_component_utils(tav_mon)
virtual tav_mem_if vif;
uvm_analysis_port #(tav_item) ap;
int tav_bug;
function new(string name, uvm_component parent); super.new(name, parent); ap = new("ap", this); endfunction
function void build_phase(uvm_phase phase);
void'(uvm_config_db#(virtual tav_mem_if)::get(this, "", "vif", vif));
void'($value$plusargs("BUG=%d", tav_bug));
endfunction
task run_phase(uvm_phase phase);
tav_item it;
forever begin
@(posedge vif.clk);
if (vif.en) begin
it = tav_item::type_id::create("it");
it.wr = vif.wr; it.addr = vif.addr; it.data = vif.wdata;
if (!it.wr) begin
if (tav_bug != 1) @(posedge vif.clk); // read data is ready one clock later
it.data = vif.rdata; // BUG=1: sampled one clock too early
end
`uvm_info("TAV_MON", it.convert2string(), UVM_MEDIUM)
`uvm_info("TAV_DBG", "debug detail, hidden at the default verbosity", UVM_HIGH)
ap.write(it);
end
end
endtask
endclass
// Advantage: one agent, reused active or passive
class tav_agent extends uvm_agent;
`uvm_component_utils(tav_agent)
tav_drv drv;
uvm_sequencer #(tav_item) seqr;
tav_mon mon;
function new(string name, uvm_component parent); super.new(name, parent); endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase); // reads is_active from config_db
mon = tav_mon::type_id::create("mon", this);
if (get_is_active() == UVM_ACTIVE) begin
drv = tav_drv::type_id::create("drv", this);
seqr = uvm_sequencer#(tav_item)::type_id::create("seqr", this);
end
endfunction
function void connect_phase(uvm_phase phase);
if (get_is_active() == UVM_ACTIVE) drv.seq_item_port.connect(seqr.seq_item_export);
endfunction
endclass
class tav_sb extends uvm_scoreboard;
`uvm_component_utils(tav_sb)
uvm_analysis_imp #(tav_item, tav_sb) imp;
bit [7:0] tav_model [bit [7:0]];
int tav_items, tav_reads, tav_mismatch;
function new(string name, uvm_component parent); super.new(name, parent); imp = new("imp", this); endfunction
virtual function void write(tav_item t);
tav_items++;
if (t.wr) tav_model[t.addr] = t.data;
else begin
tav_reads++;
if (tav_model[t.addr] != t.data) begin
tav_mismatch++;
`uvm_info("TAV_SB", $sformatf("MISMATCH read %h: got %h, expected %h", t.addr, t.data, tav_model[t.addr]), UVM_LOW)
end
end
endfunction
endclass
// Advantage: a child class the factory can put in place of tav_sb, without editing tav_env
class tav_sb_verbose extends tav_sb;
`uvm_component_utils(tav_sb_verbose)
function new(string name, uvm_component parent); super.new(name, parent); endfunction
endclass
class tav_env extends uvm_env;
`uvm_component_utils(tav_env)
tav_agent agt, agt_passive;
tav_sb sb;
function new(string name, uvm_component parent); super.new(name, parent); endfunction
function void build_phase(uvm_phase phase);
agt = tav_agent::type_id::create("agt", this);
agt_passive = tav_agent::type_id::create("agt_passive", this);
sb = tav_sb::type_id::create("sb", this);
endfunction
function void connect_phase(uvm_phase phase);
agt.mon.ap.connect(sb.imp);
endfunction
endclass
class tav_uvmsv_test extends uvm_test;
`uvm_component_utils(tav_uvmsv_test)
tav_env env;
tav_wr_rd_seq seq;
int tav_pass, tav_fail;
function new(string name, uvm_component parent); super.new(name, parent); endfunction
function void build_phase(uvm_phase phase);
tav_trace = {tav_trace, "build "};
uvm_config_db#(int)::set(this, "env.*", "tav_num", 4); // config reaches deep
uvm_config_db#(uvm_active_passive_enum)::set(this, "env.agt_passive", "is_active", UVM_PASSIVE);
tav_sb::type_id::set_type_override(tav_sb_verbose::get_type()); // factory swap
env = tav_env::type_id::create("env", this);
endfunction
function void connect_phase(uvm_phase phase); tav_trace = {tav_trace, "connect "}; endfunction
function void end_of_elaboration_phase(uvm_phase phase); tav_trace = {tav_trace, "eoe "}; endfunction
task run_phase(uvm_phase phase);
tav_trace = {tav_trace, "run"};
phase.raise_objection(this);
seq = tav_wr_rd_seq::type_id::create("seq");
seq.start(env.agt.seqr); // the sequence reads tav_num itself
#20; // let the last read reach the scoreboard
phase.drop_objection(this);
endtask
function void tav_check(string what, string got, string exp);
if (got == exp) begin
tav_pass++;
`uvm_info("TAV_UVMSV", $sformatf("PASS %s: %s", what, got), UVM_LOW)
end
else begin
tav_fail++;
`uvm_error("TAV_UVMSV", $sformatf("FAIL %s: got %s, expected %s", what, got, exp))
end
endfunction
function void report_phase(uvm_phase phase);
uvm_report_server rs = uvm_report_server::get_server();
string drv_s, mon_s; // string variables: no padding from ? :
tav_check("1 phase order", tav_trace, "build connect eoe run");
tav_check("2 sequence length from config_db", $sformatf("%0d", seq.tav_num), "4");
tav_check("3 scoreboard items / reads / mismatches",
$sformatf("%0d / %0d / %0d", env.sb.tav_items, env.sb.tav_reads, env.sb.tav_mismatch), "4 / 2 / 0");
drv_s = (env.agt_passive.drv == null) ? "none" : "built";
mon_s = (env.agt_passive.mon == null) ? "none" : "built";
tav_check("4 passive agent: driver / monitor", $sformatf("%s / %s", drv_s, mon_s), "none / built");
tav_check("5 factory: scoreboard type", env.sb.get_type_name(), "tav_sb_verbose");
// 2 monitors (active and passive agent) x 4 transactions; UVM_HIGH is filtered at the default verbosity
tav_check("6 TAV_MON shown (2 monitors) / TAV_DBG (UVM_HIGH) shown",
$sformatf("%0d / %0d", rs.get_id_count("TAV_MON"), rs.get_id_count("TAV_DBG")), "8 / 0");
tav_check("7 driver got its virtual interface", (env.agt.drv.vif == null) ? "no" : "yes", "yes");
`uvm_info("TAV_UVMSV", $sformatf("Checks: %0d pass, %0d fail", tav_pass, tav_fail), UVM_NONE)
endfunction
endclass
endpackage
module tav_top;
import uvm_pkg::*;
import tav_uvmsv_pkg::*;
logic clk = 0;
always #5 clk = ~clk;
tav_mem_if vif (clk);
tav_mem u_mem (.clk, .en(vif.en), .wr(vif.wr), .addr(vif.addr), .wdata(vif.wdata), .rdata(vif.rdata));
initial begin
uvm_config_db#(virtual tav_mem_if)::set(null, "uvm_test_top.env.*", "vif", vif);
run_test("tav_uvmsv_test");
end
endmodule
How to run it
- Open EDA Playground and pick Synopsys VCS with UVM 1.2.
- Paste the file into
testbench.svand leavedesign.svempty. - Run it once as is, then add
+BUG=1to the run options and run again.
What VCS returned
| # | Advantage | Check | Result |
|---|---|---|---|
| 1 | Phases | Phase order seen by the test | build connect eoe run |
| 2 | config_db | Sequence length set by the test | 4 |
| 3 | Sequences and scoreboard | Items / reads / mismatches | 4 / 2 / 0 |
| 4 | Reuse | Passive agent: driver / monitor | none / built |
| 5 | Factory | Scoreboard type after the override | tav_sb_verbose |
| 6 | Reporting | TAV_MON shown (2 monitors) / UVM_HIGH debug shown | 8 / 0 |
| 7 | Virtual interface | Driver got its interface from config_db | yes |
Result: 7 pass, 0 fail. Here is the log.
UVM_INFO @ 0: reporter [RNTST] Running test tav_uvmsv_test...
UVM_INFO testbench.sv(110) @ 15: uvm_test_top.env.agt.mon [TAV_MON] WR addr=10 data=a0
UVM_INFO testbench.sv(110) @ 15: uvm_test_top.env.agt_passive.mon [TAV_MON] WR addr=10 data=a0
UVM_INFO testbench.sv(110) @ 35: uvm_test_top.env.agt.mon [TAV_MON] WR addr=20 data=a1
UVM_INFO testbench.sv(110) @ 35: uvm_test_top.env.agt_passive.mon [TAV_MON] WR addr=20 data=a1
UVM_INFO testbench.sv(110) @ 65: uvm_test_top.env.agt.mon [TAV_MON] RD addr=10 data=a0
UVM_INFO testbench.sv(110) @ 65: uvm_test_top.env.agt_passive.mon [TAV_MON] RD addr=10 data=a0
UVM_INFO testbench.sv(110) @ 85: uvm_test_top.env.agt.mon [TAV_MON] RD addr=20 data=a1
UVM_INFO testbench.sv(110) @ 85: uvm_test_top.env.agt_passive.mon [TAV_MON] RD addr=20 data=a1
UVM_INFO /apps/vcsmx/vcs/X-2025.06-SP1//etc/uvm-1.2/src/base/uvm_objection.svh(1276) @ 100: reporter [TEST_DONE] 'run' phase is ready to proceed to the 'extract' phase
UVM_INFO testbench.sv(207) @ 100: uvm_test_top [TAV_UVMSV] PASS 1 phase order: build connect eoe run
UVM_INFO testbench.sv(207) @ 100: uvm_test_top [TAV_UVMSV] PASS 2 sequence length from config_db: 4
UVM_INFO testbench.sv(207) @ 100: uvm_test_top [TAV_UVMSV] PASS 3 scoreboard items / reads / mismatches: 4 / 2 / 0
UVM_INFO testbench.sv(207) @ 100: uvm_test_top [TAV_UVMSV] PASS 4 passive agent: driver / monitor: none / built
UVM_INFO testbench.sv(207) @ 100: uvm_test_top [TAV_UVMSV] PASS 5 factory: scoreboard type: tav_sb_verbose
UVM_INFO testbench.sv(207) @ 100: uvm_test_top [TAV_UVMSV] PASS 6 TAV_MON shown (2 monitors) / TAV_DBG (UVM_HIGH) shown: 8 / 0
UVM_INFO testbench.sv(207) @ 100: uvm_test_top [TAV_UVMSV] PASS 7 driver got its virtual interface: yes
UVM_INFO testbench.sv(230) @ 100: uvm_test_top [TAV_UVMSV] Checks: 7 pass, 0 fail
UVM_INFO /apps/vcsmx/vcs/X-2025.06-SP1//etc/uvm-1.2/src/base/uvm_report_server.svh(904) @ 100: reporter [UVM/REPORT/SERVER]
--- UVM Report Summary ---
** Report counts by severity
UVM_INFO : 19
UVM_WARNING : 0
UVM_ERROR : 0
UVM_FATAL : 0
** Report counts by id
[RNTST] 1
[TAV_MON] 8
[TAV_UVMSV] 8
[TEST_DONE] 1
[UVM/RELNOTES] 1
Notice that every TAV_MON line appears twice: once from env.agt.mon and once from env.agt_passive.mon. The passive agent watched the same bus without driving it, which is exactly how you reuse a block-level agent at chip level.
The planted bug: sampling one clock early
With +BUG=1, the monitor reads rdata on the same clock as the read request, before the memory has updated it.
UVM_INFO @ 0: reporter [RNTST] Running test tav_uvmsv_test...
UVM_INFO testbench.sv(110) @ 15: uvm_test_top.env.agt.mon [TAV_MON] WR addr=10 data=a0
UVM_INFO testbench.sv(110) @ 15: uvm_test_top.env.agt_passive.mon [TAV_MON] WR addr=10 data=a0
UVM_INFO testbench.sv(110) @ 35: uvm_test_top.env.agt.mon [TAV_MON] WR addr=20 data=a1
UVM_INFO testbench.sv(110) @ 35: uvm_test_top.env.agt_passive.mon [TAV_MON] WR addr=20 data=a1
UVM_INFO testbench.sv(110) @ 55: uvm_test_top.env.agt.mon [TAV_MON] RD addr=10 data=00
UVM_INFO testbench.sv(151) @ 55: uvm_test_top.env.sb [TAV_SB] MISMATCH read 10: got 00, expected a0
UVM_INFO testbench.sv(110) @ 55: uvm_test_top.env.agt_passive.mon [TAV_MON] RD addr=10 data=00
UVM_INFO testbench.sv(110) @ 75: uvm_test_top.env.agt.mon [TAV_MON] RD addr=20 data=a0
UVM_INFO testbench.sv(151) @ 75: uvm_test_top.env.sb [TAV_SB] MISMATCH read 20: got a0, expected a1
UVM_INFO testbench.sv(110) @ 75: uvm_test_top.env.agt_passive.mon [TAV_MON] RD addr=20 data=a0
UVM_INFO /apps/vcsmx/vcs/X-2025.06-SP1//etc/uvm-1.2/src/base/uvm_objection.svh(1276) @ 100: reporter [TEST_DONE] 'run' phase is ready to proceed to the 'extract' phase
UVM_INFO testbench.sv(207) @ 100: uvm_test_top [TAV_UVMSV] PASS 1 phase order: build connect eoe run
UVM_INFO testbench.sv(207) @ 100: uvm_test_top [TAV_UVMSV] PASS 2 sequence length from config_db: 4
UVM_ERROR testbench.sv(211) @ 100: uvm_test_top [TAV_UVMSV] FAIL 3 scoreboard items / reads / mismatches: got 4 / 2 / 2, expected 4 / 2 / 0
UVM_INFO testbench.sv(207) @ 100: uvm_test_top [TAV_UVMSV] PASS 4 passive agent: driver / monitor: none / built
UVM_INFO testbench.sv(207) @ 100: uvm_test_top [TAV_UVMSV] PASS 5 factory: scoreboard type: tav_sb_verbose
UVM_INFO testbench.sv(207) @ 100: uvm_test_top [TAV_UVMSV] PASS 6 TAV_MON shown (2 monitors) / TAV_DBG (UVM_HIGH) shown: 8 / 0
UVM_INFO testbench.sv(207) @ 100: uvm_test_top [TAV_UVMSV] PASS 7 driver got its virtual interface: yes
UVM_INFO testbench.sv(230) @ 100: uvm_test_top [TAV_UVMSV] Checks: 6 pass, 1 fail
UVM_INFO /apps/vcsmx/vcs/X-2025.06-SP1//etc/uvm-1.2/src/base/uvm_report_server.svh(904) @ 100: reporter [UVM/REPORT/SERVER]
--- UVM Report Summary ---
** Report counts by severity
UVM_INFO : 20
UVM_WARNING : 0
UVM_ERROR : 1
UVM_FATAL : 0
** Report counts by id
[RNTST] 1
[TAV_MON] 8
[TAV_SB] 2
[TAV_UVMSV] 8
[TEST_DONE] 1
[UVM/RELNOTES] 1
The reads now appear at 55 and 75 ns instead of 65 and 85 ns, with stale data: 00, then a0 where a1 was expected. The scoreboard flagged both, and check 3 failed with 4 / 2 / 2.
The lesson: the scoreboard caught the bug without any change to the test or the sequence. Because each part has one job, a fix or a check in one place covers every test that uses it.
Two mistakes I made building this bench
The first VCS run failed 4 checks, and both causes are common:
- config_db scope: the test set
tav_numfor"*", which means “my children”, then tried to read it on itself. The read failed, the sequence ran 0 items, and the test ended at 20 ns. The fix: set it for"env.*"and read it in the sequence throughm_sequencer. - Padded strings:
(x == null) ? "none" : "built"inside$sformatf("%s")printed" none", because the two literals have different lengths and the shorter one is padded. Assigning the result to astringvariable first removes the padding.
When plain SystemVerilog is still fine
- A quick sanity check of a small block, as in the simple example.
- Formal properties and assertions, which do not need a class testbench at all.
- Learning the language itself before learning UVM.
Common mistakes to avoid
| Mistake | What you see | Fix |
|---|---|---|
config_db::set with a path that does not match the reader | The value is never found, defaults are used | Match the path to where get is called |
| Putting stimulus in the test or the driver | Every new test edits shared code | Put stimulus in sequences |
Building components with new() | Factory overrides do nothing | Use type_id::create() |
| A monitor that ignores the protocol’s latency | False mismatches (+BUG=1) | Sample when the data is valid |
| Using UVM for a five-minute sanity check | More setup than test | Plain SystemVerilog is fine for that |
How AI helps you master this
- Map your testbench: paste a plain SystemVerilog testbench and ask which parts would become a driver, a monitor and a sequence.
- Debug config_db: paste your
setandgetcalls and ask whether the paths match. - Plan reuse: describe a block-level env and ask what changes to use it passively at chip level.
Warning: a convincing AI answer is not the same as a correct engineering result. Both mistakes in the section above looked right on paper, so run the code.
Interview questions on UVM vs SystemVerilog
- Is UVM a language? No. It is a class library and methodology written in SystemVerilog.
- Why use UVM instead of plain SystemVerilog? A standard structure, reusable agents, sequences, config_db, the factory, phases and reporting.
- What is a passive agent? An agent with only a monitor, used to observe an interface without driving it.
- What does the factory let you do? Replace a class with a child class from the test, without editing the code that creates it.
- Where should stimulus live in UVM? In sequences, started on a sequencer.
More practice: UVM interview questions.
Practice challenge
- Run the simple example, then the UVM bench, and compare how much code changes to add a third read.
- Run the UVM bench with
+BUG=1and find the two mismatch lines. - Change the config_db value from 4 to 6. Which checks change?
- Bonus: run with
+UVM_VERBOSITY=UVM_HIGH. What does check 6 report now?
FAQ
Is UVM a language or a methodology? A methodology, delivered as a SystemVerilog class library.
Why use UVM instead of plain SystemVerilog? So testbenches share one structure, parts can be reused across tests and projects, and tests can change behaviour through config_db and the factory without editing the testbench.
Can I write a testbench without UVM? Yes, as the simple example shows. For larger projects, the lack of a shared structure gets expensive.
What is the UVM factory for? Creating objects by type so a test can swap in a child class, as check 5 does with the scoreboard.
What does uvm_config_db do? It stores settings, such as a virtual interface or a sequence length, that components below can look up by path.
Does UVM replace SystemVerilog? No. UVM is written in SystemVerilog and depends on it.
References
- IEEE 1800.2-2020, Universal Verification Methodology (UVM) standard.
- Accellera UVM 1.2 Class Reference:
uvm_agent,uvm_sequence,uvm_config_db,uvm_factoryanduvm_report_server.
Keep learning
- The parts in depth: virtual interface, uvm_config_db, the UVM factory and create() vs new().
- The order things happen in: UVM phasing.
- Interview prep: UVM interview questions.
Part of the learning path UVM methodology
