RTL Studio Open IDE

2.2 · UVM CLASS

Virtual interface via uvm_config_db

Pass a virtual interface from tb_top to the driver through uvm_config_db.

Watch on YouTube

What you practice

Virtual interface via uvm_config_db (2.2). Pass a virtual interface from tb_top to the driver through uvm_config_db. It is in Virtual interface — Part 2 · Agent: Driver & Monitor of the UVM Masterclass. Connect software UVM components to hardware FIFO pins.

The UVM bench compiles in that same browser SystemVerilog simulator. You edit the test in the IDE, run Verilator, and read the log beside the waveform.

What you will learn

You will learn how to pass a virtual interface from the testbench top into UVM components using uvm_config_db, enabling the driver to access DUT pins without hardwiring connections.

Learning objectives

  • Understand the role of virtual interfaces in UVM verification environments.
  • Use uvm_config_db#(virtual interface)::set() to publish the interface globally.
  • Retrieve the virtual interface in a UVM component using uvm_config_db#(virtual interface)::get().
  • Connect class-based UVM components (e.g., driver) to hardware signals via the virtual interface.

Theory

In UVM, virtual interfaces allow class-based components to drive and sample hardware signals. Since classes cannot directly access module-level nets, a virtual interface (a handle to an interface instance) is passed from the testbench into UVM components.

uvm_config_db is a global, type-safe database used to share configuration objects—including virtual interfaces—between components. The typical pattern is:

  1. In tb_top: instantiate the interface and publish it with uvm_config_db::set().
  2. In UVM components (e.g., driver, monitor): retrieve it in build_phase with uvm_config_db::get().
OperationSyntaxPurpose
Setuvm_config_db#(virtual fifo_if)::set(null, "*", "vif", vif);Publish vif globally for any component
Getuvm_config_db#(virtual fifo_if)::get(this, "", "vif", vif);Retrieve vif in a component’s build_phase

The "*" wildcard in set() makes the interface available to all components; "" in get() means the current component’s full name path.

Practice

  1. Open RtlStudio and select this chapter (Examples / Lecture list).

Files appear automatically in Explore.

  1. Open student/tb/tb_top.sv in the editor.
  2. In student/tb/tb_top.sv, after vif instantiation (e.g., fifo_if vif(clk, rst_n, ...);), add: uvm_config_db#(virtual fifo_if)::set(null, "*", "vif", vif); before run_test();.
  3. Open student/env/fifo_driver.sv (or the driver file in the workspace).
  4. In its build_phase, add: if(!uvm_config_db#(virtual fifo_if)::get(this, "", "vif", vif)) uvm_error("NO_VIF", "Failed to get vif");.
  5. Run Simulation → Run and check the Log panel for INFO: messages.

Summary

You practiced connecting the UVM driver to the hardware interface by retrieving the virtual interface from uvm_config_db in build_phase. This enabled the driver to access FIFO signals such as clock, reset, and data lines directly through the interface. The key takeaway is that uvm_config_db provides a standardized, hierarchical mechanism for sharing virtual interfaces across UVM components. With this setup, the driver can now drive and sample signals as intended in the testbench environment.

Run it in the Verilog IDE

  1. Open the UVM workspace in the IDE. The DUT and the testbench compile together in the browser.
  2. Run the SystemVerilog simulation with Verilator and read the phase and scoreboard lines in the log.
  3. When the check is on pins rather than a print, open the VCD next to that log.
  4. Edit the sequence, driver, or scoreboard in the IDE and rerun. You stay in the same simulator.

The lesson is done when the simulation matches Virtual interface via uvm_config_db. Change the source, run the Verilog simulator again, and read the waveform without leaving the IDE. Simulation guide · Yosys guide.