Is it possible to pass a dynamic array through uvm_config_db#(...)::set/get

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

In reply to MichaelP:

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
.

In reply to dave_59:

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():

    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:


   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

In reply to MichaelP:

  1. See this post 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.