Blog

What is FIFO? | Synchronous FIFO | Asynchronous FIFO

What is FIFO?
Digital Electronics

What is FIFO? | Synchronous FIFO | Asynchronous FIFO

Synchronous FIFO

A Synchronous FIFO is a First-In-First-Out queue in which there is a single clock pulse for both data write and data read. In Synchronous FIFO the read and write operations are performed at the same rate. The number of rows is called depth or number of words of FIFO and number of bits in each row is called as width or word length of FIFO. This kind of FIFO is termed as Synchronous because the rate of read and write operations are same.

Basically Synchronous FIFO are used for High speed systems because of their high operating speed. Synchronous FIFO are easier to handle at high speed because they use free running clocks whereas in case of Asynchronous FIFO they uses two different clocks for read and write. Synchronous FIFO is more complex then the Asynchronous FIFO.

Operations in the synchronous FIFO:

  1. Write Operation: The operation involves in writing or storing the data in to the FIFO memory till it rises any flag conditions for not to write anymore.
  • To perform a write operation the data to be written is given at DIN port and write EN is to be set high then at the next rising edge the data will be written.
  1. Read Operation: Read operation performed when we want to get data out from the FIFO memory until it informs there is no more data to be read from the memory, the condition called empty condition. Empty conditions are generated using empty flags.

Pointers to control operations:

  1. Write Pointer: This pointer controls the write operation of the FIFO. It used to points to the FIFO memory location where the data will be written.
  1. Read Operation: The read operation is controlled by the read pointer. It will be pointing the location from where next data is to be read.

Flags in FIFO:

Synchronous FIFO provides us with few flags, to determine the status or to interrupt the operation of FIFO.

  1. EMPTY flag: This flags is useful to avoid the case of the invalid request of read operation when the FIFO is already empty.
  2. FULL flag: This flags is useful to avoid the case of the invalid request of write operation when the FIFO is already full.

Here we use a variable named count, which will count the total number of words in the FIFO. On the basis of value of count the flag logic will assign values to flags. If the count reaches a value equal to the size of FIFO it will assign FULL flag as logic high and if the count becomes zero it will assign EMPTY flag as logic high.

Asynchronous FIFO

An Asynchronous FIFO refers to a FIFO where the data values are written to the FIFO at a different rate and data values are read from the same FIFO at a different rate, both at the same time. The reason for calling it Asynchronous FIFO, is that the read and write clocks are not Synchronized.

The basic need for an Asynchronous FIFO arises when we are dealing with systems with different data rates. For the rate of data flow being different, we will be needing Asynchronous FIFO to synchronize the data flow between the systems. The main work of an Asynchronous FIFO is to pass data from one clock domain to another clock domain.

How to use it?

Here for example consider two systems- system A and system B. Let the data from system A is to be fed to system B, and the data output rate of system A is different than the data input rate of system B. Here we can use an Asynchronous FIFO to Synchronize system A with system B. The data from system A will be taken as input in FIFO at a rate of system A and when FIFO is full the data will be given to system B at its respective rate.

Operations in Asynchronous FIFO:

  1. Write Operation:

This operation involves writing or storing the data into FIFO memory till it rises any flag conditions for not to write anymore.

  • To perform a write operation the data to be written is given at the DIN port and the write EN is to be set high then at the next rising edge of the write clock the data is written.
  1. Read Operation:

Read operation performed when we have to get data out from the FIFO memory until it informs there is no more data to be read from the memory. Empty conditions are generated using empty flags.

  • To perform read operation we need to set Read EN high then at the next rising edge of reading clock the data to be read is at DOUT

Pointers to control Operations:

  1. Write Pointer: This pointer controls the write operation of the FIFO. It points to the memory location where next data is to be written.
  2. Read Pointer: The read operation is controlled by read pointer. It points to the location from where next data is to be read.

Flags in FIFO:

Asynchronous FIFO provides us with following two flags, to determine the status and to interrupt the operation of FIFO.

  1. EMPTY flag: This flag is useful to avoid the case of invalid request of read operation when the FIFO is already empty.
  2. FULL flag: This flag is useful to avoid the case of invalid request of write operation when the FIFO is already full.

Problem with Asynchronous FIFO:

While designing Asynchronous FIFO, the common problem is controlling of FULL and EMPTY status signals. In Synchronous FIFO where the read and write rates are same, we can simply count the total number of variables in FIFO. Increase the count whenever the write operation is performed, decrease the count whenever the read operation is performed and leave the count unchanged when read and write operations are performed simultaneously.

But it’s not the case with Asynchronous FIFO. As here the rate of data write and read are different so we can’t just keep increasing and decreasing the count for data write and read respectively.

Solution to the problem:

On doing successive operation of read and write we can met two conditions of intersection of locations stored in read and write pointer. First when the rate or reading is higher than that of rate of write and read pointer catches up write pointer, this is the condition of EMPTY FIFO. Second is when rate of write is higher than that of read and write pointer catches up read pointer by already completing a round of FIFO.

As in both of these cases the read and write pointer are containing same locations, so we need to distinguish these two cases. To distinguish these two cases we can use an extra flag, let us name it as round. Initially value assigned to round is zero. Every time either read or write pointer is given location zero after reaching its maximum value, round must be toggled. So now every time read and write have same values and round is zero, it means FIFO is empty. And every time read and write have same value and round is one, it means FIFO is full.

Leave your thought here