Skip to question and answer

Hardware interview practice

Why UVM Uses SystemVerilog Virtual Interfaces

MediumVerification UtilitiesMultiple choice

Why is a virtual interface commonly placed into a class-based driver's configuration?

Question code
virtual bus_if.master vif;

Answer choices

  1. A. It copies all interface signals into class properties
  2. B. It creates a new interface instance for every transaction
  3. C. It converts 4-state interface signals to 2-state class variables
  4. D. It gives the class a handle to a particular interface instance without hard-coding hierarchy

Concise answer

The answer and the key reason

A virtual interface gives the class-based driver a typed reference to an already-elaborated interface instance. Supplying that reference through configuration avoids fixed hierarchical names and lets the same driver connect to different interfaces; the `.master` modport preserves its intended access directions.

Deeper explanation

Work through the implementation and tradeoffs

An HDL interface belongs to the static design hierarchy, whereas a verification class is created dynamically. The class therefore uses a virtual-interface variable as a reference to the existing interface rather than attempting to instantiate or copy it. Through that reference, driver methods can read clocking information and drive protocol signals.

The test or environment can place the desired handle in configuration before the driver builds, and the driver retrieves it without knowing the top-level instance path. That separation improves reuse across benches and agent instances. Typing the variable as `virtual bus_if.master` also limits access to the master-facing members and directions.

What to remember

  • References an existing interface
  • Configuration removes hierarchy coupling
  • Modport typing limits access

Practice the complete prompt

Explain it first, then compare the reviewed solution.

Open this exact question in the practice bank to attempt it, check your reasoning, and access the full member solution.Practice this question

Keep practicing

Verification UtilitiesSystemVerilog Interface Modports ExplainedVerification UtilitiesSystemVerilog Clocking Blocks ExplainedUVM ComponentsHow to Pass a Virtual Interface with uvm_config_db