Interfacing Two Clock Domains【zz】

http://www.asic-world.com/tidbits/clock_domain.html

 

Introduction

There are times when a designer needs to interface two systems working at two different clocks. This interfacing is difficult in the sense that design becomes asynchronous at the boundary of interface, which results in setup and hold violation, metastability and unreliable data transfers. So we need to go out for special design and interfacing techniques.




 

Any two systems are considered asynchronous to each other:

 

space.gif

When they operate at two different frequency




 ../images/tidbits/crossfreq_diff_freq.gif  

space.gif

When they operate at same frequency, but at two different clock phase angles




../images/tidbits/crosscfreq_same_freq.gif


Here we have two systems, which are asynchronous in nature to each other. In such a case if we need to do data transfer, there are very few methods to achieve this:
 

space.gif

  • Handshake Signaling method.
  • Asynchronous FIFO.








space.gif




   

space.gif





 

space.gif

  ../images/main/bulllet_4dots_orange.gif Handshake Signaling


In this method the system (module) A sends data to system/module B based on the handshake signals ack and req signals. The protocol for this uses the same old method that is found with 8155 chip used with 8085.

   

space.gif



../images/tidbits/crossc1.gif
   

space.gif



Protocol



  • Transmitter asserts the req (request) signal, asking the receiver to accept the data on the data bus.
  • Receiver asserts the ack (acknowledge) signal, asserting that it has accepted the data.
   

space.gif



../images/tidbits/crossc15.gif
   

space.gif



This method is straightforward, but it too has got loop holes: when system B samples the systems A's req line and System A samples system B's ack line, they are done with respect to their internal clock, so there will be setup and hold time violation. To avoid this we go for double or triple stage synchronizers, which increase the MTBF and thus are immune to metastability to a good extent. The figure below shows how this is done with respect to the above example.

   

space.gif



../images/tidbits/crossc6.gif
   

space.gif



If we do the double or triple stage synchronizing, then the transfer rate comes down, due to the fact that a lot of clock cycles are wasted just handshaking.

   

space.gif



../images/tidbits/crossc8.gif
   

space.gif



Sometimes it is good to synchronize the data also to be double sure, but normally we don't do this, as it takes a lot of logic and what we gain is very small. The figure below shows one such case (there is no difference between circuits shown for req and data, they are one and same).

   

space.gif



../images/tidbits/crossc11.gif
   

space.gif

  ../images/main/bulllet_4dots_orange.gif Asynchronous FIFO


An Asynchronous FIFO has got two interfaces, one for writing the data into the FIFO and the other for reading the data out. It has got two clocks, one for writing and the other for reading. System A writes the data in the FIFO and System B reads out the data from it. To facilitate error free operations, we have FIFO full and FIFO empty signals. These signals are generated with respect to the corresponding clock. FIFO full signal is used by system A (as when FIFO is full, we don't want system A to write data into FIFO, this data will be lost), so it will be driven by the write clock. Similarly, FIFO empty will be driven by the read clock. Here read clock means system B clock and write clock means system A clock.

   

space.gif



Asynchronous FIFO is used at places when the performance is a matter, when one does not want to waste clock cycles in handshake signals, when there is a lot of system resources available.

   

space.gif



../images/tidbits/async_fifo_crossfreq.gif
   

space.gif



How to design an Asynchronous FIFO is not in the scope of this document, but what I would like to point out is that one should be careful with the generation of FIFO full and FIFO empty signals, as it may, in certain cases, cause metastability.

posted on 2009-11-03 18:24  Homography Matrix  阅读(507)  评论(0编辑  收藏  举报

导航