UVM Config DB

The uvm_config_db is a hierarchical configuration mechanism used to pass data between UVM components in a flexible and reusable way.

πŸ“˜ Overview

uvm_config_db allows higher-level components (like tests) to configure lower-level components (like agents, drivers, monitors).

  • Pass virtual interfaces
  • Configure agent active/passive mode
  • Share configuration objects
  • Avoid tight coupling between components

It is typically used during build_phase.

πŸš€ Why Config DB is Important
  • Enables reusable verification environments
  • Supports hierarchical configuration
  • Prevents hard-coded dependencies
  • Allows flexible test-level control
πŸ’» Basic Syntax
Set Configuration

uvm_config_db#(type)::set(
    parent,
    "instance_path",
    "field_name",
    value
);
Get Configuration

uvm_config_db#(type)::get(
    this,
    "",
    "field_name",
    variable
);
πŸ”Œ Example: Passing Virtual Interface

// In Test (top-level)
uvm_config_db#(virtual my_if)::set(
    this,
    "env.agent",
    "vif",
    vif_handle
);

// In Driver (build_phase)
if (!uvm_config_db#(virtual my_if)::get(
        this,
        "",
        "vif",
        vif
    )) begin
    `uvm_fatal("NOVIF", "Virtual interface not set")
end

The test sets the virtual interface, and the driver retrieves it during build_phase.

🎯 Example: Configuring Agent Mode

// In Test
uvm_config_db#(uvm_active_passive_enum)::set(
    this,
    "env.agent",
    "is_active",
    UVM_PASSIVE
);

This configures the agent to run in passive mode without modifying the agent code.

πŸ— Hierarchy Rules
  • Configuration is applied hierarchically.
  • Higher-level components configure lower-level ones.
  • Instance paths can use wildcards (*).
  • Search happens upward in hierarchy.
⚠ Common Mistakes
  • Calling get() in run_phase instead of build_phase
  • Incorrect instance path
  • Forgetting to check return value
  • Overusing wildcards
πŸ“Š Config DB vs Direct Assignment
Feature Config DB Direct Assignment
Reusability High Low
Hierarchy Support Yes No
Scalability Excellent Poor

Run These Examples on EDA Playground

Run the complete UVM Config DB Examples directly in your browser without installing tools.

β–Ά Open UVM Config DB Example 1

β–Ά Open UVM Config DB ExampleΒ 2