UVM QUEUE CLASS

Can somebody guide me how to share the queue between two components using uvm_queue class with example.
Eg :) I have populated the queue at monitor side i need to share it with predictor how can i do that .
Please share the response.
Thanks in advance.

In reply to Mechanic:

You can read here more about it:
https://www.chipverify.com/blog/about-the-uvm-queue-class

In reply to chr_sue:

Hi chr_sue,

Thanks for the guidance. i have read the blog and tried from my end.
But if i use uvm_queue at monitor side to populate i am able to do that and get it in pre.
here is the code link:

Please guide me .

Thanks in advance

In reply to Mechanic:

Can somebody guide me how to share the queue between two components using uvm_queue class with example.
Eg :) I have populated the queue at monitor side i need to share it with predictor how can i do that .
Please share the response.
Thanks in advance.

If you want to share uvm_queue between components, you can easily create a global pool wrapper a queue. From a pool, you can get the queue from specific key string.
Here is an example:

  • Create the pool with key is string for uvm_queue, type of queue element is int. The uvm_object_string_pool is supported by UVM.

typedef uvm_object_string_pool #(uvm_queue#(int)) uvm_queue_pool;

  • From a component, you get the uvm_queue from pool from a specific key string, push any value to a queue.

uvm_queue#(int) queue = uvm_queue_pool::get_global("queue_key");
queue.push_back(100);

  • From another component, you can get the same uvm_queue for the same key string, wait and pop the value to use.

int value;
uvm_queue#(int) queue = uvm_queue_pool::get_global("queue_key");
wait(queue.size() > 0);
value = queue.pop_front();

In reply to cuonghle:

Thanks for the example .
One clarification can we use two queues of same element type “int”? is it possible.
what would be the queue_key in that case?

please check the code in the below link :

please share your response

In reply to Mechanic:

In reply to cuonghle:
Thanks for the example .
One clarification can we use two queues of same element type “int”? is it possible.
what would be the queue_key in that case?
please share your response

If you have 2 queues which are the same type “int”, you can provide different key strings to get different queues. Key strings can be any value but need to be unique.

If you have 2 queues which are different type, you need to declare different pools using typedef that I showed in previous post.

In reply to cuonghle:

Keys are used together with uvm_pool which represents an assiciative arry´ay. This is different to a queue.
Please find below a link for an uvm_queue example. This does not work for 2 queues of the same type. BTW this example is nott running on VCS. Seems to be a weakness.
Maybe someboday has a good idea to resolve this issue.

In reply to chr_sue:

In reply to cuonghle:
Keys are used together with uvm_pool which represents an assiciative arry´ay. This is different to a queue.
Please find below a link for an uvm_queue example. This does not work for 2 queues of the same type. BTW this example is nott running on VCS. Seems to be a weakness.
Maybe someboday has a good idea to resolve this issue.
(1) - EDA Playground

The uvm_pool is a container of uvm_queue, it allows to get your uvm_queue for any key. This is convenient if you want to share queues no matter your queues are the same type or diffrrent.

In reply to cuonghle:

I’m refering to chapter 11 of the UVM Standard. In the Overview it says:

The container classes are type parameterized data structures. The uvm_queue #(T) class (see 11.3)
implements a queue data structure similar to the SystemVerilog queue construct. And the uvm_pool
#(KEY,T) class (see 11.2) implements a pool data structure similar to the SystemVerilog associative array.

For me this is a very clear statement.
Could you please explain your statement.

In reply to chr_sue:

I understand that uvm_queue implements the data structure similar to SV queue, and the uvm_pool is similar to SV associative array. But they do not change the fact that we can use uvm_pool as a container of uvm_queue using key string, in order to share the uvm_queue from a component to others easily. And it is the requirement of this topic.

You put any type of a uvm_queue to a pool, and get it in other components for specific key.
You can see many built-in pools like that in UVM such as uvm_barrier_pool, uvm_event_pool.

In reply to cuonghle:

Could you please paste a code snippet demonstrating what you are saying.
BTW you cannot put to a uvm_barrier_pool a uvm_event. These are different hings.
A queue and an associative array are also behaving differently. I don’t believe it works what you are trying to explain.

In reply to chr_sue:

Could you please paste a code snippet demonstrating what you are saying.

Please read my previous post in this topic (post 4). I used uvm_queue inside the uvm_pool with key type is string.

BTW you cannot put to a uvm_barrier_pool a uvm_event. These are different hings.

I don’t understand what you said. I meant, the uvm_pool feature of UVM has been used in many purpose such as uvm_barrier_pool and uvm_event_pool. The using of uvm_queue with uvm_pool (uvm_queue_pool) is also the same approach.

A queue and an associative array are also behaving differently. I don’t believe it works what you are trying to explain.

Of course a queue and associative array are different. But the uvm_pool or uvm_object_string_pool are designed to support any type of object as argument even uvm_queue.

In reply to cuonghle:

I see it works with the uvm_object_string_pool but this is not dedicated to an associative array.