# Error in uvm\_config\_db

**URL:** <https://verificationacademy.com/forums/t/error-in-uvm-config-db/41808>\
**Category:** UVM\
**Tags:** System-verilog-interface, UVM\
**Created:** [June 12, 2023, 12:39pm UTC](https://verificationacademy.com/forums/t/error-in-uvm-config-db/41808 "2023-06-12T12:39:53Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![HoussamSABOUR](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/h/d6d6ee/32.png) [@HoussamSABOUR](https://verificationacademy.com/forums/u/HoussamSABOUR)\
**Post date:** [June 12, 2023, 12:39pm UTC](https://verificationacademy.com/forums/t/error-in-uvm-config-db/41808/1 "2023-06-12T12:39:53Z")

</div>

I want to create a generic part of uvm\_config\_db for 2 interfaces, slave and master for that i have :

tb.sv : first module which has specific interface and must be included in my top\_tb.sv (top\_level)  
but when i try to do this i have this error :  
(_vlog-2730) Undefined variable: ‘slave\_interface’__\*\*\*\*_.  
(_vlog-2730) Undefined variable: ‘master\_interface’__\*\*\*\*_.

this the part of code for this both :

**for tb.sv (part of uvm\_config\_db)**\_\_

```verilog
initial begin 
      uvm_config_db#(virtual apb_interface)::set(null, "*", "slave_interface", apb_s0);
      uvm_config_db#(virtual ahb_interface)::set(null, "*", "master_interface", ahb_m0);
end

```

**for top\_tb.sv** \_\_

```verilog
`include "tb.sv" 
module top_tb; 
  initial begin 
    $timeformat ( -6, 3, " us", 10);

    uvm_config_db#(type(slave_interface))::get(null, "", "slave_interface", slave_interface);
    uvm_config_db#(type(master_interface))::get(null, "", "master_interface", master_interface);

    uvm_config_db#(type(slave_interface))::set(null, "uvm_test_top.env.slave_agent*", "vif", slave_interface);
    uvm_config_db#(type(master_interface))::set(null, "uvm_test_top.env.master_agent*", "vif", master_interface);
    
    run_test() ;
  end     
endmodule : top_tb

```

Thanks,

---

<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:** [June 12, 2023, 2:01pm UTC](https://verificationacademy.com/forums/t/error-in-uvm-config-db/41808/2 "2023-06-12T14:01:18Z")

</div>

_In reply to [uvm\_share](https://verificationacademy.com/forums/t/error-in-uvm-config-db/41808):_

A few remarks:  
(1) in tb.sv we do not see the instances apb\_s0 and apb\_m0.Do they exist?  
(2) your slave\_interface is the sam interface as the master interface. This results from the setings in tb.sv  
(3) in top\_tb your settings are wrong. The first 2 uvm\_config\_db shoule be like this:

```verilog
uvm_config_db#(virtual apb_interface)::get(null, "", "slave_interface", slave_interface);
    uvm_config_db#(virtual apb_interface)::get(null, "", "master_interface", master_interface);

```

(4) in top\_tb you need also instances for the master and slave interface, respectively.  
(5) What is the objective of the uvm\_congig\_db set commands in top\_tb?

It is a little bit confusing what you are coding.  
Please explain in some more detail what your objective is.

---

<div class="post-metadata">

**Author:** ![HoussamSABOUR](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/h/d6d6ee/32.png) [@HoussamSABOUR](https://verificationacademy.com/forums/u/HoussamSABOUR)\
**Post date:** [June 12, 2023, 2:39pm UTC](https://verificationacademy.com/forums/t/error-in-uvm-config-db/41808/3 "2023-06-12T14:39:12Z")

</div>

Thank you for your answer so, my objectif is to make generic uvm\_config\_db , for this i instaciate it by master and slave interface.

1. i have the instance of apb\_s0 and ahb\_m0 in my tb.sv

2 ) i have apb as slave interface and ahb as master interface

1. i tried it but i have the same error

2. when i instanciate my master\_interface and slave\_interface i didn’t resolve the error

5 ) as I had a bridge-specific config\_db in tb.sv, and I want to make a generic part in top\_tb.sv

---

<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:** [June 12, 2023, 3:00pm UTC](https://verificationacademy.com/forums/t/error-in-uvm-config-db/41808/4 "2023-06-12T15:00:21Z")

</div>

_In reply to [uvm\_share](https://verificationacademy.com/forums/t/error-in-uvm-config-db/41808/3):_

Oh I have overseen the ahb and apb interface.  
But you need the interface declared when putting the interface through the config\_db.

---

<div class="post-metadata">

**Author:** ![HoussamSABOUR](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/h/d6d6ee/32.png) [@HoussamSABOUR](https://verificationacademy.com/forums/u/HoussamSABOUR)\
**Post date:** [June 12, 2023, 3:12pm UTC](https://verificationacademy.com/forums/t/error-in-uvm-config-db/41808/5 "2023-06-12T15:12:15Z")

</div>

_In reply to [chr\_sue](https://verificationacademy.com/forums/t/error-in-uvm-config-db/41808/4):_  
Yes, thats what i did, i intanciated like this in tb.sv:

```verilog
apb_interface slave_interface ; 
ahb_interface master_interface ;

```

---

<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:** [June 12, 2023, 4:39pm UTC](https://verificationacademy.com/forums/t/error-in-uvm-config-db/41808/6 "2023-06-12T16:39:54Z")

</div>

_In reply to [uvm\_share](https://verificationacademy.com/forums/t/error-in-uvm-config-db/41808/5):_

This declaration requires brackets like this

```verilog
apb_interface slave_interface(); 
ahb_interface master_interface();

```

---

<div class="post-metadata">

**Author:** ![chrisspear](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/chrisspear/32/2702_2.png) [@chrisspear](https://verificationacademy.com/forums/u/chrisspear)\
**Post date:** [June 12, 2023, 9:11pm UTC](https://verificationacademy.com/forums/t/error-in-uvm-config-db/41808/7 "2023-06-12T21:11:59Z")

</div>

_In reply to [uvm\_share](https://verificationacademy.com/forums/t/error-in-uvm-config-db/41808/6):_

So much missing code… Here is a complete working example.

```verilog
interface apb_interface;
  logic clk;
endinterface // apb

interface ahb_interface;
  logic clk;
endinterface // ahb

module tb;
  import uvm_pkg::*;
  apb_interface apb_s0();
  ahb_interface ahb_m0();

  initial begin 
    // ** Use scope of (null,"") to match the get() call
    uvm_config_db#(virtual apb_interface)::set(null, "", "slave_interface", apb_s0);
    uvm_config_db#(virtual ahb_interface)::set(null, "", "master_interface", ahb_m0);
  end
endmodule // tb

module top_tb;
  import uvm_pkg::*;
`include "uvm_macros.svh"

  virtual apb_interface slave_interface;
  virtual ahb_interface master_interface;
  
  initial begin 
    $timeformat ( -6, 3, " us", 10);
    
    uvm_config_db#(type(slave_interface))::get(null, "", "slave_interface", slave_interface);
    uvm_config_db#(type(master_interface))::get(null, "", "master_interface", master_interface);
    
    uvm_config_db#(type(slave_interface))::set(null, "uvm_test_top.env.slave_agent*", "vif", slave_interface);
    uvm_config_db#(type(master_interface))::set(null, "uvm_test_top.env.master_agent*", "vif", master_interface);
    
    run_test("no_test") ;
  end     

class no_test extends uvm_test;
  `uvm_component_utils(no_test)
  function new(string name, uvm_component parent);
    super.new(name, parent);
  endfunction

  task run_phase (uvm_phase phase );
    `uvm_info("HELLO", "WORLD", UVM_MEDIUM)
  endtask
endclass
endmodule  

```

---

<div class="post-metadata">

**Author:** ![HoussamSABOUR](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/h/d6d6ee/32.png) [@HoussamSABOUR](https://verificationacademy.com/forums/u/HoussamSABOUR)\
**Post date:** [June 13, 2023, 7:18am UTC](https://verificationacademy.com/forums/t/error-in-uvm-config-db/41808/8 "2023-06-13T07:18:07Z")

</div>

Yes, thank you for your all answers.

So when i try this code :

```verilog
module top_tb;
  import uvm_pkg::*;
`include "uvm_macros.svh"
 
  virtual apb_interface slave_interface;
  virtual ahb_interface master_interface;
 
  initial begin 
    $timeformat ( -6, 3, " us", 10);
 
    uvm_config_db#(type(slave_interface))::get(null, "", "slave_interface", slave_interface);
    uvm_config_db#(type(master_interface))::get(null, "", "master_interface", master_interface);
 
    uvm_config_db#(type(slave_interface))::set(null, "uvm_test_top.env.slave_agent*", "vif", slave_interface);
    uvm_config_db#(type(master_interface))::set(null, "uvm_test_top.env.master_agent*", "vif", master_interface);
 
    run_test("no_test") ;
  end

```

I have a error when i want to simulate like it doesn’t find the port to connect interface ahb and apb

---

<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:** [June 13, 2023, 8:15am UTC](https://verificationacademy.com/forums/t/error-in-uvm-config-db/41808/9 "2023-06-13T08:15:14Z")

</div>

_In reply to [uvm\_share](https://verificationacademy.com/forums/t/error-in-uvm-config-db/41808/8):_  
Which simulator you are using?  
The code works with VCS and Questa and fails with Xcelium and Riviera. Both simulators cannot deal with

```verilog
type(master_interface)

```

And I do not see what the benefit is of using

```verilog
type(master_interface)

```

instad of

```verilog
virtual ahb_interface

```

---

<div class="post-metadata">

**Author:** ![HoussamSABOUR](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/h/d6d6ee/32.png) [@HoussamSABOUR](https://verificationacademy.com/forums/u/HoussamSABOUR)\
**Post date:** [June 13, 2023, 8:48am UTC](https://verificationacademy.com/forums/t/error-in-uvm-config-db/41808/10 "2023-06-13T08:48:18Z")

</div>

Thanks for your interaction,

my final objective is to develop unified verif env , for this i need to have a stable part of uvmconfig\_db which muste be generic for each interface master and slave. that’s the reason why i declared both types : master and slave

For my simulator, I’m using Questa

---

<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:** [June 13, 2023, 9:28am UTC](https://verificationacademy.com/forums/t/error-in-uvm-config-db/41808/11 "2023-06-13T09:28:48Z")

</div>

_In reply to [uvm\_share](https://verificationacademy.com/forums/t/error-in-uvm-config-db/41808/10):_

But you cannot reach it. You have to declare the master/slave interfaces explicitely in your top\_tb.  
See here:

```verilog
module top_tb;
  import uvm_pkg::*;
`include "uvm_macros.svh"
 
  virtual apb_interface slave_interface;
  virtual ahb_interface master_interface;

```

And this is my example on Edaplayground:

> **[EDA Playground](https://www.edaplayground.com/x/HSpK)**
>
> Edit, save, simulate, synthesize SystemVerilog, Verilog, VHDL and other HDLs from your web browser.

---

<div class="post-metadata">

**Author:** ![HoussamSABOUR](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/h/d6d6ee/32.png) [@HoussamSABOUR](https://verificationacademy.com/forums/u/HoussamSABOUR)\
**Post date:** [June 13, 2023, 9:42am UTC](https://verificationacademy.com/forums/t/error-in-uvm-config-db/41808/12 "2023-06-13T09:42:45Z")

</div>

Thank you Sir, it is solved Now
