2

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:

  1. 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.
  2. 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?

Input and Output Data with an AFIFO

Candy
  • 133
  • 1
  • 10
  • 1
    Can you clarify what you are planning to do with the Bram. The Fifo should be enough for the communication and typically you don't need an additional Bram. Just use 2 Fifos for 2-way communication. Check out also xmp components from Xilinx. They are much more accessible than core generator cores for memory and fifos, and also have handy clock domain crossing stuff. – FritzDC Jul 25 '17 at 07:40
  • Another top level module will be accessing the BRAM contents ultimately. Basically my main_module running at clockA sends (or receives) data and address to be written to (or read from) the BRAM clocked at clockB. This poses synchronization and setup/hold time issues. I was planning to introduce a FIFO in between the BRAM and main_module. – Candy Jul 25 '17 at 09:26
  • It sounds a bit that you are trying to over engineer a common setup, where just a bram with two ports in different clock domains would suffice. Any other solution will be less efficient in both resource usage and maximum throughput. For any and all multi-bit signal clock domain crossing, best bet is to use fifos. One for each direction. BTW, you don't clock the bram, but the interface port. – FritzDC Jul 25 '17 at 10:01
  • Not exactly over engineer, as other modules will also have access to the BRAM at different times and only my main_module has a different clock speed! – Candy Aug 03 '17 at 04:10
  • So, I cannot see how true dual port ram with one port for the "main block" and one port for "the other" with independent clocks would not be solution to your design problem. – FritzDC Aug 03 '17 at 06:03
  • So you suggest switching of dual port RAM for my main_module? Because other modules also use this port of BRAM at clockB at different times. Only main_module has different clock. Please note that the port A of BRAM is tied to a top module at all times. The port B is switched between different modules, one of which is main _module. – Candy Aug 07 '17 at 10:34
  • 1
    Ok, I didn't picture in the top module, sorry. I'll make proper answer with this info. – FritzDC Aug 10 '17 at 06:32

1 Answers1

1

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.

FritzDC
  • 497
  • 1
  • 6
  • 21
  • Okay I tried using AFIFO method..but there seems to be a read latency of almost 6 cycles when I start writing to the input port of AFIFO i.e. data becomes available on the output port of AFIFO after six clock cycles. Is this to be expected? – Candy Aug 10 '17 at 17:27
  • It vastly depends on the clocks - what are the frequencies and are they related - 6 clocks sounds a bit much, but completely possible. Make sure to have "fist fall through" enabled. – FritzDC Aug 11 '17 at 06:28
  • The clocks are independently generated. The faster clock is 5 times faster than the slower one and are also out of phase. I have also uploaded a screenshot of my simulations. – Candy Aug 22 '17 at 05:01