Fix the read side of the CDC data FIFO. The read address generation did not function correctly. Redesign the read side of the FIFO, and make sure that it becomes empty after the DMA transfer ends; and never get stock in a cyclic mode.
Make the gray coder/decoder's data width parameterizable.