To exchange flags (1 bit signals) between two unrelated clocks, a single synchronizer flip flop to clock that signal is used normally. However, under violations of setup/hold times of the flip flop, metastability can occur. On a Virtex2 Pro, does metastability occur often? Does adding a second (or even third) flip flop after the synchronizer flip flop help or is that overcautious? Best Regards, Simon Heinzle
Synchronizer Flip Flop / Metastability
Started by ●September 23, 2005
Reply by ●September 23, 20052005-09-23
On Fri, 23 Sep 2005 13:37:11 +0200, Simon Heinzle wrote:> To exchange flags (1 bit signals) between two unrelated clocks, a single > synchronizer flip flop to clock that signal is used normally. However, under > violations of setup/hold times of the flip flop, metastability can occur. > > On a Virtex2 Pro, does metastability occur often? Does adding a second (or > even third) flip flop after the synchronizer flip flop help or is that > overcautious? > > Best Regards, > Simon HeinzleStandard practice is two flip flops not one. It's been decades since I looked at the math but as I recall there is a square law involved, i.e. the probability of a double synchronizer failing is the square of a probability of a single synchronizer failing. Someone who has looked at this more recently then me might say that my math is wrong but in any event there is no question that a double synchronizer is significantly better than a single synchronizer.
Reply by ●September 23, 20052005-09-23
Simon Heinzle wrote:> To exchange flags (1 bit signals) between two unrelated clocks, a single > synchronizer flip flop to clock that signal is used normally. However, under > violations of setup/hold times of the flip flop, metastability can occur. > > On a Virtex2 Pro, does metastability occur often? Does adding a second (or > even third) flip flop after the synchronizer flip flop help or is that > overcautious? > > Best Regards, > Simon HeinzleThere have been many good threads on this subject. You may want to Google this group for "metastability." That being said, the answer is of course "it depends." The number of stages required depends on your clock rate, the metastability characteristics of the flip-flops, and your required failure tolerance. Generally two stages are used, however it is possible to get away with one if the signal is only used at the next edge of the clock (which is almost like two stages except the second stage may have less tolerance for metastability if there is a LUT between the two stages). In any case, make sure the input is synchronized only once to avoid possible logic errors. This may seem obvious, but if your "single-stage" synchronizer output has many loads the tools may duplicate the flip-flop for you unless you specifically tell them not to. In the case of a two-stage synchronizer, only the second flip-flop might be duplicated as the fist stage has just one load. Also the routing delay from first to second stage can become important at higher frequencies. Just my 2 cents Gabor
Reply by ●September 23, 20052005-09-23
"Simon Heinzle" <sheinzle@student.ethz.ch> wrote:>To exchange flags (1 bit signals) between two unrelated clocks, a single >synchronizer flip flop to clock that signal is used normally. However, under >violations of setup/hold times of the flip flop, metastability can occur. > >On a Virtex2 Pro, does metastability occur often? Does adding a second (or >even third) flip flop after the synchronizer flip flop help or is that >overcautious?Xilinx has a application note on this general subject: http://www.xilinx.com/bvdocs/appnotes/xapp094.pdf While adding multiple stages can reduce the risk of a metastable failure, it is not the only way to do so. Both the odds of a metastable failure and the consequences of that failure are important. The odds can be improved by increasing the settling time. See figure two in the application note. To make sure there is enough settling time, typical designs might both put an additional timing constraint between the synchronizer FF and the next FF or FFs, and put physical constraint (LOC or RLOC) on these FFs to position them for minimal delay. The consequences can sometimes be improved by making the rest of the design more robust. Examples might be to design the logic to recover from a metastable failure, to make the software check the data and ignore/correct invalid values, etc. -- Phil Hays to reply solve: phil_hays at not(coldmail) dot com If not cold then hot
Reply by ●September 23, 20052005-09-23
Simon, Firstly, congratulations on having parents who can spell. Secondly, you may be interested in this link:- http://www.fpga-faq.org/FAQ_Pages/0017_Tell_me_about_metastables.htm Lots of good stuff, complete with a link to this:- http://www.fpga-faq.org/archives/59375.html#59399 a simple and reliable circuit posted by Rick Collins to transfer a flag from one domain to another. Cheers, Symon. p.s. Isn't Google ads great? At the bottom of the above linked page, I saw an advertising link for beach footwear! Guess which type.... "Simon Heinzle" <sheinzle@student.ethz.ch> wrote in message news:4333e8e2$1@news1.ethz.ch...> To exchange flags (1 bit signals) between two unrelated clocks, a single > synchronizer flip flop to clock that signal is used normally. However,under> violations of setup/hold times of the flip flop, metastability can occur. > > On a Virtex2 Pro, does metastability occur often? Does adding a second (or > even third) flip flop after the synchronizer flip flop help or is that > overcautious? > > Best Regards, > Simon Heinzle > > >
Reply by ●September 23, 20052005-09-23
Simon, metastability is a problem that cannot be "solved", we can only reduce the probability of errors due to metastability. The extra delay at the Q output of a flip-flop (or latch) with undefined timing relationship between D and Clk is theoretically unbounded. This can be a surprise to digital designers who are accustomed to deterministic behavior. Metastability is not deterministic, it is a statistical phenomenon. The good news is that modern CMOS flip-flops and latches recover very fast, within a few ns, as shown in the Xilinx app note XAPP094, which is based on actual measurements, not on theory. In many cases you will find that the mean-time-betwen-failure is millions or billions of years. Just make sure that the data path from the metastable-going flip-flop to the (single!) next synchronizing flip-flop is as fast as possible. No extra logic, absolutely minimal routing delays. Peter Alfke, Xilinx Applications
Reply by ●September 26, 20052005-09-26
Thanks a lot guys! "Simon Heinzle" <sheinzle@student.ethz.ch> wrote in message news:4333e8e2$1@news1.ethz.ch...> To exchange flags (1 bit signals) between two unrelated clocks, a single > synchronizer flip flop to clock that signal is used normally. However, > under violations of setup/hold times of the flip flop, metastability can > occur. > > On a Virtex2 Pro, does metastability occur often? Does adding a second (or > even third) flip flop after the synchronizer flip flop help or is that > overcautious? > > Best Regards, > Simon Heinzle > > >
Reply by ●September 27, 20052005-09-27
Peter Alfke wrote:> metastability is a problem that cannot be "solved", we can only > reduce the probability of errors due to metastability.This certainly depends on what you mean by "solved". Even machines intended to be completely deterministic are built of components which have various wear and statistical failure mechanisms. However, engineers usually consider the problem solved if the MTBF of the conglomeration of gears, relays, tubes, CMOS transistors, etc. is longer than the expected operational life of the widget by sufficient orders of magnitude. In that sense, one could easily consider the metastability problem solved when the probability of the register train not resolving is far less than that of the device getting vaporized in a direct meteor strike. In which case even a CMOS NAND gate would no longer produce the correct voltage result.> In many cases you will find that the mean-time-betwen-failure is > millions or billions of years.Which means the power supply, if not electromigration, background radiation, bonding wires, or even a meteor strike, etc., would far more likely cause any instance of the "solved" FPGA solution to fail even earlier. IMHO. YMMV. -- Ron rhn A.T nicholson d.O.t C-o-M
Reply by ●September 27, 20052005-09-27
Your wear-out analogy does not apply. Metastability failure is completely statistical and probabilistic. Even when the MTBF is a million years, the failure can occur in the next second. Not likely, but possible. That's why I claim that the problem can never be solved. We can only reduce the probability down to an acceptable level. I really believe that this is an important distinction vs any failure besed on wear-out. Peter Alfke
Reply by ●September 27, 20052005-09-27






