UVM Resource DB & The Pool

The engine under the hood. While uvm_config_db is the user-friendly interface, uvm_resource_db is where the data actually lives.

Concept: The Global Warehouse

Think of uvm_resource_db as a massive, global warehouse (singleton) where everything can be stored and retrieved by any component, anywhere in the testbench hierarchy.

Resource DB vs Config DB

uvm_config_db is actually a wrapper class that extends uvm_resource_db. It adds the concept of "Hierarchy" (paths and wildcards).

uvm_resource_db is purely name-based (and type-based). It doesn't care about the component hierarchy as much as the "scope string" you manually provide.

How to Use uvm_resource_db

1. Setting a Resource (Write)

Unlike config_db, we often define a "scope" string manually. This is less restrictive than cntxt.

// Using uvm_resource_db
// Arg 1: Scope (Regular Expression allowed)
// Arg 2: Name/Label
// Arg 3: Value
uvm_resource_db#(int)::set("env.agent*", "num_packets", 50, this);

2. Getting a Resource (Read)

if(!uvm_resource_db#(int)::read_by_name("env.agent.driver", "num_packets", val, this))
    `uvm_error("NO_RSRC", "Resource not found")
else
    `uvm_info("RSRC", $sformatf("Got %0d", val), UVM_LOW)

UVM Pool (uvm_pool)

At the very bottom, resources are stored in a uvm_pool, which is essentially an associative array (map). You can specifically use uvm_pool classes to create your own global dictionaries.

class my_scoreboard extends uvm_scoreboard;
    // A global pool of integers, indexed by string names
    uvm_pool#(int) my_global_counters;
    function new(string name, uvm_component parent);
        super.new(name, parent);
        // Get the singleton instance
        my_global_counters = uvm_pool#(int)::get_global_pool();
    endfunction
    task run_phase(uvm_phase phase);
        // Share data globally without config_db overhead
        my_global_counters.add("packets_processed", 0);
    endtask
endclass
Use Config DB mostly!
In professional testbenches, stick to uvm_config_db for 99% of tasks. It handles the complexity of "who wins" (precedence) when multiple settings apply to the same component. Use uvm_resource_db only when you need very specific low-level control or global sharing ignoring hierarchy.