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)
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?
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).
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.
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();
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.