Q: Bi-directional communication using Asynchronous FIFO? I am trying to interface a module (let's call it main_module) with a Dual Port Block RAM memory  generated by the Xilinx CORE Generator. Both the modules transmit and receive data with each other and run at markedly different clock speeds. In order to cater for the synchronization issues faced in interfacing, I have decided to use an asynchronous FIFO (also generated by the Xilinx CORE Generator). With regards to this I have some confusions:


*

*How can I efficiently change the assignment of FIFO Read and Write clocks for bi directional communication between the main_module and BRAM? In the memory write mode, the WR_CLK of FIFO would be that of the main_module and the RD_CLK of FIFO would be that of the BRAM module. In the memory read mode, the clocks would be oppositely assigned. Same will be with the DIN and DOUT pins assignment of FIFO. The read and write modes are selected through input signals. 

*What about the memory addresses? They would be generated in the main_module and have to be passed to the BRAM. Should synchronization be done for that too? If yes then what would be the most efficient manner for that? 


 

A: Three options come into mind in order of preference:
1) Switch to AXI in your BRam interface and use AXI components and protocol for multi-master memory access. It might seem like an overkill at first, but whatever you make from the scratch will need to work towards similar principles on ad-hoc basis, which typically is much more time consuming than using purpose built industry standards methods. 
2) (Re)Architect the design so that one BRam port is not needed to be shared. For example duplicate the data so that there is always just one clock per port, i.e. write to two BRams is the data is needed by two parties. 
3) As you propose, have a Fifo for the clock that is not used in the port natively. You will need to have both data and address in this Fifo. Writes are thus quite straining-forward, but for reads you'll need also Fifo (or XMP  Clock Domain Crossing Synchronizer) for the return channel and some protocol to handle the read. 
