dll_fpga
Full Member level 3
- Joined
- Mar 9, 2011
- Messages
- 185
- Helped
- 19
- Reputation
- 38
- Reaction score
- 21
- Trophy points
- 1,298
- Location
- kerala,India
- Activity points
- 2,416
I think depth of any FIFO can be calculated as
Syncronous FIFO or
Asyncronous FIFO: = Bwr/Brd where Bwr is the peak write side data rate or bandwdth .Brd is the peak read side data rate.
Anyone with different opinions please let me know.
The implementation of a FIFO can require additional depth due to latency delays. A simple example is a dual clock fifo. In order to function, signals need to be transferred between clock domains. This transfer will take clock cycles to accomplish. During that latency time you will need to have additional storage (i.e. fifo depth) without which the fifo will overflow.
You can observe a simple test case of this by
- Creating a 1 deep dual clock fifo
- Clock both sides with the same frequency clock, perhaps phase shifting the one if you'd like
Depending on the implementation, this latency might be needed even for a single clock fifo. In any case, to correct your equation you'd need to add round trip latency delay.
Another example where your equations fails is if Bwr/Brd is not an integer. Simple case, Bwr = 1.1 MB/sec; Brd = 1 MB/sec so your fifo depth would be 1.1. Or Bwr = 1; Brd = 2 so your ratio is 0.5. Fifos have depths that are integers. This one is simple to correct: Depth = ceil(Bwr/Brd)
As permute already pointed out, if Bwr > Brd, then you need to know how long such this condition is maintained (it can't be 100% of the time obviously).
In short your equation is not correct under any of the following conditions:
- Bwr > Brd (see permute's posting for example)
- Bwr < Brd (this post, can't have fractional fifo depth)
- Bwr = Brd (this post, need to consider latency in dual clock fifos)
Kevin Jennings
Hello Permute and KJ,
Thanks for the post.
Permute,
I think instead of peak bandwidth we need to consider the peak throughput(actual amount of DATA that is written/read in a given time frame). .
>>Look at a 1Mbps data stream and a processor capable of processing data at 100Mbps. It would appear as if no FIFO is required. However, what if the 1Mbps is coming from a 10Gbe interface as a 1Mbit burst once per second. The data is written in 100us. During this time, 10kb of data is processed. This means a FIFO would need to buffer 990kb of data, which is nearly the entire size of the burst.
My assumption is that the entire DATA chunk written will be processed during the read
In the above example since the data throughput of the write side is lesser than read side(1Mpbs and 100 Mbps) ,i think, a FIFO is not needed.
Similarly for variable write and read speeds we need to compute maximum write/read that can happen in a given time frame.
FIFO size = max write -max read(within a given time frame)
K-J ,
I think a correction factor of +-2 can be considered for the synchronization delay.As K-J pointed out any calculation results has to be rounded to the next highest integer value.
Thus combining both we get FIFO size = calculated size +2 .(considering worst case)
Another thing to be noted is "do not write to a full FIFO and do not read from an empty FIFO".so i think Bwr > Brd is the worst case scenario.(to avoid overflow)
so instead of Bwr/Brd ,the formul has to be modified to wr(total writes) - rd(total read)
Please let me know your comments.
mostly yes, and that is why I left the format in terms of bits. It is fairly common to have width/rate changing fifos.
There may be some implementation reasons to avoid some width changes. For example, it may be desirable to place the first word of a packet in an aligned location. Doing this would artificially increase the write bandwidth by a small amount. Likewise, the receiver may need additional cycles within a FSM for each received packet. This would lower the read bandwidth by a small amount unless the state machine were changed.
In my original example, the only reason why buffering 990kb was enough was that the system only received 1Mb in that second and was fully capable of processing all of it. If the system receives more data than it can process on a continual basis, the fifo would overflow eventually.
fundamentally, Bwr/Brd, or any similar ratio, will never be correct. The fifo has a size in bits (or bytes, words, etc...). time/time, freq/freq, etc... will all be unitless.
My intent here is to show that there isn't a useful and simple formula for every fifo sizing problem. In many practical cases, it isn't difficult to size the fifo. Beyond this, sizing based on an upper-bound (eg, 1Mbit vs 990kbit) is often not significantly different than the optimum sizing. More complex fifo sizing problem might be closely upper-bounded by convex optimization problems. In other cases, it may be a combinatorial optimization problem. Though more often a loose upper bound found by simplified assumptions is used instead.
Post #6 should answer your question about back-pressure.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?