There are many serial communicating devices which gives data in bursts, i.e after launching several data in consecutive cycles, it then becomes quite for several cycles.
And in some other cases the frequency of such operations are different, where the device and processor will be on different clocks.
This causes Data Loss.
This causes Data Loss.
How to prevent this Data Loss?
A FIFO is a special type of buffer, where data written into the buffer first comes out first. There are other kinds of buffers, and choice of buffer is architecture dependent.
FIFOs can be implemented with software or hardware. The choice between a software and a hardware solution depends on the type of application and features desired.
How it works?
There are two clocks involved, a launch clock during which the data is stored in the FIFO just like write clock, and a capture clock where the data is read from the FIFO like read clock.
In a circular FIFO concept, the memory address of the incoming data is in the write pointer. The address of the first data word in the FIFO that is to be read out is in the read pointer. After reset, both pointers indicate the same memory location. After each write operation, the write pointer is set to the next memory location. The reading of a data word sets the read pointer to the next data word that is to be read out. The read pointer constantly follows the write pointer. When the read pointer reaches the write pointer, the FIFO is EMPTY. If the write pointer catches up with the read pointer, the FIFO is FULL.
FIFO Limitations:
FIFO is not of much use if launch clock is faster than capture clock, and if average data rate is greater than capture rate, because after a while, the FIFO would become FULL.
How to decide of FIFO buffer Size?
FIFO depth is decided as :
(data bytes (burst) written in write clock) - (data bytes read in read clock in the time taken to write the burst).
Example: Suppose 200 bytes burst is to be written at 100 MHZ, 1 byte per write clock. and Read clock is 50 MHZ, 1 byte read per read clock. what is the FIFO depth?
Time taken to write 1 byte = (1/100) = 10 ns
So, Time taken to write 200 Bytes = 10 * 200 = 2000 ns
Time required to read 1 byte = (1/50) = 20 ns
So, in 2000 ns date bytes read = (2000/20) = 100 Bytes
So, FIFO Depth = 200 - 100 = 100 Bytes.
Example: Suppose 200 bytes burst is to be written at 100 MHZ, 1 byte per write clock. and Read clock is 50 MHZ, 1 byte read per read clock. what is the FIFO depth?
Time taken to write 1 byte = (1/100) = 10 ns
So, Time taken to write 200 Bytes = 10 * 200 = 2000 ns
Time required to read 1 byte = (1/50) = 20 ns
So, in 2000 ns date bytes read = (2000/20) = 100 Bytes
So, FIFO Depth = 200 - 100 = 100 Bytes.