# Is it possible to pass a dynamic array through uvm\_config\_db#(...)::set/get

**URL:** <https://verificationacademy.com/forums/t/is-it-possible-to-pass-a-dynamic-array-through-uvm-config-db-set-get/36898>\
**Category:** UVM\
**Tags:** UVM, uvm-uvm\_config\_db\
**Created:** [December 8, 2019, 7:08pm UTC](https://verificationacademy.com/forums/t/is-it-possible-to-pass-a-dynamic-array-through-uvm-config-db-set-get/36898 "2019-12-08T19:08:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MichaelP](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@MichaelP](https://verificationacademy.com/forums/u/MichaelP)\
**Post date:** [December 8, 2019, 7:08pm UTC](https://verificationacademy.com/forums/t/is-it-possible-to-pass-a-dynamic-array-through-uvm-config-db-set-get/36898/1 "2019-12-08T19:08:14Z")

</div>

Hi,

I looking for a syntax or code example which is passing a dynamic array/queue using the uvm\_config\_db.  
For example, in my “generator component”, I create different kinds of packets to be sent into my DUT.  
When one of the packets finished its pass in the DUT, I would like to add one of the output packet fields monitored (e.g. address set by the DUT) to an array. And use the uvm\_config\_db#(…)::set(…) to configure it in the DB.  
So later in the test, I can use the uvm\_config\_db#(…)::get(…), on this same array of addresses and use it in one of my later packets to read from this address.  
Of course, remove/pop it from the array/queue once the packet with this address randomized successfully, and update the uvm\_config\_db with updated array/queue items left.

Is it possible to pass as a type to uvm\_config\_db a dynamic array?  
If yes, can someone please present a working example?

Thanks in advance,  
Michael

---

<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:** [December 9, 2019, 7:04am UTC](https://verificationacademy.com/forums/t/is-it-possible-to-pass-a-dynamic-array-through-uvm-config-db-set-get/36898/2 "2019-12-09T07:04:55Z")

</div>

_In reply to [MichaelP](https://verificationacademy.com/forums/t/is-it-possible-to-pass-a-dynamic-array-through-uvm-config-db-set-get/36898):_

The uvm\_config\_db can pass any data type by value. Complex data type like unpacked arrays need **typedef** , so you would do   
uvm\_config\_db#(my\_type)::get(…);. But if you want to _share_ an array, you need to wrap the array in a class object, then you can use the uvm\_config\_db to share the handle to that object containing the array.

It seems you want to be pushing and popping address, so a queue would be a better array type, and the UVM already provides a queue wrapped in an object, called   
uvm\_queue.

---

<div class="post-metadata">

**Author:** ![MichaelP](https://verificationacademy.com/forums/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@MichaelP](https://verificationacademy.com/forums/u/MichaelP)\
**Post date:** [December 15, 2019, 5:16pm UTC](https://verificationacademy.com/forums/t/is-it-possible-to-pass-a-dynamic-array-through-uvm-config-db-set-get/36898/3 "2019-12-15T17:16:21Z")

</div>

_In reply to [dave\_59](https://verificationacademy.com/forums/t/is-it-possible-to-pass-a-dynamic-array-through-uvm-config-db-set-get/36898/2):_

Thank you very much Dave!!  
I have few questions regards the uvm\_queue.

1. I saw in different places over the internet that a uvm\_queue can be created either by new():

```verilog

    class costume_sb extends uvm_scoreboard;
        //.... 
        uvm_queue#(trans_t) txn_queue;
        //..
        function void build_phase(uvm_phase phase);
            super.build_phase(phase);
            txn_queue = new();
        endfuction
    endclass 
   

```

Or by using the create() method:

```verilog

   class env extends uvm_env;

      uvm_queue#(string) my_queue;
 
      function void build_phase(uvm_phase phase);
          my_queue = uvm_queue#(string)::type_id::create("my_queue");
      endfunction
 
   endclass
   

```

What is the difference between these 2 kinds of creation the uvm\_queue?

1. Regards the uvm\_queue methods described in the UVM documentation reference.  
There is one method called: get\_global\_queue()  
How is it used?  
Is there any good code example and explanation how to use it?

Thanks in advance,  
Michael

---

<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:** [December 15, 2019, 6:24pm UTC](https://verificationacademy.com/forums/t/is-it-possible-to-pass-a-dynamic-array-through-uvm-config-db-set-get/36898/4 "2019-12-15T18:24:26Z")

</div>

_In reply to [MichaelP](https://verificationacademy.com/forums/t/is-it-possible-to-pass-a-dynamic-array-through-uvm-config-db-set-get/36898/3):_

1. See [this post](https://verificationacademy.com/forums/uvm/new-vs-create#reply-65114) about new versus create. BTW, only the latest version of the UVM will let you call create() on a UVM base class. Previously, you could only call create() on user defined classes register with the fsctory.

2. I’d rather not explain things I think are unnecessary.
