QUEUES

Hi Folks,

I have a doubt in working of Queue.

Generally QUEUE works as FIFO and LIFO. It does the same work a FIFO and LIFO does.

The question is, Whether the Queue acts like Asynchronous FIFO or Synchronous FIFO ? Will a Queue works in two different frequencies ? Meaning, Write to Queue happens at one clock (CLOCK_1) and read from the queue happens at different clock (CLOCK_2)

Thanks in Advance,
Yogaraj

In reply to Yogaraj Selvalingam:

You question is unclear. A SystemVerilog queue is a data type for a kind of Dynamic array. Whether it is asynchronous or synchronous depends on the location of the code doing the reading or writing. That code, together with a queue array can be used to construct a FILO or LIFO.

So are you asking how a queue is operates as a software construct, or how one constructs a queue in hardware?

In reply to dave_59:

Hi Dave,

Thanks for your Valuable time and answer.

I am asking regarding software construct. If I am using push_front() method to write a sequence of data ‘A’, ‘B’, ‘C’, ‘D’ inside a queue and I trying to use pop_back() method to read the data from queue. Now the Queue works like First In First Out.

The question is can I push the data inside the queue at one clock and read the data from the queue from different clock. i.e. Master is pushing at @(posedge master_clock) and slave is trying to pop data at different clock @(posedge slave_clock).

In reply to Yogaraj Selvalingam:

It would be better using a mailbox put() and get() method for what are doing. A mailbox takes care of the synchronization issues together with the queue data.

In reply to dave_59:

Yes, I am agreed with Dave. A mailbox is a better option for a synchronization than queue.
But, still if you want to use a common queue in two different clock cycles, then you can use size() method of queue to provide synchronization at popping clock.
e.g.,
if(queue.size() > 0) queue.pop_back();

In reply to bdreku:

Hi Dave,

Thank you for clearing my doubts.

In reply to Yogaraj Selvalingam:

Hi Dave,

I am developing a Behavioral Modelling Code for an IP. The IP generally works on two different clocks. Write is happening at one clock and read is happening in different clock. I have two ways to do, Either using a FIFO or Queues. I have worked in Queues that work in single clock. So I got a doubt whether it can work on two different clocks. Now I am clear with it.

Hi Bdreku,

I am using queue.size() method to pop data out from the Queue to provide proper synchronization.

Thanks,
Yogaraj

In reply to Yogaraj Selvalingam:

See my model at
https://verificationacademy.com/forums/systemverilog/asynchronous-fifo-verification

Ben