Part 11 · Senior Prep · Intermediate
config_db Wiring Whiteboard Q&A
Model answers on uvm_config_db set/get paths, virtual interface push from top, cfg object distribution, and debug when get fails.
config_db path questions
Q: Whiteboard top module vif push + agent get
diagram
[INT][SENIOR][UVM] MODEL ANSWER
Q: vif config_db whiteboard?
A:
MECHANISM: Top: uvm_config_db#(virtual apb_if)::set(null, "*", "vif", apb_if0);
Agent build: get(this, "", "vif", vif) — fatal if fail.
MOTIVATION: Only elaboration-time top knows interface instances.
PITFALL: Typo in field name "vif" vs "apb_vif" — silent null at run_phase.
EXAMPLE: set before run_test(); get in agent build_phase before run_phase.systemverilog
// top.sv
module tb_top;
apb_if apb_if0(.pclk(clk), ...);
initial begin
uvm_config_db#(virtual apb_if)::set(null, "*", "vif", apb_if0);
run_test("apb_base_test");
end
endmodule
// agent build_phase
if (!uvm_config_db#(virtual apb_if)::get(this, "", "vif", vif))
`uvm_fatal("AGT", "virtual interface not set")Q: set(this, "env.agt", "cfg") vs set(null, "*") — when each?
diagram
[INT][SENIOR][UVM] MODEL ANSWER
Q: Scoped vs wildcard set?
A:
MECHANISM: Wildcard null,"*" for vif from top — one interface many agents.
Scoped set(this,"env*","cfg") from test — avoid collisions.
MOTIVATION: Wildcard cfg causes last-write-wins across unrelated agents.
PITFALL: set(null,"*","cfg",cfg) for two agents — both get same mutable object.
EXAMPLE: Test sets per-agent path: set(this,"env.axi_agt","cfg",axi_cfg).systemverilog
class base_test extends uvm_test;
function void build_phase(uvm_phase phase);
apb_cfg agt_cfg = apb_cfg::type_id::create("agt_cfg");
agt_cfg.is_active = UVM_ACTIVE;
uvm_config_db#(apb_cfg)::set(this, "env.agt", "cfg", agt_cfg);
env = apb_env::type_id::create("env", this);
endfunction
endclassKey takeaways
vif: set(null,"*") from top; get in agent build_phase.
cfg: scoped paths from test — clone per agent.
Fatal on vif get fail — catch wiring bugs early.
Common pitfalls
get path does not match set hierarchy string — most common debug.
Setting cfg after child built — get returns false, defaults used silently.
Debug and print
Q: get returns false — debug checklist?
diagram
[INT][SENIOR][UVM] MODEL ANSWER
Q: config_db get fail debug?
A:
STEPS: 1) uvm_config_db::dump(). 2) Compare set path vs get inst_name.
3) Check type parameter matches exactly. 4) Set before get phase.
MOTIVATION: Silent default after failed get — TB runs with null vif until hang.
PITFALL: Assuming wildcard set reached agent with wrong field name.
EXAMPLE: set "apb_vif" get "vif" — dump shows mismatch instantly.Q: Resources vs config_db — interview one-liner
diagram
[INT][SENIOR][UVM] MODEL ANSWER
Q: config_db vs uvm_resource_db?
A:
MECHANISM: config_db is scoped to component hierarchy with set/get audit trail;
resource_db is global name pool — less hierarchy discipline.
WHEN: config_db for vif, cfg, virtual sequencer handles; resources for rare global.
PITFALL: Mixing both for same field — debug nightmare.
EXAMPLE: Stick to config_db in interview whiteboard unless asked resources.bash
# enable config_db trace at sim launch
simv +UVM_CONFIG_DB_TRACE +UVM_TESTNAME=apb_base_test 2>&1 | tee cfg_trace.log
grep -E "set|get|vif" cfg_trace.log | head -30Q: Whiteboard test → env → agent config flow
diagram
[INT][SENIOR][UVM] whiteboard config flow
top: set(null, "*", "vif", if)
test: set(this, "env", "cfg", top_cfg)
env build: get cfg; set(this, "agt", "cfg", agt_cfg_clone)
agt build: get cfg; get vif
Draw 4 boxes with arrows — 90-second interview drillsystemverilog
// env distributes clone — whiteboard this function
function void apb_env::build_phase(uvm_phase phase);
apb_cfg agt_cfg;
super.build_phase(phase);
uvm_config_db#(apb_cfg)::get(this, "", "cfg", cfg);
agt_cfg = cfg.clone();
agt_cfg.is_active = UVM_ACTIVE;
uvm_config_db#(apb_cfg)::set(this, "agt", "cfg", agt_cfg);
agt = apb_agent::type_id::create("agt", this);
endfunctionKey takeaways
get fail debug: dump, path match, type match, phase order.
config_db for TB wiring — resource_db only when asked.
Draw test→env→agent cfg flow — high-frequency whiteboard.
Common pitfalls
Cloning cfg forgotten — agents share mutable state.
config_db set in connect_phase — too late for build_phase get.