First In First Out
A sequential type of memory used to pass data between two asynchronous clock domains. Usually between two systems working in same clock but with different throughput.
- Avoid Overflow
- Writing is faster than reading.
- Avoid Underflow
- Writing is slower than reading.
You can find the code and testbench of FIFO here, before that you need to know how to calculate the depth of the fifo.
Size of FIFO basically implies that how much data is required to buffer. Consider the worst case while reading and writing. So the depth basically depend on the rate of reading and writing and the size of data.
Note
Things to consider before calculating depth
- Read Frequency
- Write Frequency
- Data Length
- Idle Cycles in operations
Write Frequency > Read Frequency
How to Proceed
F write = 80MHz F read = 50Mz Burst Length = 120 Consider no idle cycle between
Time required to write one data item =
$\frac{1}{F_w}$ =$\frac{1}{80M}$ = 12.5 nsTime required for writing whole data = 120 * 12.5 = 1500 ns
Time required to read one data item =
$\frac{1}{F_r}$ =$\frac{1}{50M}$ = 20 nsNumber of data read during 1500ns =
$\frac{1500}{20}$ = 75Number of Data needed to store in FIFO = 120(Total data) - 75(read Data) = 45
Write Frequency > Read Frequency with idle clocks
How to Proceed
F write = 80MHz F read = 50Mz Burst Length = 120 1 Idle clock between successive writes 3 Idle clock between successive reads
Time required to write one data item with considering idle =
$2*\frac{1}{F_w}$ =$\frac{2}{80M}$ = 25 nsTime required for writing whole data = 120 * 25 = 3000 ns
Time required to read one data item with considering idle =
$4*\frac{1}{F_r}$ =$\frac{4}{50M}$ = 80 nsNumber of data read during 1500ns =
$\frac{3000}{80}$ = 37.5 = 37Number of Data needed to store in FIFO = 120(Total data) - 37(read Data) = 83
Write Frequency < Read Frequency
How to Proceed
Depth of 1 is sufficient.Write Frequency < Read Frequency with idle clocks
How to Proceed
F write = 30MHz F read = 50Mz Burst Length = 120 1 Idle clock between successive writes 3 Idle clock between successive reads
Time required to write one data item with considering idle =
$2*\frac{1}{F_w}$ =$\frac{2}{30M}$ = 66.67 nsTime required for writing whole data = 120 * 66.67 = 8000 ns
Time required to read one data item with considering idle =
$4*\frac{1}{F_r}$ =$\frac{4}{50M}$ = 80 nsNumber of data read during 1500ns =
$\frac{8000}{80}$ = 100Number of Data needed to store in FIFO = 120(Total data) - 100(read Data) = 20
Write Frequency = Read Frequency
How to Proceed
No need of FIFO if clock are on phase, Depth of **1** is sufficient if clock are out of phase.Write Frequency = Read Frequency with idle clocks
How to Proceed
F write = 50MHz F read = 50Mz Burst Length = 120 1 Idle clock between successive writes 3 Idle clock between successive reads
Time required to write one data item with considering idle =
$2*\frac{1}{F_w}$ =$\frac{2}{50M}$ = 40 nsTime required for writing whole data = 120 * 40 = 4800 ns
Time required to read one data item with considering idle =
$4*\frac{1}{F_r}$ =$\frac{4}{50M}$ = 80 nsNumber of data read during 1500ns =
$\frac{4800}{80}$ = 60Number of Data needed to store in FIFO = 120(Total data) - 60(read Data) = 60