# Config\_db dynamic connection

**URL:** <https://verificationacademy.com/forums/t/config-db-dynamic-connection/35044>\
**Category:** UVM\
**Tags:** UVM, config\_db\
**Created:** [September 17, 2018, 5:24am UTC](https://verificationacademy.com/forums/t/config-db-dynamic-connection/35044 "2018-09-17T05:24:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rohitkumar.b](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/r/b5ac83/32.png) [@rohitkumar.b](https://verificationacademy.com/forums/u/rohitkumar.b)\
**Post date:** [September 17, 2018, 5:24am UTC](https://verificationacademy.com/forums/t/config-db-dynamic-connection/35044/1 "2018-09-17T05:24:09Z")

</div>

I wanted to make dynamic connection with the desired discrete input/output. In the below line,input SCAN\_ENABLE is connected with env[1], with the usage of same line I want to connect this input with env[2],env[3].etc so that I didn’t have to repeat this line again and again.

uvm\_config\_db #(virtual input\_if)::set(null,“uvm\_test\_top.top\_env.env[1]”,“pcm\_if\_SCAN\_ENABLE”,PCM\_top.DUT1.pcmif\_1\_SCAN\_ENABLE);

What’s your view on this.  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [September 17, 2018, 4:13pm UTC](https://verificationacademy.com/forums/t/config-db-dynamic-connection/35044/2 "2018-09-17T16:13:03Z")

</div>

_In reply to [rohitkumar.b](https://verificationacademy.com/forums/t/config-db-dynamic-connection/35044):_

```verilog
for(int ii=1;ii<N;ii++)
  uvm_config_db #(virtual input_if)::set(null,$sformatf("uvm_test_top.top_env.env[%0d]",ii),"pcm_if_SCAN_ENABLE",PCM_top.DUT1.pcmif_1_SCAN_ENABLE);

```

---

<div class="post-metadata">

**Author:** ![rohitkumar.b](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/r/b5ac83/32.png) [@rohitkumar.b](https://verificationacademy.com/forums/u/rohitkumar.b)\
**Post date:** [September 18, 2018, 5:11am UTC](https://verificationacademy.com/forums/t/config-db-dynamic-connection/35044/3 "2018-09-18T05:11:42Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/config-db-dynamic-connection/35044/2):_  
Thanks Dave, I also want to change DUT values with respect to env[\*] value, so that connection should be according to the different DUTs.

and how can I set these input/outputs simultaneously for different DUTs before run time.

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [September 18, 2018, 6:27am UTC](https://verificationacademy.com/forums/t/config-db-dynamic-connection/35044/4 "2018-09-18T06:27:34Z")

</div>

_In reply to [rohitkumar.b](https://verificationacademy.com/forums/t/config-db-dynamic-connection/35044/3):_

I knew that was going to be your next question. SystemVerilog identifiers are not dynamically constructed strings. They must be resolved as you compile the source code. You could create a text macro to help you, but you still would need to repeat the line.

```verilog
`define config_vif(N) \
uvm_config_db #(virtual input_if)::set(null,`"uvm_test_top.top_env.env[``N``]`","pcm_if_SCAN_ENABLE",PCM_top.DUT1.pcmif_``N``_SCAN_ENABLE);

`config_vif(1)
`config_vif(2)
`config_vif(3)
`config_vif(4)

```

---

<div class="post-metadata">

**Author:** ![rohitkumar.b](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/r/b5ac83/32.png) [@rohitkumar.b](https://verificationacademy.com/forums/u/rohitkumar.b)\
**Post date:** [September 18, 2018, 10:15am UTC](https://verificationacademy.com/forums/t/config-db-dynamic-connection/35044/5 "2018-09-18T10:15:06Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/config-db-dynamic-connection/35044/4):_

Can I use this syntax inside a for loop ??

---

<div class="post-metadata">

**Author:** ![dave\_59](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/dave_59/32/4499_2.png) [@dave\_59](https://verificationacademy.com/forums/u/dave_59)\
**Post date:** [September 18, 2018, 3:46pm UTC](https://verificationacademy.com/forums/t/config-db-dynamic-connection/35044/6 "2018-09-18T15:46:20Z")

</div>

_In reply to [rohitkumar.b](https://verificationacademy.com/forums/t/config-db-dynamic-connection/35044/5):_

No. Compiler macros get expanded before parsing any SystemVerilog syntax.  
When you put a number in an identifier, you might as well use apple, orange, fig.
