Google

Lubee's Blog--Digtial IC Fan's Home

WELCOME IC FANS' HOME! --ASIC/IC Design,Logical Design,STA,Digital IC Design,Synthesis, and so on.

2007-12-20

Calculate Depth of FIFO

It is an interesting Architectural decision, what should be our FIFO depth?
  • What is the Transmitter data rate?
  • What is the reciever data rate?
when there is a requirement for FIFO? when the Transmitter data rate and the recieve data rate are not in sync rather they dont match.The read is slower than the write, so there is always a chance the data will be lost, so FIFO will be an intermediate logic where the data would be buffered or stored . Smaller FIFO depth can cause overflow scenario and cause a data loss
Possible scenarioes:
Scenario 1:
Write is in maximum condition & Read is in minimum condition , means Write process is writing the data faster and read is reading or accessing the data slowest.
Scenario 2:
Whether the design supports only single writes or burst writes also. It becomes more complex when burst writes are present.
Scenario 3:
Write with no idle cycles and read with idle cycles.
Scenario 4:
Is the design's requirement is of Synchronous FIFO or an asynchronous FIFO?
Synchronous FIFO: A First In First Out memory, where in the has a control logic mechanism, has read and write pointers, generates Status signals and places handshake signals across. Sync FIFO has a same clock frequency for both read and write operation. The control/status signals could be Read Error, Write Error signals generated. Read Error generated when the FIFO is empty and Write Error is generated when the FIFO is full, writing may cause a data loss.Based on these signals can generate interrrupt signals to act upon. Handshake signals could be Read Enable or a Write Enable, Write Acknowledge and read acknowledge.
Asynchronous FIFO: The operation of Write and Read of a FIFO is purely asynchronous.
Scenario 5:
The Data width of an Tx and Rx are different.
Watermarks as Threshold setters
Set an low watermark and high watermark
FIFO_watermarking

Details about depth of FIFO

One of the most common questions in interviews is how to calculate the depth of a FIFO. Fifo is used as buffering element or queueing element in the system, which is by common sense is required only when you slow at reading than the write operation. So size of the FIFO basically implies the amount of data required to buffer, which depends upon data rate at which data is written and the data rate at which data is read. Statistically, Data rate varies in the system mainly depending upon the load in the system. So to obtain safer FIFO size we need to consider the worst case scenario for the data transfer across the FIFO under consideration.

For worst case scenario, Difference between the data rate between write and read should be maximum. Hence, for write operation maximum data rate should be considered and for read operation minimum data rate should be considered.

So in the question itself, data rate of read operation is specified by the number of idle cycles and for write operation, maximum data rate should be considered with no idle cycle.

So for write operation, we need to know Data rate = Number of data * rate of clock. Writing side is the source and reading side becomes sink, data rate of reading side depends upon the writing side data rate and its own reading rate which is Frd/Idle_cycle_rd.

In order to know the data rate of write operation, we need to know Number of data in a Burst which we have assumed to be B.

So following up with the equation as explained below:

Fifo size = Size to be buffered = B - B * Frd / (Fwr* Idle_cycle _rd ).

Here we have not considered the synchronizing latency if Write and Read clocks are Asynchronous. Greater the Synchronizing latency, higher the FIFO size requirement to buffer more additional data written.

../images/main/bulllet_4dots_orange.gifExample : FIFO Depth Calculation

Assume that we have to design a FIFO with following requirements and We want to calculate minumum FIFO depth,space.gif

  • A synchronized fifo
  • Writing clock 30MHz - F1
  • Reading clock 40MHz - F2
  • Writing Burst Size - B
  • Case 1 : There is 1 idle clock cycle for reading side - I
  • Case 2 : There is 10 idle clock cycle for reading side – I

FIFO depth calculation = B - B *F2/(F1*I)

If we have alternate reading cycles, i.e. between two reading cycle there is IDLE cycle.

FIFO depth calculation = B - B * F2/(F1*2)

In our present problem FIFO depth = B - B *40/(30*2)= B(1-2/3)= B/3

That means if our Burst amount of data is 10, FIFO DEPTH = 10/3 = 3.333 = 4 (approximately)

If B = 20, and then FIFO depth = 20/3 = 6.6 = 7 or 8 (clocks are asynchronous)

If B = 30 FIFO depth = 30/3 = 10 or 11 (clocks are asynchronous)

If 10 IDLE cycles between two reading cycles .

FIFO DEPTH = B - B *F2/(F1*10) .

= B(1-4/30)

= B * 26 /30


Labels:

1 Comments:

Anonymous Anonymous said...

Hey buddy...consider this case where write freq is 100Mhz with duty cycle 50 and read freq is 90MHz with duty cycle 60 ..and data size is 8units,,,can u explain the depth of fifo now

July 30, 2014 at 8:26 PM  

Post a Comment

Subscribe to Post Comments [Atom]

<< Home