G
googler
Guest
Hi,
For asynchronous FIFO implementation, I usually use the technique with
gray-coded read and write pointers. To elaborate, it uses n+1 bit
pointers (instead of the n bits) for both read and write and these are
stored in registers as gray codes, synchronized over to the other
clock domain and compared with the gray pointer there. For empty, all
bits in gray-coded read and write pointers should be equal. For full,
2 MSBs of the gray-coded pointers should be inverted with respect to
the other, but the other bits should match.
Now, I have read a few papers on this topic (including Cliff
Cummings'). I didn't find any explanation on how to calculate the
number of elements in the FIFO (which can also help with finding
'almost full/empty' statuses). I have the following questions.
1. Is it a viable option to convert the synchronized gray read pointer
to binary value and subtract it from the binary value of the write
pointer to calculate the number of elements in the fifo (on the write
side)? (Similarly for the other side)
2. If it is, then I would think we can use this number to determine
whether the fifo is almost full (with respect to a programmable value)
on the write side. However, I do not see this is getting done
anywhere. Instead, I read some papers that say using gray-coded
pointers restrict the generation of 'almost full/empty' flags (when
using arbitrary programmable numbers). Is that true, or is it possible
to generate 'almost full/empty' statuses using this approach?
Thanks.
For asynchronous FIFO implementation, I usually use the technique with
gray-coded read and write pointers. To elaborate, it uses n+1 bit
pointers (instead of the n bits) for both read and write and these are
stored in registers as gray codes, synchronized over to the other
clock domain and compared with the gray pointer there. For empty, all
bits in gray-coded read and write pointers should be equal. For full,
2 MSBs of the gray-coded pointers should be inverted with respect to
the other, but the other bits should match.
Now, I have read a few papers on this topic (including Cliff
Cummings'). I didn't find any explanation on how to calculate the
number of elements in the FIFO (which can also help with finding
'almost full/empty' statuses). I have the following questions.
1. Is it a viable option to convert the synchronized gray read pointer
to binary value and subtract it from the binary value of the write
pointer to calculate the number of elements in the fifo (on the write
side)? (Similarly for the other side)
2. If it is, then I would think we can use this number to determine
whether the fifo is almost full (with respect to a programmable value)
on the write side. However, I do not see this is getting done
anywhere. Instead, I read some papers that say using gray-coded
pointers restrict the generation of 'almost full/empty' flags (when
using arbitrary programmable numbers). Is that true, or is it possible
to generate 'almost full/empty' statuses using this approach?
Thanks.