Module 7 — Interfaces
Bundling related signals into a single reusable unit: the interface construct, modports for directional views, clocking blocks for race-free synchronous sampling, and the virtual interface that lets classes reach into the physical DUT connection.
📑 Table of Contents
56Interface
An interface bundles a group of related signals (and optionally tasks/functions, parameters) into a single named entity, connected via a single port instead of dozens of individual wires — dramatically simplifying module instantiation and reducing connection errors.
Interfaces are the standard way to model DUT-facing buses (AXI, APB, AHB, custom protocols) in a modern testbench — the same interface instance is shared between the DUT and the testbench's driver/monitor, guaranteeing both sides always agree on signal names and widths.
57Modports
A modport defines a restricted, directional "view" of an interface's signals from the perspective of one connected module — enforcing that a master only drives outputs it should drive, and a slave only drives its own outputs.
Attempting to drive a signal that's an input in the connected modport is a compile-time error — modports catch directional wiring mistakes early, before they become hard-to-debug multi-driver contention or X-propagation bugs at simulation time.
58Clocking Blocks
A clocking block defines race-free, synchronized sampling and driving of interface signals relative to a clock edge — inputs are sampled slightly before the edge, outputs are driven slightly after, eliminating testbench-vs-RTL race conditions.
Without a clocking block, a testbench driving a signal with a plain non-blocking assignment right at posedge clk races against the DUT's own flops sampling on the same edge — the order of evaluation between testbench and DUT is technically non-deterministic across simulators. The clocking block's built-in input/output skew removes this ambiguity entirely.
59Virtual Interface
A virtual interface is a handle (pointer-like reference) to a physical interface instance — it's what lets class-based testbench code (drivers, monitors, which live outside the static module hierarchy) reach in and drive/sample real DUT signals.
If a virtual interface handle is used before it's assigned (i.e. still null) — commonly because the assignment via uvm_config_db or a direct constructor argument was forgotten — accessing any signal through it causes a null-pointer-style runtime error. "Why does my UVM testbench fail with a 'virtual interface not set' error?" is one of the most frequently debugged UVM issues, and it's exactly this: the physical interface handle was never connected to the class-side virtual interface reference.
🎯 Module 7 Recap
interfacebundles related signals into one reusable, single-port entity, eliminating messy long port lists.modportgives each connected module a restricted, directional view — driving a modport's input signal is a compile-time error.clockingblocks add sample/drive timing skew relative to a clock edge, eliminating testbench-vs-DUT race conditions.virtual interfaceis the bridge that lets dynamic, class-based testbench code (which lives outside the static module hierarchy) reach and control a real, physical interface instance.- An unassigned (null) virtual interface handle is one of the most common real-world UVM runtime errors.
📚 Next up — Module 8: UVM Basics (why UVM, architecture, uvm_object/uvm_component, factory, config_db, TLM, sequences, drivers, monitors, agents, environment, scoreboard, test, and phases)
↑ Back to Table of Contents
Comments
Post a Comment