# How to convert code which use resurce\_db to config\_db

**URL:** <https://verificationacademy.com/forums/t/how-to-convert-code-which-use-resurce-db-to-config-db/32408>\
**Category:** UVM\
**Tags:** UVM, Resource\_db, config\_db\
**Created:** [October 9, 2016, 1:23pm UTC](https://verificationacademy.com/forums/t/how-to-convert-code-which-use-resurce-db-to-config-db/32408 "2016-10-09T13:23:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![saritr](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/df705f/32.png) [@saritr](https://verificationacademy.com/forums/u/saritr)\
**Post date:** [October 9, 2016, 1:23pm UTC](https://verificationacademy.com/forums/t/how-to-convert-code-which-use-resurce-db-to-config-db/32408/1 "2016-10-09T13:23:55Z")

</div>

In my tb\_top I declare the following instance and set to the resource\_db:

```verilog
   axi_interface vif(ACLK, ARESETn);

   uvm_resource_db#(virtual axi_interface)::set(.scope("ifs"), .name("axi_interface"), .val(vif));

```

In the driver class I declare the following virtual interface, and in the build phase I read it from the resource\_db by get:

```verilog
 virtual axi_interface vif;
 void'(uvm_resource_db#(virtual axi_interface)::read_by_name(.scope("ifs"), .name("axi_interface"), .val(vif)));

```

Since I have understood that its better to use config\_db than resource\_db I want to change the code.

So in the tb\_top I did

```verilog
uvm_config_db#(virtual axi_interface)::set(null, "uvm_test_top", "axi_interface",vif);

```

I’m not sure how to change the relevant code (read\_by\_name) of the driver.

---

<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:** [October 9, 2016, 1:48pm UTC](https://verificationacademy.com/forums/t/how-to-convert-code-which-use-resurce-db-to-config-db/32408/2 "2016-10-09T13:48:36Z")

</div>

_In reply to [saritr](https://verificationacademy.com/forums/t/how-to-convert-code-which-use-resurce-db-to-config-db/32408):_

The setting from the top\_tb is correct.  
Retrieving the the virtual interface in the agent looks like this:  
uvm\_config\_db#(virtual axi\_interface)::get(this, “”, .name(“axi\_interface”), .val(vif));  
this is indicating a relative path.  
The scope is the concatenation of this and “”.

---

<div class="post-metadata">

**Author:** ![saritr](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/s/df705f/32.png) [@saritr](https://verificationacademy.com/forums/u/saritr)\
**Post date:** [October 9, 2016, 1:59pm UTC](https://verificationacademy.com/forums/t/how-to-convert-code-which-use-resurce-db-to-config-db/32408/3 "2016-10-09T13:59:24Z")

</div>

_In reply to [chr\_sue](https://verificationacademy.com/forums/t/how-to-convert-code-which-use-resurce-db-to-config-db/32408/2):_

Why in the agent? Can I do it also from the driver right?

---

<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:** [October 9, 2016, 3:43pm UTC](https://verificationacademy.com/forums/t/how-to-convert-code-which-use-resurce-db-to-config-db/32408/4 "2016-10-09T15:43:10Z")

</div>

_In reply to [saritr](https://verificationacademy.com/forums/t/how-to-convert-code-which-use-resurce-db-to-config-db/32408/3):_

You can do this als in the driver. But in the agnet you might have a monitor which is connected to the virtual interface.
