UVM testbenches
Go to Declaration, Find Usages and Rename understand the patterns UVM testbenches are built from:
| Pattern | Example | What works |
|---|---|---|
| Virtual interfaces | virtual my_if vif; … vif.req <= 1; |
The interface type, its signals through vif., clocking items through vif.cb. and modports |
| Configuration database | uvm_config_db#(virtual my_if)::get(this, "", "vif", vif) |
The interface in the type argument and the vif handle; the string key "vif" is left alone |
| Factory | my_agent::type_id::create("agt", this) |
The class name before ::type_id |
| Parameterized base classes | class my_driver extends uvm_driver #(my_item); |
The class in the type argument |
| Component hierarchy | agt.drv.vif = null; |
Each step of the member chain, across classes |
| Sequence items | rand bit [7:0] addr; with constraint c_addr { addr < 8'h10; } |
Fields in constraints and through handles (it.addr) |
| Phase methods | virtual function void build_phase(uvm_phase phase); |
Overrides in your classes; super.build_phase(phase) refers to the library method and is not changed |
| Clocking blocks and modports | clocking cb @(posedge clk); output req; endclocking |
The block (vif.cb), its items (vif.cb.req), default clocking cb;, modport mp(clocking cb) |
| Bind | bind dut chk u_chk(.clk(clk)); |
The target module; port expressions resolve in the target module; the bound instance inside the target module (u_chk.flag) and through its instances (u_dut.u_chk.flag) |

Try it
Section titled “Try it”- In the sample project, open
uvm/my_pkg.sv. In classmy_driver, renamevifinvirtual my_if vif;tom_vif(⇧F6 / Shift+F6, then Refactor). These change: the declaration,uvm_config_db#(virtual my_if)::get(this, "", "vif", m_vif),m_vif.req <= 1;,m_vif.data <= req.addr;andagt.drv.m_vif = null;in classmy_env. The string"vif"stays.uvm/tb_top.svis unchanged. Undo. - Rename the class
my_itemtobus_txn. The class, its end label,uvm_sequence #(bus_txn),uvm_driver #(bus_txn),bus_txn it;andbus_txn::type_id::create("it")change; the default argument"my_item"of the constructor stays. Undo. - Open
uvm/my_if.svand rename the interfacemy_iftobus_if. The end label,virtual bus_if vif;anduvm_config_db#(virtual bus_if)::getinuvm/my_pkg.sv, and the instancebus_if vif_inst(.clk(clk));anduvm_config_db#(virtual bus_if)::setinuvm/tb_top.svall change. Undo.