You are on page 1of 2

FIFO Depth Calculation: Basically we use FIFO for synchronizing two clock domains (different frequencies) so we need a device

which has some tolerance power to hold the data that device is called FIFO .By using FIFO we can easily avoid overflow and underflow conditions The scenario can be two of following l l Writing is faster than reading then there is possibility of overflow Writing is slower than reading then there is possibility of underflow

In FIFO depth calculation we always have to consider worst cast .size of FIFO basically implies that how much data is required to buffer . And it is totally depend on data rate of reading and writing. Data rate = Number of Data x Time Period Difference = DRFAST DRSLOW Depth = Difference / Higher Freq. Time Period

Writing side is Source and Reading Side is Sink. If the data rate of writing is higher then the reading sides data rate then the FIFO will now overflow. Another Type of depth calculation can be done by this method: Consider F1 is writing frequency and F2 is reading frequency (F1>F2) and Data Size is D (Data Words) Time taken to write to FIFO = DATA/F1 Data Read from the FIFO in the same time = (DATA/F1) xF2 Excess Data is FIFO (Backlog) = DATA-((DATA/F1) x F2 Read side will take more time to read the data so that time is called mop-up time. Following is the calculation of mop-up time Mop-up time = Backlog/F2 = DATA-(DATA/F1 F2) Fwrite = Clock Frequency of Write Clock Domain Depth= Wmax {Wmax x Fread x Wread} Fread = Clock Frequency of Read Clock Domain Fwrite x Wwrite Wmax= Maximum number of worlds can be Written Wwrite = Number of Writes in Per Clock Wread = Number of reads in Per Clock Following are some cases of FIFO depth calculation with perfect explanation. Case: 1 Writing Side Reading Side Solution: Consider the data size is = 10 Data Rate of Writing = 10 x (1/30) =333.33 ns Data Rate of Reading = 10 x (1/40) =250.0 ns. Difference between Data Rates = 333.33 250.0 = 83.33 Now divide with highest frequency time period = 83.33/25ns = 3.3332 = 4 (Aprox) Depth of FIFO Should be 4 = 30 MHz => 33.33 ns Time Period = 40 MHz = > 25.0 ns Time Period

Case: 2 Writing Side Reading Side = 80 Data/100 Clock = 100 MHz => 10ns Time Period = 80 Data/80 Clock = 80 MHz => 12ns Time Period

No Randomization Solution: Data Size is = 80 Data Rate of Writing =80*10=800ns Data Rate of Reading=80*12=900ns Difference = 960-800=160ns Now divide with highest frequency time period = 160/10ns=16 Depth of FIFO Should be 16 Case: 3 Writing Side Reading Side Word Size Solution: Data Rate of Writing =100*2=200ns Data Rate of Reading=400*2=800ns Difference = 800-200=600 Now Divide by the lowest frequency time period = 600/400 = 1.5 = 2 Case: 4 Writing Data = 80 DATA/100 Clock (Randomization of 20 Datas) Outgoing Data= 8 DATA/10 Clock Solution: Above shows that the Writing Frequency is equal to reading frequency We will consider worst case = 10 MHz => 100 ns = 2.5 MHz=>400 ns =2

20 Data

80 Valid Data

80 Valid Data

20 Data

So we will consider 200 Cycles. In 200 Cycle 160 Data is written. it means 160 data continuously written in 160 clock it is the worst case . At the reading side we will Read 8x16=128 data in 16x10=160 Clock Cycle. So the Difference between Written Data and Read Back Data is = 160-128=32

You might also like