FI FO Depth Calcul ati on: 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 Writing is faster than reading then there is possibility of overflow l 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.
Writing side is Source and Reading Side is Si nk. 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 Fread = Clock Frequency of Read Clock Domain 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 Si de = 30 MHz => 33.33 ns Time Period Reading Side = 40 MHz = > 25.0 ns Ti me Period 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 Depth= Wmax {Wmax x Fread x Wread} Fwrite x Wwrite Case: 2 Writing Si de = 80 Data/ 100 Clock = 100 MHz => 10ns Time Peri od Reading Side = 80 Data/ 80 Cl ock = 80 MHz => 12ns Ti me Peri od 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 Si de = 10 MHz => 100 ns Reading Side = 2.5 MHz=>400 ns Word Size = 2 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 ( Randomi zati on of 20 Datas) Outgoi ng Data= 8 DATA/ 10 Clock Solution: Above shows that the Writing Frequency is equal to reading frequency We will consider worst case
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 20 Data 80 Val id Data 80 Val i d Data 20 Data