Protected Course Page
Enter the password to view Day 26 of the UVM 30-Day plan.
Day 26: VIP Integration — Using Verification IP in Your UVM Environment
A 30-day SystemVerilog/UVM verification series. The first five weeks built a testbench by hand. The last week learns that most of it comes from a vendor.
Every team that verifies more than one DUT has learned the same lesson: do not write your own APB, AXI, PCIe, USB, DDR, or Ethernet agent. Buy one, or use the open-source one, and spend your time on the DUT instead. That is what VIP (Verification IP) is for.
Using a VIP is not as simple as "plug it in." It comes with a driver, a monitor, protocol assertions, coverage models, sequence libraries, a config object, and a vocabulary all its own. The skill is not writing it — the skill is integrating it without inheriting every quirk of the vendor's architecture.
1. What a VIP Provides
A typical protocol VIP ships with:
| Layer | What it provides |
|---|---|
| Agent | Driver, sequencer, monitor, ready to instantiate |
| Transaction | The bus item class with all protocol fields |
| Sequence library | Base sequences for common operations (single read, burst write, etc.) |
| Protocol assertions | SVA that check the bus handshake, ready to bind |
| Coverage | Protocol coverage that reports as part of the merge |
| Config object | Vendor-specific knobs: bus width, wait states, error injection |
| Adapter (optional) | A register adapter for RAL integration |
Your job is to instantiate the agent, connect it to your environment, and connect your sequences to it. Everything else is theirs.
2. Integrating the VIP Into Your Env
The env instantiates the VIP agent like any other agent. The differences are:
- The VIP likely has its own config object class. Use it as-is; do not wrap it unless you need to extend it.
- The VIP's analysis port may have a different type. That is fine — your scoreboard can accept the VIP's transaction type, or you can add an adapter.
- The VIP's sequencer may have a specific method to start sequences. Use the standard
seq.start(vip_sqr); it is auvm_sequencerunderneath.
class dut_env extends uvm_env;
`uvm_component_utils(dut_env)
// VIP-provided agent type (example name — real name depends on vendor)
vendor_apb_agent apb_agent_inst;
vendor_apb_agent_config apb_cfg;
// Your components
fifo_scoreboard sb;
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
// 1. Create the VIP config and set the virtual interface
apb_cfg = vendor_apb_agent_config::type_id::create("apb_cfg");
apb_cfg.vif = apb_vif;
apb_cfg.is_active = UVM_ACTIVE;
// Any other VIP-specific knobs
// 2. Place it in config_db at the agent's path
uvm_config_db#(vendor_apb_agent_config)::set(
this, "apb_agent_inst", "cfg", apb_cfg);
// 3. Create the agent
apb_agent_inst = vendor_apb_agent::type_id::create(
"apb_agent_inst", this);
// 4. Your own components
sb = fifo_scoreboard::type_id::create("sb", this);
endfunction
virtual function void connect_phase(uvm_phase phase);
super.connect_phase(phase);
// 5. Connect the VIP's analysis port to your scoreboard.
// The VIP's monitor publishes vendor_apb_item, not your own bus_item.
// Either your scoreboard accepts vendor_apb_item, or you add an adapter.
apb_agent_inst.monitor.analysis_port.connect(sb.apb_export);
endfunction
endclass
The four things to pay attention to:
- The config class name. Every VIP has one, and it is almost never
uvm_agent_config. Look at the VIP's documentation for the right class. - The port name. The VIP's monitor's analysis port may be called
analysis_port,ap, or something vendor-specific. Find the right name. - The transaction type. Your scoreboard's imports are parameterized on the VIP's item type. Use the VIP's type directly, or add an adapter.
- The active/passive control. VIPs usually support the same
get_is_active()model, but the config object field is vendor-specific.
3. Extending a VIP With the Factory
Every VIP component is created with type_id::create, so every VIP component can be overridden with the factory. That is how you extend a VIP without patching its source.
Example: the vendor's driver does not implement the timing mode you need. Subclass it, override the one method, and use set_type_override:
// Your subclass in your own package
class my_slow_apb_driver extends vendor_apb_driver;
`uvm_component_utils(my_slow_apb_driver)
virtual task drive_transfer(vendor_apb_item item);
// Extra wait states
repeat (3) @(posedge vif.pclk);
super.drive_transfer(item);
endtask
endclass
// In the test's build_phase, before creating the env:
vendor_apb_driver::type_id::set_type_override(
my_slow_apb_driver::get_type());
Now the VIP's agent creates your driver instead of the vendor's, without any patching. This is the same factory mechanism from Day 5, applied to a third-party library.
4. Extending With Callbacks
If the VIP exposes callback hooks, use them. Callbacks are almost always safer than subclassing because the VIP's authors have committed to keeping them stable across releases.
class my_apb_cb extends vendor_apb_callback;
`uvm_object_utils(my_apb_cb)
virtual task pre_drive(vendor_apb_item item);
if (item.addr inside {['h100:'h1FF]})
item.delay = 5; // add latency to this address range only
endtask
endclass
// Attach in the test:
my_apb_cb cb = my_apb_cb::type_id::create("cb");
uvm_callbacks#(vendor_apb_driver, vendor_apb_callback)::add(
env.apb_agent_inst.driver, cb);
The vendor's driver, unchanged, now has extra behaviour for a specific address range. This is the pattern Day 11 introduced, applied to a VIP.
5. Debugging a VIP Failure
A test fails. Is it the DUT, your testbench, or the VIP? Three questions, in order:
Question 1: Did the VIP's protocol assertions fire?
If the VIP's protocol assertions (which check the bus handshake) fire, either the DUT is violating the protocol or the VIP is configured wrong for the bus. This is the fastest way to know whether the problem is at the bus level.
Question 2: Did the VIP's monitor see the transactions you expected?
Add a scoreboard subscriber to the VIP's analysis port (or use UVM_HIGH verbosity). If the monitor did not see the transaction, the failure is upstream of your scoreboard — either the DUT did not respond or the VIP's monitor did not detect the response. If the monitor did see it, the failure is in your scoreboard's comparison.
Question 3: Is the VIP's config set as you intended?
Print the config object in build_phase. Most VIP failures are misconfiguration: wrong bus width, wrong active/passive, wrong timing mode, wrong endianness. The config is a data structure; print it and read it.
// In the test's build_phase:
`uvm_info("VIP_CFG", $sformatf("apb_cfg: active=%s, width=%0d, mode=%s",
apb_cfg.is_active.name(), apb_cfg.bus_width, apb_cfg.timing_mode),
UVM_LOW)
6. What Day 27 Will Add
Tomorrow begins the Capstone Project — Day 1 of 3. You will pick a small DUT (an APB UART, a GPIO controller, or a small FIFO with a register interface) and design the testbench architecture from scratch. Days 27–29 are the build; Day 30 is the review and wrap-up. The capstone is where everything from Days 1–26 has to work together.
7. Quiz
Ten questions on VIP integration, extension, and debugging.
Coming Up Next: Day 27 — Capstone Project (Day 1 of 3)
- DUT selection — APB UART, GPIO controller, or small FIFO with register interface.
- Testbench architecture — agents, env, scoreboard, coverage plan.
- Register model — the RAL block that matches the DUT's register map.
- Sequence design — the smoke test, the pattern test, the corner test.
Series: 30 days of SystemVerilog/UVM verification. Day 26's VIP integration.
No comments:
Post a Comment