Hardware interview practice
Pass a virtual interface through config_db
A top module owns bus_if bus(clk), while uvm_test_top.env.agent.drv needs a virtual handle named vif. Implement matching config_db set/get calls and fail clearly if lookup fails.
Starting point
Question code
top: bus_if bus(clk);
test: uvm_test_top.env.agent.drv
field name: vifReviewed example
Work through one case
Input
set(null, "uvm_test_top.env.agent.*", "vif", bus) and get(this, "", "vif", vif)Expected output
Driver receives the bus handleThe wildcard matches drv and both calls use the same virtual type and field name.
What to cover
Requirements
- From top before run-time stimulus, set virtual bus_if bus into uvm_config_db using field name vif for the driver path or a matching wildcard path.
- In the driver's build_phase, get virtual bus_if with the same type and field name into the member vif.
- Check the get return value and issue uvm_fatal if it is zero; never continue with a null virtual interface.
- Use a context and instance path that actually matches uvm_test_top.env.agent.drv.
