Electrical – Asynchronous FIFO for fast-write-slow-read

cdcfifofpga

I'm not quite sure how to generate full signal in a FIFO with fast-write and slow-read. Eg., if f_wr=10*f_rd, when the updated writing pointer is synchronized to reading side using simple methodologies for synchronization from fast clock domain to slow clock domain (e.g., by extending the lifetime of the data in fast clock domain), several data could have been written into the FIFO. In such cases, the full signal is not up-to-date and may cause the data in FIFO be overwritten. What kind of special processing should be taken here?

As I tried to generate an FIFO IP in Xilinx ISE, there's no option to input the parameters of the clocks if I choose not to use built-in FIFO, i.e., it doesn't know which side (write/read) goes faster. How does the IP do such synchronization correctly?

Best Answer

If the average input and output data rates are fixed and different, then you will overflow or underflow a FIFO eventually. There is no 'processing' you can use to avoid corrupting data.

What a FIFO does is act as a flexible buffer to take up temporary variations in the data arrival and consumption rate. The FIFO has to be deep (long?) enough so that it can store all of the excess data, and a bit more for margin.

If your input and/or output rates are not externally fixed, then you can use the FIFO to control one or the other. A FIFO will have full and empty flags, and the Xilinx ones have programmable 'nearly full' and 'nearly empty' flags as well. These can be fed back to your data source and/or and sink to tell them to wait. The deeper the FIFO, the longer you can allow a difference in input/output rate to persist before having to throttle the faster connection.