Skip to content

Latest commit

 

History

History

3. FIFO

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

FIFO 📥

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.

alt text

Uses of FIFO

  • 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.

Depth Calculation

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

CASE 1

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 ns

Time 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 ns

Number of data read during 1500ns = $\frac{1500}{20}$ = 75

Number of Data needed to store in FIFO = 120(Total data) - 75(read Data) = 45

CASE 2

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 ns

Time 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 ns

Number of data read during 1500ns = $\frac{3000}{80}$ = 37.5 = 37

Number of Data needed to store in FIFO = 120(Total data) - 37(read Data) = 83

CASE 3

Write Frequency < Read Frequency
How to Proceed Depth of 1 is sufficient.

CASE 4

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 ns

Time 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 ns

Number of data read during 1500ns = $\frac{8000}{80}$ = 100

Number of Data needed to store in FIFO = 120(Total data) - 100(read Data) = 20

CASE 5

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.

CASE 6

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 ns

Time 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 ns

Number of data read during 1500ns = $\frac{4800}{80}$ = 60

Number of Data needed to store in FIFO = 120(Total data) - 60(read Data) = 60

Simulation Results

waveform

schematic