# What is the difference between uvm\_config\_db and uvm\_resource\_db?

**URL:** <https://verificationacademy.com/forums/t/what-is-the-difference-between-uvm-config-db-and-uvm-resource-db/29373>\
**Category:** UVM\
**Tags:** UVM, uvm\_config\
**Created:** [April 18, 2014, 10:10am UTC](https://verificationacademy.com/forums/t/what-is-the-difference-between-uvm-config-db-and-uvm-resource-db/29373 "2014-04-18T10:10:43Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![rajasravan](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/r/2acd7d/32.png) [@rajasravan](https://verificationacademy.com/forums/u/rajasravan)\
**Post date:** [April 18, 2014, 10:10am UTC](https://verificationacademy.com/forums/t/what-is-the-difference-between-uvm-config-db-and-uvm-resource-db/29373/1 "2014-04-18T10:10:43Z")

</div>

Hi

I would like to know What is the difference between uvm\_config\_db and uvm\_resource\_db ?  
Please let me know the difference between the the two config\_db’s, when it can be used and how it is used with an example?  
I went through so many articles but it is vague and unclear.can some one point me with the expamples and usage ?

-Thanks,  
-Raja.

---

<div class="post-metadata">

**Author:** ![tfitz](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/tfitz/32/3025_2.png) [@tfitz](https://verificationacademy.com/forums/u/tfitz)\
**Post date:** [April 18, 2014, 12:59pm UTC](https://verificationacademy.com/forums/t/what-is-the-difference-between-uvm-config-db-and-uvm-resource-db/29373/2 "2014-04-18T12:59:05Z")

</div>

Don’t worry about the differences, and just use uvm\_config\_db.  
uvm\_config\_db is a convenience layer built on top of uvm\_resource\_db, but that convenience is very important. In particular, uvm\_resource\_db uses a “last write wins” approach. The uvm\_config\_db, on the other hand, looks at where things are in the hierarchy up through end\_of\_elaboration, so “parent wins.” Once you start start\_of\_simulation, the config\_db becomes “last write wins.”

---

<div class="post-metadata">

**Author:** ![rajasravan](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/r/2acd7d/32.png) [@rajasravan](https://verificationacademy.com/forums/u/rajasravan)\
**Post date:** [April 21, 2014, 4:17am UTC](https://verificationacademy.com/forums/t/what-is-the-difference-between-uvm-config-db-and-uvm-resource-db/29373/3 "2014-04-21T04:17:10Z")

</div>

_In reply to [tfitz](https://verificationacademy.com/forums/t/what-is-the-difference-between-uvm-config-db-and-uvm-resource-db/29373/2):_

Hi tfitz,

Thanks alot for the reply.

It would be really helpful if you can give explaination on this last write approach/last write wins.  
Please can you give with an exmaple if possible to see the difference.  
This would be really helpful.

-Thanks,  
-Sravan

---

<div class="post-metadata">

**Author:** ![rajasravan](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/r/2acd7d/32.png) [@rajasravan](https://verificationacademy.com/forums/u/rajasravan)\
**Post date:** [April 22, 2014, 7:49am UTC](https://verificationacademy.com/forums/t/what-is-the-difference-between-uvm-config-db-and-uvm-resource-db/29373/4 "2014-04-22T07:49:35Z")

</div>

_In reply to [rajasravan](https://verificationacademy.com/forums/t/what-is-the-difference-between-uvm-config-db-and-uvm-resource-db/29373/3):_

Can you please comment on this.

-Thanks,  
-Sravan.

---

<div class="post-metadata">

**Author:** ![tfitz](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/tfitz/32/3025_2.png) [@tfitz](https://verificationacademy.com/forums/u/tfitz)\
**Post date:** [April 22, 2014, 12:59pm UTC](https://verificationacademy.com/forums/t/what-is-the-difference-between-uvm-config-db-and-uvm-resource-db/29373/5 "2014-04-22T12:59:22Z")

</div>

_In reply to [rajasravan](https://verificationacademy.com/forums/t/what-is-the-difference-between-uvm-config-db-and-uvm-resource-db/29373/4):_

The build-time behavior of uvm\_config\_db is explained in the [Advanced UVM](https://verificationacademy.com/sessions/understanding-factory-and-configuration) video course. If a test and an env both set a config\_db value during build-time, the test’s value will be used because it is higher in the component hierarchy. This is what you would expect.  
However, using the uvm\_resource\_db, since build\_phase() is called top-down, the env’s build\_phase is called after the test’s, so the env value would overwrite the test value.  
Once start\_of\_simulation\_phase is reached, a write using either the config\_db or the resource\_db will overwrite whatever is currently in the database for that specific parameter. This is what we mean by “last write wins.”

---

<div class="post-metadata">

**Author:** ![rajasravan](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/r/2acd7d/32.png) [@rajasravan](https://verificationacademy.com/forums/u/rajasravan)\
**Post date:** [April 23, 2014, 9:52am UTC](https://verificationacademy.com/forums/t/what-is-the-difference-between-uvm-config-db-and-uvm-resource-db/29373/6 "2014-04-23T09:52:53Z")

</div>

_In reply to [tfitz](https://verificationacademy.com/forums/t/what-is-the-difference-between-uvm-config-db-and-uvm-resource-db/29373/5):_

Hi,

This is really helpful to my understading.And i can see the main difference betwee uvm\_config\_db and uvm\_resource\_db is **“When you want to share object and access it from different location without using the hierarchy you can use uvm\_resource\_db.” Can you comment on this?**

**uvm\_config\_db :: set function parameter**

static function void set( uvm\_component cntxt,  
string inst\_name,  
string field\_name,  
T value )

**uvm\_resource\_db :: set function parameter**

static function void set( input string scope,   
input string name,   
T val,   
input uvm\_object accessor = null )

There is no instance name in resource\_db.

-Thanks,  
-Sravan.

---

<div class="post-metadata">

**Author:** ![tfitz](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/tfitz/32/3025_2.png) [@tfitz](https://verificationacademy.com/forums/u/tfitz)\
**Post date:** [April 23, 2014, 1:00pm UTC](https://verificationacademy.com/forums/t/what-is-the-difference-between-uvm-config-db-and-uvm-resource-db/29373/7 "2014-04-23T13:00:53Z")

</div>

_In reply to [rajasravan](https://verificationacademy.com/forums/t/what-is-the-difference-between-uvm-config-db-and-uvm-resource-db/29373/6):_

Using the resource\_db requires that the scope (arbitrary string) for the set and get match. For trivial environments this isn’t difficult. However, for complex environments, including IP from different sources, it’s more difficult to manage. That, along with some other non-intuitive behaviors of the resource\_db is why you should always just use the config\_db.  
I have never written a testbench that required using the resource\_db and I suggest you do the same.  
Good luck,  
-Tom

---

<div class="post-metadata">

**Author:** ![rajasravan](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/r/2acd7d/32.png) [@rajasravan](https://verificationacademy.com/forums/u/rajasravan)\
**Post date:** [April 24, 2014, 8:49am UTC](https://verificationacademy.com/forums/t/what-is-the-difference-between-uvm-config-db-and-uvm-resource-db/29373/8 "2014-04-24T08:49:39Z")

</div>

_In reply to [tfitz](https://verificationacademy.com/forums/t/what-is-the-difference-between-uvm-config-db-and-uvm-resource-db/29373/7):_

Thanks alot Tom.For the valuable & informative reply.

-Thanks,  
-Sravan.

---

<div class="post-metadata">

**Author:** ![Sagar\_Shah](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/sagar_shah/32/1963_2.png) [@Sagar\_Shah](https://verificationacademy.com/forums/u/Sagar_Shah)\
**Post date:** [May 1, 2016, 12:03pm UTC](https://verificationacademy.com/forums/t/what-is-the-difference-between-uvm-config-db-and-uvm-resource-db/29373/9 "2016-05-01T12:03:45Z")

</div>

_In reply to [tfitz](https://verificationacademy.com/forums/t/what-is-the-difference-between-uvm-config-db-and-uvm-resource-db/29373/8):_

Hi Tom,  
I tried one example with uvm\_resource\_db.  
But it is not working as you explained for uvm\_resource\_db during build\_phase.  
In uvm\_resource\_db also top hierarchy win during build\_phase.

```verilog
class my_agent extends uvm_agent;
  `uvm_component_utils (my_agent)
  int var1;
  function new (string name = "my_agent", uvm_component parent = null);
   super.new(name, parent);
  endfunction
  function void build_phase (uvm_phase phase);
    super.build_phase (phase);
    if(!uvm_resource_db #(int)::read_by_name("", "var1", var1, this))
      `uvm_error ("GET-FAIL", "not able to get value")
    else 
      `uvm_info ("GET-PASS", $sformatf("var1=%0d", var1), UVM_NONE)
  endfunction
endclass

/////////////////
class my_env extends uvm_env;
  `uvm_component_utils (my_env)
  int var1;
  my_agent agnt;
  function new (string name = "my_env", uvm_component parent = null);
    super.new(name, parent);
  endfunction
  function void build_phase (uvm_phase phase);
    super.build_phase (phase);
    agnt = my_agent::type_id::create("angt", this);
    var1 = 60;
    uvm_resource_db #(int)::set("*", "var1", var1, this);
    `uvm_info ("SET", $sformatf("From ENV=%0d", var1), UVM_NONE)
  endfunction
endclass

/////////////////
class my_test extends uvm_test;
  `uvm_component_utils (my_test)
  int var1;
  my_env env;
  function new (string name = "my_test", uvm_component parent = null);
    super.new(name, parent);
  endfunction
  function void build_phase (uvm_phase phase);
    super.build_phase (phase);
    env = my_env::type_id::create("env", this);
    var1 = 70;
    uvm_resource_db #(int)::set("*", "var1", var1, this);
    `uvm_info ("SET", $sformatf("From TEST=%0d", var1), UVM_NONE) 
  endfunction
  task run_phase (uvm_phase phase);
    phase.raise_objection(this);
    #500;
    phase.drop_objection(this);
  endtask
endclass

///////////////
module top();
  initial begin
    run_test("my_test");
  end
endmodule

//Output:
//UVM_INFO @ 0: reporter [RNTST] Running test my_test...
//UVM_INFO testbench.sv(15) @ 0: uvm_test_top [SET] From TEST=70
//UVM_INFO design.sv(36) @ 0: uvm_test_top.env [SET] From ENV=60
//UVM_INFO design.sv(14) @ 0: uvm_test_top.env.angt [GET-PASS] var1=70
//UVM_INFO /apps/vcsmx/etc/uvm-1.1/src/base/uvm_objection.svh(1267) @ 500: reporter [TEST_DONE] 'run' phase is ready to proceed to the 'extract' phase

```

Here I set value 70 from test, 60 from env, and getting value 70 in agent instead of 60.  
Can you please explain what is wrong I am doing here?

---

<div class="post-metadata">

**Author:** ![dhserfer](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/d/a9a28c/32.png) [@dhserfer](https://verificationacademy.com/forums/u/dhserfer)\
**Post date:** [May 2, 2016, 12:13am UTC](https://verificationacademy.com/forums/t/what-is-the-difference-between-uvm-config-db-and-uvm-resource-db/29373/10 "2016-05-02T00:13:11Z")

</div>

_In reply to [Sagar Shah](https://verificationacademy.com/forums/t/what-is-the-difference-between-uvm-config-db-and-uvm-resource-db/29373/9):_

Your code appears to be working correctly. ‘my\_test’ is above ‘my\_env’. Also, his suggestion was to NOT use the resource\_db.

From the file resource.svh:

// Multiple resources that have the same name are stored in a queue.  
// Each resource is pushed into a queue with the first one at the front  
// of the queue and each subsequent one behind it. The same happens for  
// multiple resources that have the same type. The resource queues are  
// searched front to back, so those placed earlier in the queue have  
// precedence over those placed later.

---

<div class="post-metadata">

**Author:** ![chr\_sue](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/chr_sue/32/1199_2.png) [@chr\_sue](https://verificationacademy.com/forums/u/chr_sue)\
**Post date:** [May 2, 2016, 6:23am UTC](https://verificationacademy.com/forums/t/what-is-the-difference-between-uvm-config-db-and-uvm-resource-db/29373/11 "2016-05-02T06:23:36Z")

</div>

_In reply to [dhserfer](https://verificationacademy.com/forums/t/what-is-the-difference-between-uvm-config-db-and-uvm-resource-db/29373/10):_

The configuration database is implemented on top of the resource database. The resource database  
is a pool of name-value pairs each associated with a scope string.  
The configuration database associates this scope string with full hierarchical names in the component hierarchy such that entriesin the configuration database, but not the resource database, are tied to the component hierarchy.

---

<div class="post-metadata">

**Author:** ![dhserfer](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/d/a9a28c/32.png) [@dhserfer](https://verificationacademy.com/forums/u/dhserfer)\
**Post date:** [May 2, 2016, 11:10am UTC](https://verificationacademy.com/forums/t/what-is-the-difference-between-uvm-config-db-and-uvm-resource-db/29373/12 "2016-05-02T11:10:10Z")

</div>

_In reply to [chr\_sue](https://verificationacademy.com/forums/t/what-is-the-difference-between-uvm-config-db-and-uvm-resource-db/29373/11):_

For the code that is provided, each of the uvm\_resource\_db::set functions are identical and performed in the build phases of the my\_test and my\_env components. If the ‘names’ are the same, don’t they utilize the same queue (and my\_test build\_phase ‘sets’ the head of the queue)?

---

<div class="post-metadata">

**Author:** ![chr\_sue](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/chr_sue/32/1199_2.png) [@chr\_sue](https://verificationacademy.com/forums/u/chr_sue)\
**Post date:** [May 2, 2016, 11:39am UTC](https://verificationacademy.com/forums/t/what-is-the-difference-between-uvm-config-db-and-uvm-resource-db/29373/13 "2016-05-02T11:39:10Z")

</div>

_In reply to [dhserfer](https://verificationacademy.com/forums/t/what-is-the-difference-between-uvm-config-db-and-uvm-resource-db/29373/12):_

The resource\_db commands have only two lookup arguments, the scope and the name. Both are strings.  
The accessor, last argument, is used only for auditting. You do not have to provide an actual argument, because it has a default value.  
The config\_db commands have 3 lookup arguments, the contxt, the scope and the name. The contxt is not a simple string, it is of type uvm\_component. The cntxt and name argument give you more flexibility when defining what you want to set or get. Typical arguments for the contxt are ‘this’, indicating the lookup-path is a relative path from the component where the command was issued and ‘null’ indicating there is nothing above, meaning an absolute path.

---

<div class="post-metadata">

**Author:** ![peter1](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/peter1/32/1304_2.png) [@peter1](https://verificationacademy.com/forums/u/peter1)\
**Post date:** [September 12, 2018, 11:56pm UTC](https://verificationacademy.com/forums/t/what-is-the-difference-between-uvm-config-db-and-uvm-resource-db/29373/14 "2018-09-12T23:56:56Z")

</div>

_In reply to [chr\_sue](https://verificationacademy.com/forums/t/what-is-the-difference-between-uvm-config-db-and-uvm-resource-db/29373/13):_

Hi chr, what it the meaning of the scope in resouce\_db?  
why do we need the scope?  
Thanks!

---

<div class="post-metadata">

**Author:** ![skumarts](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/3e96dc/32.png) [@skumarts](https://verificationacademy.com/forums/u/skumarts)\
**Post date:** [July 23, 2024, 7:43am UTC](https://verificationacademy.com/forums/t/what-is-the-difference-between-uvm-config-db-and-uvm-resource-db/29373/15 "2024-07-23T07:43:55Z")

</div>

@tfitz  
I am facing a similar Problem in my environment what is being discussed here, but i am not able to understand this behavior.

I am setting a object in the base\_test.sv in the build\_phase using  
uvm\_resource\_db::set

uvm\_resource\_db #(uvm\_object)::set(scope, “my\_agent”, my\_agent, this);

in my extended base\_test my\_base\_test extends base\_test.sv  
i am setting the same instance name in the build\_phase.  
uvm\_config\_db #(uvm\_object)::set(this, “my\_env”, “my\_agent”, this.new\_agent);

it is never taking the instance new\_agent which i am setting from the my\_base\_test.sv in build phase.

i also tried to do this in the start\_of\_simulation phase in my\_base\_test.sv

// func: start\_of\_simulation\_phase  
virtual function void start\_of\_simulation\_phase(uvm\_phase phase);  
super.start\_of\_simulation\_phase(phase);  
`uvm\_info(“mai\_base\_test”, “Setting arf\_agent config from start\_of\_simulation”, UVM\_NONE);  
uvm\_config\_db #(uvm\_object)::set(this, “my\_env”, “arf\_agent”, this.new\_agent);  
endfunction : start\_of\_simulation\_phase

its not picking new\_agent still,

uvm\_resource\_db setting in base\_test is overriding all other settings , even last write is not taking affect here.  
The way only i got this working was using uvm\_config\_db::set in the base\_test.sv but this base\_test.sv is not managed be my, i am trying just to re-use form other tb.  
it seems that if someone is using a uvm\_resource\_db setting in the base\_test.sv,  
we are not able to override this in the extended my\_base\_test.sv

i didn’t find any description related resolving multiple uvm\_resource\_db setting or uvm\_config\_db setting.  
Thanks for your Help

---

<div class="post-metadata">

**Author:** ![chr\_sue](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/chr_sue/32/1199_2.png) [@chr\_sue](https://verificationacademy.com/forums/u/chr_sue)\
**Post date:** [July 23, 2024, 9:18am UTC](https://verificationacademy.com/forums/t/what-is-the-difference-between-uvm-config-db-and-uvm-resource-db/29373/16 "2024-07-23T09:18:10Z")

</div>

I’m trying to understand why you are passing uvm\_components through your UVM testbench. It does not make really sense in my eyes. uvm\_componets will be created at runtime 0. Then they exist until the end of the simulation. In your uvm\_config\_db calls you are using as type uvm\_object, which is not correct. It should be uvm\_component. You should clean-up your code and restart again .

---

<div class="post-metadata">

**Author:** ![skumarts](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/3e96dc/32.png) [@skumarts](https://verificationacademy.com/forums/u/skumarts)\
**Post date:** [July 23, 2024, 10:45am UTC](https://verificationacademy.com/forums/t/what-is-the-difference-between-uvm-config-db-and-uvm-resource-db/29373/17 "2024-07-23T10:45:44Z")

</div>

my\_agent is a class, and class get created only when we create them, so they are objects, if i Replace uvm\_config\_db #(uvm\_object):: with uvm\_config\_db #(uvm\_Component)::  
Nothing is getting passed to the Destination get function, its a nul\_object.

---

<div class="post-metadata">

**Author:** ![chr\_sue](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/chr_sue/32/1199_2.png) [@chr\_sue](https://verificationacademy.com/forums/u/chr_sue)\
**Post date:** [July 23, 2024, 11:22am UTC](https://verificationacademy.com/forums/t/what-is-the-difference-between-uvm-config-db-and-uvm-resource-db/29373/18 "2024-07-23T11:22:11Z")

</div>

All classes belonging to the testbench topology are bsased on uvm\_components. They will be created during buil\_phase automatically. They are dynamic but not transient objects. All extensions from uvm\_object are transient objects. They are created at any time and will disappear after they are processed/finished.

---

<div class="post-metadata">

**Author:** ![rawrakesh](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/r/c77e96/32.png) [@rawrakesh](https://verificationacademy.com/forums/u/rawrakesh)\
**Post date:** [April 24, 2025, 9:37pm UTC](https://verificationacademy.com/forums/t/what-is-the-difference-between-uvm-config-db-and-uvm-resource-db/29373/19 "2025-04-24T21:37:15Z")

</div>

This article can help: [Difference between uvm\_config\_db and uvm\_resource\_db? - THETECHIEBLOG](https://www.thetechieblog.com/uvm/difference-between-uvm_config_db-and-uvm_resource_db/)

---

<div class="post-metadata">

**Author:** ![Amoch](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/a/df705f/32.png) [@Amoch](https://verificationacademy.com/forums/u/Amoch)\
**Post date:** [April 28, 2025, 4:47pm UTC](https://verificationacademy.com/forums/t/what-is-the-difference-between-uvm-config-db-and-uvm-resource-db/29373/20 "2025-04-28T16:47:20Z")

</div>

I find the resource db very handy if I want to pass something to a sequence.

Or you can do the normal “to sequence” UVM gymnastics and go through a component with the config\_db to a UVM component with hierarchy.

[Next page](https://verificationacademy.com/forums/t/what-is-the-difference-between-uvm-config-db-and-uvm-resource-db/29373.md?page=2)
