Professional Documents
Culture Documents
Boston, MA
Voted Best Paper
1st Place
Clifford E. Cummings
Sunburst Design, Inc.
cliffc@sunburst-design.com
ABSTRACT
1.0 Introduction........................................................................................................................... 6
2.0 Metastability.......................................................................................................................... 6
2.1 Why is metastability a problem?........................................................................................... 7
3.0 Synchronizers........................................................................................................................ 8
3.1 Two synchronization scenarios ............................................................................................. 8
3.2 Two flip-flop synchronizer ................................................................................................... 8
3.3 MTBF - mean time before failure ......................................................................................... 9
3.4 Three flip-flop synchronizer ............................................................................................... 10
3.5 Synchronizing signals from the sending clock domain....................................................... 10
3.6 Synchronizing signals into the receiving clock domain...................................................... 11
4.0 Synchronizing fast signals into slow clock domains .......................................................... 13
4.1 Requirement for reliable signal passing between clock domains ....................................... 13
4.1.1 The "three edge" requirement .......................................................................................... 13
4.2 Problem - passing a fast CDC pulse ................................................................................... 14
4.3 Problem - sampling a long CDC pulse - but not long enough!........................................... 15
4.4 Open-loop solution - sampling signals with synchronizers ................................................ 16
4.5 Closed loop solution - sampling signals with synchronizers .............................................. 17
5.0 Passing multiple signals between clock domains ............................................................... 18
5.1 Multi-bit CDC strategies..................................................................................................... 18
5.2 Multi-bit signal consolidation ............................................................................................. 18
5.3 Problem - Two simultaneously required control signals..................................................... 19
5.3.1 Solution - Consolidation.................................................................................................. 20
5.4 Problem - Two phase-shifted sequencing control signals................................................... 21
5.4.1 Solution - consolidation and an extra flip-flop................................................................ 22
5.5 Problem - Multiple CDC signals......................................................................................... 23
5.5.1 Solutions for passing multiple CDC signals.................................................................... 23
5.6 Multi-Cycle Path (MCP) formulation ................................................................................. 24
5.6.1 MCP formulation using a synchronized enable pulse ..................................................... 25
5.6.2 Closed-loop - MCP formulation with feedback .............................................................. 27
5.6.3 Closed-loop - MCP formulation with acknowledge feedback ........................................ 28
5.7 Synchronizing counters....................................................................................................... 29
5.7.1 Binary counters ................................................................................................................ 29
5.7.2 Gray codes ....................................................................................................................... 30
5.7.3 Gray-to-binary conversion ............................................................................................... 30
5.7.4 Binary-to-gray conversion ............................................................................................... 31
5.7.5 Gray code counter style #1 .............................................................................................. 32
5.7.6 Gray code counter style #2 .............................................................................................. 33
5.8 Additional multi-bit CDC techniques ................................................................................. 34
5.8.1 Multi-bit CDC signal passing using asynchronous FIFOS.............................................. 34
5.8.2 Multi-bit CDC signal passing using 1-deep / 2-register FIFO synchronizer ................... 35
6.0 Naming conventions & design partitioning ........................................................................ 36
6.1 Clock & signal naming conventions ................................................................................... 36
SNUG Boston 2008 2 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
6.1.1 Multi-clock / multi-source modules with no naming convention................................... 37
6.2 Timing verification for each clock domain......................................................................... 37
6.3 Clock oriented design partitioning...................................................................................... 37
6.3.1 Timing analysis of clock-partitioned modules................................................................. 39
6.4 Partitioning with MCP formulations................................................................................... 40
7.0 Multi-clock gate-level simulation issues ............................................................................ 41
7.1 Synchronizer gate-level CDC simulation issue .................................................................. 41
7.2 Strategies to remove X-propagation from gate-level simulations....................................... 41
7.2.1 Simulator command to turn off timing checks ................................................................ 42
7.2.2 Change flip-flop setup and hold times to 0...................................................................... 42
7.2.3 Copy and modify new flip-flop models ........................................................................... 42
7.2.4 Synopsys set_annotated_check command ....................................................................... 42
7.3 Additional strategies to remove X-propagation .................................................................. 43
7.3.1 Use multiple SDF files .................................................................................................... 43
7.3.2 Vendor synchronizer cell with supporting SDF generation tools.................................... 43
7.3.3 Vendors with built-in synchronizer support .................................................................... 44
7.4 Multiple SDF files for gate-level CDC simulations ........................................................... 44
7.5 Force synchronizer notifier inputs to a fixed value............................................................. 44
7.6 ASIC & FPGA library cell synchronizers........................................................................... 45
7.7 Simulation model with random delay insertion .................................................................. 46
8.0 Summary & conclusions ..................................................................................................... 47
8.1 Recommended 1-bit CDC techniques................................................................................. 47
8.2 Recommended multi-bit CDC techniques .......................................................................... 48
8.3 Recommended naming conventions and design partitioning ............................................. 48
8.4 Recommended solutions to multi-clock gate-level CDC simulations ................................ 48
9.0 Acknowledgements............................................................................................................. 48
10.0 References........................................................................................................................... 48
11.0 Author & Contact Information............................................................................................ 49
12.0 Appendix............................................................................................................................. 50
12.1 Common sync2 model - used by MCP formulation and FIFO synchronizer...................... 50
12.2 MCP formulation with ready-acknowledge source code .................................................... 50
12.3 Multi-bit 1-deep / 2-register FIFO synchronizer source code............................................. 55
SNUG Boston 2008 3 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
Table of Figures
SNUG Boston 2008 4 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
Table of Examples
SNUG Boston 2008 5 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
1.0 Introduction
In 2001, I presented my first paper on multi-asynchronous clock design. At that time, I had not
found any good sources to describe the design and synthesis techniques required to do proper
multi-clock design. The 2001 paper was a collection of techniques that I had gathered over years
from actual ASIC and FPGA design experiences. At the conclusion of the 2001 conference
presentation, dozens of engineers and colleagues came forward and shared with me enough
additional interesting ideas and techniques to write a sequel on the topic. Over the past eight
years, I have included instruction on multi-clock design techniques in my Advanced and Expert
Verilog and SystemVerilog training courses, and over that same period of time, more colleagues
and students have shared with me additional interesting multi-clock design techniques. Since the
release of the first multi-clock paper in 2001, the industry has largely identified these types of
design methodologies as Clock Domain Crossing (CDC) techniques. I will use this common
nomenclature in this paper.
This paper includes the best techniques described in the 2001 paper along with an updated
collection of interesting and efficient multi-clock design techniques that have been shared with
me over the past decade. The actual conference presentation slides will be mostly a collection of
the new techniques incorporated since the original 2001 presentation, retaining only enough of
the original slides to introduce the fundamental CDC design concepts and issues.
2.0 Metastability
Metastbility refers to signals that do not assume stable 0 or 1 states for some duration of time at
some point during normal operation of a design. In a multi-clock design, metastability cannot be
avoided but the detrimental effects of metastability can be neutralized.
SNUG Boston 2008 6 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
Quoting from Dally and Poulton's book[9] concerning metastability:
"When sampling a changing data signal with a clock ... the order of the events
determines the outcome. The smaller the time difference between the events, the
longer it takes to determine which came first. When two events occur very close
together, the decision process can take longer than the time allotted, and a
synchronization failure occurs."
Figure 1 shows a synchronization failure that occurs when a signal generated in one clock
domain is sampled too close to the rising edge of a clock signal from a second clock domain.
Synchronization failure is caused by an output going metastable and not converging to a legal
stable state by the time the output must be sampled again.
Figure 2 - Metastable bdat1 output propagating invalid data throughout the design
Every flip-flop that is used in any design has a specified setup and hold time, or the time in which
the data input is not legally permitted to change before and after a rising clock edge. This time
SNUG Boston 2008 7 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
window is specified as a design parameter precisely to keep a data signal from changing too close
to another synchronizing signal that could cause the output to go metastable.
3.0 Synchronizers
When passing signals between clock domains, an important question to ask is, do I need to
sample every value of a signal that is passed from one clock domain to another?
First scenario: sometimes it is not necessary to sample every value, but it is important that the
sampled values are accurate. One example is the set of gray code counters used in a standard
asynchronous FIFO design. In a properly designed asynchronous FIFO model, synchronized gray
code counters do not need to capture every legal value from the opposite clock domain, but it is
critical that sampled values be accurate to recognize when full and empty conditions have
occurred.
Second scenario: a CDC signal must be properly recognized or recognized and acknowledged
before a change is permitted on the CDC signal.
In both of these scenarios, the CDC signals will require some form of synchronization into the
receiving clock domain.
The first flip-flop samples the asynchronous input signal into the new clock domain and waits for
a full clock cycle to permit any metastability on the stage-1 output signal to decay, then the stage-
1 signal is sampled by the same clock into a second stage flip-flop, with the intended goal that
the stage-2 signal is now a stable and valid signal synchronized and ready for distribution within
the new clock domain.
SNUG Boston 2008 8 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
Figure 3 - Two flip-flop synchronizer
It is theoretically possible for the stage-1 signal to still be sufficiently metastable by the time the
signal is clocked into the second stage to cause the stage-2 output signal to also go metastable.
The calculation of the probability of the time between synchronization failures (MTBF) is a
function of multiple variables including the clock frequencies used to generate the input signal
and to clock the synchronizing flip-flops. One description of the MTBF calculation can be found
in Dally and Poulton[9].
For most synchronization applications, the two flip-flop synchronizer is sufficient to remove all
likely metastability.
When calculating MTBF numbers, larger numbers are preferred over smaller numbers. Larger
MTBF numbers indicate longer periods of time between potential failures, while smaller MTBF
SNUG Boston 2008 9 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
numbers indicate that metastability could happen frequently, similarly causing failures within the
design.
Dally and Poulton[9] give a good equation with very thorough analysis of the calculation that can
be performed to calculate the MTBF of a synchronizer circuit. Without repeating the equation
and analysis, it should be pointed out that two of the most important factors that directly impact
the MTBF of a synchronizer circuit are, the sample clock frequency (how fast are signals being
sampled into the receiving clock domain) and the data change frequency (how fast is the data
changing that crosses the CDC boundary).
From the above partial equation, it can be seen that failures occur more frequently (shorter
MTBF) in higher speed designs, or when the sampled data changes more frequently.
For some very high speed designs, the MTBF of a two-flop synchronizer is too short and a third
flop is added to increase the MTBF to a satisfactory duration of time. Of course, satisfactory is
determined by the architect of the design.
SNUG Boston 2008 10 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
Consider an example where the signals in the sending clock domain are not registered before
being passed into the receiving clock domain, as shown in Figure 6.
In this example, the combinational output from the sending clock domain could experience
combinational settling at the CDC boundary. This combinational settling effectively increases the
data-change frequency potentially creating small bursts of oscillating data and thereby increasing
the number of edges that could be sampled while changing, with a corresponding increase in the
potential for sampling changing data and generating metastable signals.
Signals in the sending clock domain should be synchronized before being passed to a CDC
boundary. The synchronization of signals from the sending clock domain reduces the number of
edges that can be sampled in the receiving clock domain, effectively reducing the data-change
frequency in the MTBF equation and hence increasing the time between calculated failures (see
section 3.3 for a description of the impact of data change frequencies on MTBF).
SNUG Boston 2008 11 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
Figure 7 - Registered signals sent across a CDC boundary
In Figure 7, the aclk logic settles and sets up on the adat flip-flop before being passed into the
bclk domain. The adat flip-flop filters out the combinational settling on the flip-flop input (a)
and passes a clean signal to the bclk logic.
SNUG Boston 2008 12 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
4.0 Synchronizing fast signals into slow clock domains
As discussed in section 3.1, if a CDC signal cannot be skipped when passed between clock
domains, it is important to consider signal widths or synchronization techniques when they are
passed between clock domains.
One issue associated with synchronizers is the possibility that a signal from a sending clock
domain might change values twice before it can be sampled, or might be too close to the
sampling edges of a slower clock domain. This possibility must be considered any time signals
are sent from one clock domain to another and a determination must be made whether missed
signals are or are not a problem for the design in question.
When missed samples are not allowed, there are two general approaches to the problem:
(1) An open-loop solution to ensure that signals are captured without acknowledgment.
(2) A closed-loop solution that requires acknowledgement of receipt of the signal that crosses a
CDC boundary.
Both solutions are discussed in this section.
For exceptionally long source and destination clock frequencies, this requirement could probably
be safely relaxed to 1-1/4 times the cycle time of the receiving clock domain or less, but the
"three edge" guideline is the safest initial design condition, and is easier to prove through the use
of SystemVerilog assertions than to dynamically measure a fractional width of a CDC signal
during simulation.
The "three edge" requirement actually applies to both open-loop and closed-loop solutions, but
implementations of the closed-loop solution automatically ensure that at least three edges are
detected for all CDC signals.
SNUG Boston 2008 13 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
4.2 Problem - passing a fast CDC pulse
Consider the severely flawed condition where the sending clock domain has a higher frequency
than the receiving clock domain and that a CDC pulse is only one cycle wide in the sending clock
domain. If the CDC signal is only pulsed for one fast-clock cycle, the CDC signal could go high
and low between the rising edges of a slower clock and not be captured into the slower clock
domain as shown in Figure 8.
SNUG Boston 2008 14 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
4.3 Problem - sampling a long CDC pulse - but not long enough!
Consider the somewhat non-intuitive and flawed condition where the sending clock domain
sends a pulse to the receiving clock domain that is slightly wider than the period of the receiving
clock frequency. Under most conditions, the signal will be sampled and passed, but there is the
small but real chance that the CDC pulse will change too close to the two rising clock edges of
the receiving clock domain and thereby violate the setup time on the first clock edge and violate
the hold time of the second clock edge and not form the anticipated pulse. This possible failure is
shown in Figure 9.
Figure 9 - Marginal CDC pulse that violates the destination setup and hold times
SNUG Boston 2008 15 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
4.4 Open-loop solution - sampling signals with synchronizers
One potential solution to this problem is to assert CDC signals for a period of time that exceeds
the cycle time of the sampling clock as shown in Figure 10. As discussed in section 4.1.1, the
minimum pulse width is 1.5X the period of the receiving clock frequency. The assumption is that
the CDC signal will be sampled at least once and possibly twice by the receiver clock.
Open-loop sampling can be used when relative clock frequencies are fixed and properly
analyzed.
Advantage: the Open-loop solution is the fastest way to pass signals across CDC boundaries that
does not require acknowledgement of the received signal.
Disadvantage: the largest potential problem related to an open-loop solution is that another
engineer might mistake the solution for a general purpose solution, or the design requirements
might change and an engineer might fail to re-analyze the original open loop solution. This
problem can be minimized by adding a SystemVerilog Assertion to the model to detect if the
input pulse ever fails to exceed the "three edges" design requirement.
Figure 10 - Lengthened pulse to guarantee that the control signal will be sampled
SNUG Boston 2008 16 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
4.5 Closed loop solution - sampling signals with synchronizers
A second potential solution to this problem is to send an enabling control signal, synchronize it
into the new clock domain and then pass the synchronized signal back through another
synchronizer to the sending clock domain as an acknowledge signal.
Advantage: synchronizing a feedback signal is a very safe technique to acknowledge that the
first control signal was recognized and sampled into the new clock domain.
SNUG Boston 2008 17 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
5.0 Passing multiple signals between clock domains
When passing multiple signals between clock domains, simple synchronizers do not guarantee
safe delivery of the data.
A frequent mistake made by engineers when working on multi-clock designs is passing multiple
CDC bits required in the same transaction from one clock domain to another and overlooking the
importance of the synchronized sampling of the CDC bits.
The problem is that multiple signals that are synchronized to one clock will experience small
data changing skews that can occasionally be sampled on different rising clock edges in a second
clock domain. Even if we could perfectly control and match the trace lengths of the multiple
signals, differences in rise and fall times as well as process variations across a die could
introduce enough skew to cause sampling failures on otherwise carefully matched traces.
Multi-bit CDC strategies must be employed to avoid skewed sampling of the multi-bit value.
(1) Multi-bit signal consolidation. Where possible, consolidate multiple CDC bits into 1bit CDC
signals.
(2) Multi-cycle path formulations. Use a synchronized load signal to safely pass multiple CDC
bits.
(3) Pass multiple CDC bits using gray codes.
Simply using synchronizers on all of the CDC bits is not always good enough as will be shown in
the following examples.
If the order or alignment of the control signals is significant, care must be taken to correctly pass
the signals into the new clock domain. All of the examples shown in this section are overly
simplistic but they closely mimic situations that often arise in real designs.
SNUG Boston 2008 18 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
5.3 Problem - Two simultaneously required control signals.
In the simple example shown in Figure 12, a register in the receiving clock domain requires both
a load signal and an enable signal in order to load a data value into the register. If both the load
and enable signals are driven on the same sending clock edge, there is a chance that a small skew
between the control signals could cause the two signals to be synchronized into different clock
cycles within the receiving clock domain. Under these conditions, the data would not be loaded
into the register.
SNUG Boston 2008 19 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
5.3.1 Solution - Consolidation
The solution to the problem in section 5.3 is simple, consolidate the control signals. As shown in
Figure 13, drive both the load and enable register input signals in the receiving clock domain
from just one load-enable signal. Consolidation will remove the potential of two control signals
arriving shifted in time.
Figure 13 - Solution - Consolidating control signals before passing between clock domains
SNUG Boston 2008 20 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
5.4 Problem - Two phase-shifted sequencing control signals.
The diagram in Figure 14, shows two enable signals, aen1 and aen2, that are sequentially driven
from a sending clock domain into the receiving clock domain to control the enable inputs of
pipelined data registers. The problem is that in the first clock domain, the aen1 control signal
might terminate slightly before the aen2 control signal is generated, and the rising edge of the
receiving clock might occur in the slight gap between the aen1 and aen2 control signal pulses,
causing a one-cycle gap to form in the enable control-signal chain in the receiving clock domain.
This would cause the a2 data value to be missed by the second register.
SNUG Boston 2008 21 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
5.4.1 Solution - consolidation and an extra flip-flop
The solution to this problem, as shown in Figure 15, is to send only one control signal into the
receiving clock domain and generate the second phase-shifted pipelined enable signal within the
receiving clock domain.
Figure 15 - Solution - Logic to generate proper sequencing signals in the new clock domains
SNUG Boston 2008 22 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
5.5 Problem - Multiple CDC signals
The diagram in Figure 16 shows two encoded control signals being passed between clock
domains. If the two encoded signals are slightly skewed when sampled, an erroneous decoded
output could be generated for one clock period in the receiving clock domain.
There are at least two Multi-Cycle Path (MCP) formulations that can be used to fix this problem:
(1) Closed-loop - MCP formulation with feedback.
(2) Closed-loop - MCP formulation with acknowledge feedback.
The MCP formulation implementation techniques are described starting in the next section.
There are also at least two FIFO strategies that act as closed loop solutions to this problem:
(1) Asynchronous FIFO implementation.
(2) 2-deep FIFO implementation.
The FIFO implementation techniques are described starting in section 5.8.
SNUG Boston 2008 23 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
Figure 17 - Logic to pass a synchronized enable pulse between clock domains
An MCP formulation refers to sending unsynchronized data to a receiving clock domain paired
with a synchronized control signal. The data and control signals are sent simultaneously allowing
the data to setup on the inputs of the destination register while the control signal is synchronized
for two receiving clock cycles before it arrives at the load input of the destination register.
Advantages:
(1) The sending clock domain is not required to calculate the appropriate pulse width to send
between clock domains.
(2) The sending clock domain is only required to toggle an enable into the receiving clock
domain to indicate that data has been passed and is ready to be loaded. The enable signal is
not required to return to its initial logic level.
This strategy passes multiple CDC signals without synchronization, and simultaneously passes a
synchronized enable signal to the receiving clock domain. The receiving clock domain is not
allowed to sample the multi-bit CDC signals until the synchronized enable passes through
synchronization and arrives at the receiving register.
SNUG Boston 2008 24 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
This strategy is called a Multi-Cycle Path Formulation[8] due to the fact that the unsynchronized
data word is passed directly to the receiving clock domain and held for multiple receiving clock
cycles, allowing an enable signal to be synchronized and recognized into the receiving clock
domain before permitting the unsynchronized data word to change.
Because the unsynchronized data is passed and held stable for multiple clock cycles before being
sampled, there is no danger that the sampled value will go metastable.
A key feature of this synchronized enable pulse generation is that the polarity of the input signal
does not matter. In Figure 18, the d-input is toggled high in cycle 1 and by cycle 4 a high signal
has propagated through the three synchronizing flip-flops. In cycle 3 the outputs of the q2 and q3
flip-flops have a different polarity causing the synchronized enable pulse to form on the output of
the exclusive-or gate in that same cycle. Similarly, the d-input is toggled low in cycle 7 and by
cycle 10 a high signal has propagated through the three synchronizing flip-flops. And again in
cycle 9 the outputs of the q2 and q3 flip-flops have a different polarity causing the synchronized
enable pulse to form on the output of the exclusive-or gate.
SNUG Boston 2008 25 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
Figure 19 - Synchronized enable pulse generation logic and equivalent symbol
In addition to generating a pulse off of any d-input polarity, the synchronized enable pulse
generation circuit also has a q-output that follows the d-input delayed by three clock cycles. The
q-output is frequently used as a feedback signal and passed as an acknowledge signal through
another synchronized enable pulse generation circuit in the sending clock domain.
Using this technique, it is required that the receiving clock domain have logic in place to capture
the data when the pulse is detected, because the pulse will only be valid for one receiving clock
cycle per multi-cycle data word.
SNUG Boston 2008 26 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
5.6.2 Closed-loop - MCP formulation with feedback
An important technique when using an MCP formulation is to pass the enable signal back to the
sending clock domain as an acknowledge signal as shown in Figure 21.
For the example in Figure 21, the acknowledge feedback signal (b_ack) generates an
acknowledge pulse (aack) that is used as an input to a small READY-BUSY, 1-state FSM block
that generates a ready signal (aready) to indicate that it is now safe to change the data input
(adatain) value again. Once the aready signal goes high, the sender is free to send new data
(adatain) and the accompanying asend control signal.
This is an automatic feedback path that assumes that the receiving clock domain will always be
ready for the next data word synchronized through an MCP formulation.
SNUG Boston 2008 27 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
5.6.3 Closed-loop - MCP formulation with acknowledge feedback
A fully responsive variation of the technique described in section 5.6.2 uses an MCP formulation
is to pass the enable signal back to the sending clock domain as an acknowledge signal only after
the receiving clock domain acknowledges receipt of the data with a bload pulse as shown in
Figure 22.
For the example in Figure 22, the receiving clock domain has a small WAIT-READY, 1-state FSM
that sends a valid signal (bvalid) to the receiving logic when data is valid on the input to the
data register. The data is not actually loaded until the receiving logic acknowledges that the data
should be loaded by asserting the bload signal. There is no feedback to the sending clock
domain until the data has been loaded, then the b_ack signal is sent back the same as the MCP
formulation with automatic feedback.
This is an feedback path requires action on the part of the receiving clock domain before data is
captured and feedback is sent.
SNUG Boston 2008 28 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
5.7 Synchronizing counters
As mentioned earlier, when passing multiple signals between clock domains, an important
question to ask is, do I need to sample every value of a signal that is passed from one clock
domain to another? With counters, the answer is frequently, no!
Reference [1] details FIFO design techniques where gray code counters are sampled between
clock domains and intermediate gray count values are often missed. For this FIFO design, the
greater consideration is to make sure that the counters cannot overrun their boundaries, which
could cause missed full and empty flag detection. Even though the sampled gray count values
between clock domains are often missed, the design is robust and all important gray count values
are appropriately sampled. See [1] for details.
Since a valid design might be allowed to skip some count value samples, can any counter be used
to pass count values across a CDC boundary? The answer is no.
SNUG Boston 2008 29 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
overflow or causing invalid data to be read from the FIFO due to an attempt to read data when
the FIFO is really empty.
Standard gray codes have very nice translation properties to convert gray-to-binary and back
again. Using these conversions, it is simple to design efficient gray code counters.
The equations for a sample 4-bit gray-to-binary conversion are shown in Figure 24.
bin[0] = gray[3] ^ gray[2] ^ gray[1] ^ gray[0];
bin[1] = gray[3] ^ gray[2] ^ gray[1];
bin[2] = gray[3] ^ gray[2];
bin[3] = gray[3];
Figure 24 - 4-bit gray-to-binary conversion equations
The easiest way to code a gray-to-binary converter is to code a for-loop and do an exclusive-or
reduction on a gray code vector with variable index range, where each time through the loop the
LSB of the index range increases until we are left with a simple assignment of bin[MSB] =
^gray[MSB:MSB] (just the 1-bit MSB of the gray code vector), as shown in Example 1.
module gray2bin_bad #(parameter SIZE = 4)
(output logic [SIZE-1:0] bin,
input logic [SIZE-1:0] gray);
Unfortunately, Verilog and SystemVerilog do not permit part selects using a variable index range
so the code in Example 1, although conceptually correct, will not compile.
SNUG Boston 2008 30 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
To address this issue, remember that an exclusive-or gate is really a programmable inverter. If
one input is tied high, the other input is inverted and passed to the output. Similarly, if one input
is tied low, the other input is passed to the output without inversion (no change from input to
output).
Taking advantage of the fact that any added exclusive-or operation that involves a 0-input does
not change the outcome of the operation, the way to approach of a gray-to-binary conversion is to
exclusive-or the significant gray-code bits with padded 0's as shown in Figure 25.
bin[0] = gray[3] ^ gray[2] ^ gray[1] ^ gray[0] ; // gray>>0
bin[1] = 1'b0 ^ gray[3] ^ gray[2] ^ gray[1] ; // gray>>1
bin[2] = 1'b0 ^ 1'b0 ^ gray[3] ^ gray[2] ; // gray>>2
bin[3] = 1'b0 ^ 1'b0 ^ 1'b0 ^ gray[3] ; // gray>>3
Figure 25 - 4-bit gray-to-binary conversion equations - 2nd method
The corresponding parameterized SystemVerilog model for this simplified algorithm is shown in
Example 2. This example is syntactically correct, will compile and does work.
module gray2bin #(parameter SIZE = 4)
(output logic [SIZE-1:0] bin,
input logic [SIZE-1:0] gray);
always_comb
for (int i=0; i<SIZE; i++)
bin[i] = ^(gray>>i);
endmodule
Example 2 - Parameterized and correct gray-to-binary SystemVerilog model
What happens to all of the extra exclusive-or operations with inputs tied to 0? Synthesis tools
recognize that exclusive-or gates with a constant-0 on one input can be optimized away to infer a
very efficient implementation of the design.
The equations for a sample 4-bit binary-to-gray conversion are shown in Figure 26.
gray[0] = bin[0] ^ bin[1];
gray[1] = bin[1] ^ bin[2];
gray[2] = bin[2] ^ bin[3];
gray[3] = bin[3] ^ 1'b0 ; // same as gray[3] = bin[3];
Figure 26 - 4-bit binary-to-gray conversion equations
SNUG Boston 2008 31 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
The easiest way to code a binary-to-gray converter is to code a simple continuous assignment that
performs a bit-wise exclusive-or operation between the binary vector and a right-shifted version
of the same binary vector as shown in
Example 3. This example is syntactically correct, will compile and does work.
module bin2gray #(parameter SIZE = 4)
(output logic [SIZE-1:0] gray,
input logic [SIZE-1:0] bin);
The SystemVerilog code for gray-code counter style #1 incorporates a gray-to-binary converter, a
binary-to-gray converter and increments the binary value between conversions as shown in
Figure 27.
Figure 27 - Gray code counter style #1 - only one gray code register
The corresponding parameterized SystemVerilog model for the gray-code counter style #1 is
shown in Example 4.
SNUG Boston 2008 32 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
module graycntr #(parameter SIZE = 5)
(output logic [SIZE-1:0] gray,
input logic clk, inc, rst_n);
always_comb begin
for (int i=0; i<SIZE; i++)
bin[i] = ^(gray>>i);
bnext = bin + inc;
gnext = (bnext>>1) ^ bnext;
end
endmodule
Example 4 - Parameterized gray-code counter SystemVerilog model
Figure 28 - Gray code counter style #2 - binary register and gray code register
The SystemVerilog code for gray-code counter style #2 incorporates a binary counter to eliminate
the need for the gray-to-binary conversion, and uses the next binary count value to do the binary-
to-gray conversion that is then registered into the gray code register. This style uses twice as
SNUG Boston 2008 33 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
many flip-flops but a shorter combinational logic path to generate the next gray code value,
which makes this implementation faster than gray code counter style #1. The block diagram for
gray code counter style #2 is shown in Figure 28,
The corresponding parameterized SystemVerilog model for the gray-code counter style #2 is
shown in Example 5.
There are at least two interesting FIFO implementation strategies that can be used to address
multi-bit CDC signal integrity:
(1) Asynchronous FIFO implementations.
(2) 2-deep FIFO implementation.
A standard asynchronous FIFO device allows multiple data or control words to be inserted as
long as the FIFO is not full, and the receiver and then extract multiple data or control words
when convenient as long as the FIFO is not empty.
Most of the hard work in a FIFO design is done through the synchronization of gray code
counters and a proven FIFO design technique is described in [1].
SNUG Boston 2008 34 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
5.8.2 Multi-bit CDC signal passing using 1-deep / 2-register FIFO synchronizer
Another interesting variation on passing multiple control and data bits across CDC boundaries
involves the use of a 1-deep two register FIFO as shown in Figure 29.
This 1-deep two register FIFO has a number of interesting characteristics. Since the FIFO is built
using only two registers or a 2-deep dual port RAM, the gray code counters used to detect full
and empty are simple toggle flip-flops, which is really nothing more than 1-bit binary counters
(remember, the MSB of a standard gray code is the same as the MSB of a binary code).
On reset, both pointers are cleared and the FIFO is empty and hence the FIFO is not full. We use
the inverted not-full condition to indicate that the FIFO is ready to receive a data or control word
(wrdy is high). After a data or control word is put into the FIFO (using wput), the wptr toggles
and the FIFO becomes full, or in other words, the wrdy signal goes low, which also disables the
ability to toggle the wptr and therefore also disables the ability to put another word into the 2-
register FIFO until the first word is removed from the FIFO by the receiving clock-domain logic.
What is especially interesting about this design is that the wptr is now pointing to the second
location in the 2-register FIFO, so when the FIFO does again become ready (when wrdy is high),
the wptr is already pointing to the next location to write.
The same concept is replicated on receiving side of the FIFO. When a data or control word is
written into the FIFO, the FIFO becomes not empty. We use the inverted not-empty condition to
indicate that the FIFO is has a data or control word that is ready to be received (rrdy is high).
By using two registers to store the multi-bit CDC values, we are able to remove one clock cycle
from the send MCP formulation and another cycle from the acknowledge feedback path.
SNUG Boston 2008 35 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
6.0 Naming conventions & design partitioning
Naming conventions help to ensure good team communication and also facilitate the use of
scripting languages to gather and group all signals in a design that are associated with a particular
clock. Good design partitioning can significantly reduce the effort to synthesize and verify the
timing of a multi-clock design. Recommended naming conventions and design partitioning are
discussed in this section.
There are two approaches to address potential CDC problems: (1) verify that the design meets
qualified CDC rules, (2) avoid the problem. Both approaches are valuable and should be used to
ensure an error-free design.
The first approach, verification of CDC design rules, typically requires the use of special tools to
check the design for possible CDC violations. When I wrote my first paper on multi-clock design
in 2001, I was unaware of any tool on the market that performed checking of CDC rules. Today
there are a number of companies that provide such tools (see [11] for a list of companies and
tools in the CDC verification space).
The second approach, avoid the problem, can be done by employing a few good coding
guidelines as outlined below.
Guideline: Use a clock naming convention to identify the clock source of every signal in a
design.
Reason: A naming convention helps all team members to identify the clock domain for every
signal in a design and also makes grouping of signals for timing analysis easier to do using
regular expression "wild-carding" from within a synthesis script.
One proven naming convention requires that a leading prefix character be used to identify the
various asynchronous clock domains. Examples included: uClk for the microprocessor clock,
vClk for the video clock and dClk for the display clock.
Each signal is then synchronized to one of the clock domains in the design and each signal-name
is labeled with a prefix character to identify the clock domain used to generate that signal. For
example, any signal that is generated by the uClk is labeled with a u-prefix in the signal name,
such as uaddr, udata, uwrite, etc. Any signal that is generated by the vClk is similarly
labeled with a v-prefix in the signal name, such as vdata, vhsync, vframe, etc. The same
signal naming convention is used for all signals generated by any of the other clocks in the
design.
SNUG Boston 2008 36 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
Using this technique, any engineer on the design team can easily identify the clock-domain
source of any signal in the design and either use the signals directly or pass the signals through
proper synchronization so that the signals can be used within a new clock domain.
The exact naming convention is not important, but it is vital that every engineer on the project
agrees to adhere to the naming convention chosen by the team. A naming convention will
significantly contribute to the productivity of the design team.
Even if your team has access to good CDC analysis tools, I strongly recommend that you take a
few simple steps to make analysis and recognition of potential CDC design problems easier to
identify and debug.
By partitioning a design to permit only one clock per module, static timing analysis becomes a
significantly easier task for each domain in the design.
Reason: Static timing analysis and creating synthesis scripts is more easily accomplished on
single-clock modules or groups of single-clock modules.
Exception: The top-level module that connects together the signals from all of the different
clock domains will naturally have all of the clocks as inputs to this module. Minimize your
multi-clock verification effort and only allow the top-module to have multiple clock inputs.
Reason: The timing verification of completely synchronous sub-blocks can be easily verified
using STA (Static Timing Analysis) tools and partitioning the design blocks into multiple one-
SNUG Boston 2008 37 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
clock domain sub-blocks turns a large complicated timing analysis task into multiple, completely
synchronous, one-clock designs.
Guideline: Create synchronizer modules to pass signals from one clock domain into another
clock domain and only allow one clock per synchronizer module.
Reason: It is given that any signal passing from one clock domain to another clock domain will
eventually experience setup and hold time problems. Isolating the CDC boundary logic can
significantly reduce the design and verification effort of multi-clock designs.
Under most conditions, the synchronizer modules will be the only blocks in the design that will
experience intentional setup and hold time violations. When passing signals between
asynchronous clock domains, it is given that timing violations will occur, that is the whole reason
why synchronizers must be added to a design.
Consider an example design with three clock domains, labeled aClk, bClk and cClk and shown
in Figure 30. In this design, all of the aClk design blocks have been grouped into a single aClk
Logic block. All of the bClk design blocks have been grouped into a single bClk Logic block
and similarly we have created a cClk Logic block. Any signal that originates in an asynchronous
SNUG Boston 2008 38 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
clock domain passes through a synchronizer module before it is permitted to drive an input of
another Logic block.
Group together all design modules that are clocked within each clock domain. One group should
be formed for each clock domain in the design. These groups will be timing verified as if each
were a separate, completely synchronous design. For each clock domain, we have a single design
block and we can easily perform worst-case (max-time / setup time checking) timing analysis,
and best-case (min-time / hold time checking) timing analysis.
Also using this clock-oriented partitioning strategy, each of the CDC boundaries has been
isolated using a synchronizer module. Each synchronizer module only includes either
synchronizer cells provided by the ASIC or FPGA vendor (preferred), or is built using flip-flops
connected as pairs to form synchronizer-equivalent cells.
If synchronizer cells are available from the ASIC or FPGA vendor, and instantiated into the
design, there will be no need to verify setup and hold times on these modules, since the vendor
should have already created a cell layout that does not violate setup or hold times between the
flip-flop stages.
If the synchronizers are synthesized from RTL code, it is most important to perform best-case
timing analysis to make sure that the flip-flops are not placed too close together in such a way
that the output from the first stage might change too quickly to satisfy the hold time requirement
of the input of the second stage. A colleague recently pointed out that worst-case timing analysis
should also be performed just in case the layout tools happen to place the two synchronizer flip-
flops far apart on the ASIC or FPGA die. I agree with this updated recommendation.
Because of the partitioning of the separate synchronizers, gate-level simulations can more easily
be configured to ignore setup and hold time violations on the first stage of each synchronizer
The static timing analysis of the RTL synchronizers requires simple set_false_path commands to
remove the inputs from the STA. We know that there are timing problems at the inputs of the
synchronizers, that is why the synchronizers are used.
By partitioning design and synchronizer blocks to permit only one clock per module, static
timing analysis becomes a significantly easier task to perform. Synthesis script commands used
to address multiple clock domain issues now become a matter of grouping, identifying false paths
and performing min-max timing analysis.
SNUG Boston 2008 39 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
6.4 Partitioning with MCP formulations
Partitioning a design at clock boundaries into separate design blocks and synchronizer blocks
works well most of the time, but if multiple signals need to be passed between clock domains
using an MCP formulation, then some of the signals that are passed to a design block may come
from a different clock domain as shown in Figure 31.
In general, only the inputs to the synchronizers and MCP formulation data paths require
"set_false_path" commands. If a clock-prefix naming scheme is used, then wild-cards can be
used to easily identify all asynchronous inputs. In Figure 31, to exclude the adata bus from STA
within the bClk Logic block, first execute the command:
set_false_path -from { a* }
This command should be sufficient to eliminate all asynchronous inputs from bClk STA.
SNUG Boston 2008 40 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
7.0 Multi-clock gate-level simulation issues
Digital simulation models typically generate X's when synchronizers recognize setup and hold
time violations on CDC signals. This can frequently cause gate-level simulations to fail. What
techniques exist to address this problem?
As mentioned in section 6.3.1, signals crossing clock boundaries through a synchronizer will
experience setup and hold violations. That is why synchronizers are added to a design, to filter
out the metastability effects of a signal that changes too close to the rising edge of a receiving
clock domain clock signal.
SNUG Boston 2008 41 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
Since X-propagation happens when a setup or hold time is violated, almost all of the approaches
to address this issue involve changing the setup and hold times to 0 so that there can be no setup
or hold time violation, and hence, no X-propagation.
Some of the approaches are bad and others are good. Below are some of the strategies that have
been considered to address the X-propagation problem.
SNUG Boston 2008 42 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
Using a creative naming convention for the output of the first stage flip-flop of a synchronizer
might make wild card expressions possible to easily backannotate all first stage flip-flop SDF
setup and hold time values to zero using very few dc_shell-t commands.
This technique works if the design is being done with Synopsys DesignCompiler tools, but what
about non-Synopsys flows?
Since then, other engineers from many companies have shared additional techniques. Those
techniques are described in this section and I am very grateful to all the engineers who continue
to share interesting techniques with me each year. Kudos to you all!
Many engineers have told me that they actually generate two SDF files. The first SDF file has all
of the actual delays, including accurate setup and hold times, for the entire design. Then
engineers generate a second SDF file with only the first stage flip-flops included in the file. In
this file, the setup and hold times are set to 0. Some engineers build this file by hand and other
generated this file using scripts.
Engineers then read in the first SDF file using the $sdf_annotate command. Then they read in the
second SDF file, which overwrites the setup and hold times for the data inputs of the first stage
synchronizers. When reading in the two SDF files, last SDF file for each instance wins. All
timing was accurately annotated, and then the timing checks for the first stage synchronizers
were modified.
This is a clever technique that can be used with any tools flow that generates SDF files.
SNUG Boston 2008 43 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
This technique requires that a separate synchronizer cell be created with proper placement
relationship between the two flip-flop stages. To make this method work, the vendor must
provide:
(1) the actual synchronizer cell - these will be instatiated into the design.
(2) the SystemVerilog model for the synchronizer cell for simulation.
(3) SDF file generation tools that will generate an SDF file with 0-setup and 0-hold for the
synchronizer cells.
If a vendor can provide this cell and these capabilities, it will only be necessary to generate a
single SDF file with proper timing checks for the synchronizer cells.
Any ASIC of FPGA vendor who provides this capability is doing a huge favor for their customer
base. I have heard that some ASIC vendors provide this capability. I do not know of any FPGA
vendor who provides this capability. Recognizing that most modern designs are multi-clock
designs, I strongly urge all ASIC and even all FPGA vendors to provide synchronizer cells with
appropriate simulation and SDF file tool support.
Vendor list:
(No vendors listed as of this release of this paper)
The technique involved writing out the full SDF timing file and then either manually or by using
a script, generate a second SDF file for just the first-stage flip-flops of all synchronizer modules.
The second SDF file set all setup and hold times to 0 and then the two SDF files are applied to
the design using $sdf_annotate commands. The first SDF file annotates all of the actual timing to
the entire design and then the second SDF file is read to over-write the setup and hold times for
the first stage synchronizers.
The advantage of this technique is that it can be used for all designs using all tools, not just
Synopsys ASIC designs. This is a highly recommended technique.
SNUG Boston 2008 44 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
Most ASIC and FPGA flip-flop models are built from Verilog User Defined Primitives (UDPs)
and the notifier signal is typically listed as one of the inputs to the UDP table. Whenever the
notifier input toggles (caused by a timing violation), the flip-flop output goes unknown and that
unknown is what is visible on the output of the gate-level flip-flop models. The notifier on these
first-stage flip-flop models can be force to a logic level to prevent them from toggling and
causing the flip-flop outputs to go unknown during simulation.
One clever technique used by at least one company forces the timing violation notifiers of the
first-stage synchronizer flip-flops to be forced to one logic level so they can never toggle and
trigger X's into the flip-flop models.
I know of no FPGA provider that provides this capability, but a forward thinking FPGA provider
would provide such cells for their advanced multi-clock design customers.
SNUG Boston 2008 45 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
7.7 Simulation model with random delay insertion
An interesting model that synthesizes to the correct synchronizer for design, but simulates with
random cycle delays has been suggested by multiple colleagues.
The block diagram for the model is shown in Figure 33, and the SystemVerilog code to support
this model is shown in Example 6.
Figure 33 - Sample ASIC & FPGA synchronizer cell for synthesis and simulation
As can be seen in the block diagram, the model is designed to produce either a synthesizble
synchronizer model or to be used as a simulation model with selectable delays.
The IEEE Std 1364.1-2002 Verilog RTL Synthesis Standard[6] requires that a compliant
synthesis tool set the SYNTHESIS macro before reading in any Verilog models. Although most
synthesis tools have largely ignored many of the requirements of the IEEE Verilog synthesis
standard, most tools have implemented this nice SYNTHESIS macro requirement.
Tools that set the SYNTHESIS macro before reading this sync2 SystemVerilog code will select
the code to infer the two flip-flop synchronizer.
Simulators, which do not set the SYNTHESIS macro, will read the sync2 model, ignore the code
intended for a synthesizable model and will simulate the model in the `else portion of the code.
SNUG Boston 2008 46 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
The model is parameterized so the same model can be used with the default parameter SIZE of
1-bit in width for simple 1-bit CDC signals, or the model can be instantiated with the SIZE
parameter set to a multi-bit width so that the synchronizer can be used to capture and synchronize
multi-bit buses such as gray code counters.
`ifdef SYNTHESIS
logic [SIZE-1:0] q1;
`else
logic [SIZE-1:0] y1, q1a, q1b;
logic [SIZE-1:0] DLY = '0;
SNUG Boston 2008 47 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
8.2 Recommended multi-bit CDC techniques
When passing multiple control or data signals between clock domains, use one of the following
strategies:
• Consolidate - first attempt to combine multiple signals into a 1-bit representation in the
sending clock domain before synchronizing the signal into the receiving domain.
• Use Multi-Cycle Path (MCP) formulations to pass multiple signals across clock domains
• Use FIFOs to pass multi-bit buses, either data or control buses.
• Use gray code counters.
As much as possible, partition the design sub-blocks into completely synchronous 1-clock
designs.
The techniques described in this paper were designed to facilitate robust development and
verification of multi-clock designs.
9.0 Acknowledgements
My thanks to the hundreds of colleagues and students who have shared interesting multi-
asynchronous clock CDC design techniques over the past eight years.
10.0 References
[1] Clifford E. Cummings, “Simulation and Synthesis Techniques for Asynchronous FIFO Design,”
SNUG 2002 - www.sunburst-design.com/papers/CummingsSNUG2002SJ_FIFO1.pdf
[2] Clifford E. Cummings, “Synthesis and Scripting Techniques for Designing Multi-Asynchronous
Clock Designs,” SNUG 2001 -
www.sunburst-design.com/papers/CummingsSNUG2001SJ_AsyncClk.pdf
SNUG Boston 2008 48 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
[3] Don Mills & Clifford E. Cummings, “RTL Coding Styles That Yield Simulation and Synthesis
Mismatches” SNUG 1999 -
www.sunburst-design.com/papers/CummingsSNUG1999SJ_SynthMismatch.pdf
[4] Frank Gray, "Pulse Code Communication." United States Patent Number 2,632,058. March 17,
1953.
[5] Himanshu Bhatnagar, Advanced ASIC Chip Synthesis, Second Edition, Kluwer Academic
Publishers, 2002.
[6] "IEEE Std. 1364.1 - 2002 IEEE Standard for Verilog Register Transfer Level Synthesis," IEEE
Computer Society, IEEE, New York, NY, IEEE Std 1364.1-2002
[7] Mark Litterick, “Pragmatic Simulation-Based Verification of Clock Domain Crossing Signals and
Jitter Using SystemVerilog Assertions,” DVCon 2006
www.verilab.com/files/sva_cdc_paper_dvcon2006.pdf
[8] Real Intent, Inc. (white paper), “Clock Domain Crossing Demystified: The Second Generation
Solution for CDC Verification,” February 2008 - www.realintent.com
[9] Steve Golson, personal communication
[10] William J. Dally and John W. Poulton, Digital Systems Engineering, Cambridge University Press,
1998
[11] Wikipedia: http://en.wikipedia.org/wiki/Clock_Domain_Crossing_Verification
Mr. Cummings has presented more than 80 SystemVerilog seminars and training classes in the
past five years and was the featured speaker at the world-wide SystemVerilog NOW! seminars.
Mr. Cummings has participated on every IEEE & Accellera SystemVerilog, SystemVerilog
Synthesis, SystemVerilog committee, and has presented more than 40 papers on SystemVerilog
& SystemVerilog related design, synthesis and verification techniques.
Mr. Cummings holds a BSEE from Brigham Young University and an MSEE from Oregon State
University.
Sunburst Design, Inc. offers World Class Verilog & SystemVerilog training courses. For more
information, visit the www.sunburst-design.com web site.
Email address: cliffc@sunburst-design.com
An updated version of this paper can be downloaded from the web site: www.sunburst-
design.com/papers
(Last updated September 26, 2008)
SNUG Boston 2008 49 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
12.0 Appendix
This appendix includes the source code for the MCP formulation with acknowledge feedback
and the 1-deep, 2-register FIFO synchronizer.
12.1 Common sync2 model - used by MCP formulation and FIFO synchronizer
The sync2 model is common to both the MCP formulation with ready-acknowledge design
(source code in section 12.2) and the multi-bit 1-deep / 2-register FIFO synchronizer (source
code in section 12.3).
// Pulse Generator
module plsgen (
output logic pulse, q,
input logic d,
input logic clk, rst_n);
assign pulse = q ^ d;
endmodule
Example 8 - plsgen.sv code
SNUG Boston 2008 50 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
module asend_fsm (
output logic aready, // ready to send next data
input logic asend, // send adata
input logic aack, // acknowledge receipt of adata
input logic aclk, arst_n);
always_comb begin
case (state)
READY: if (asend) next = BUSY;
else next = READY;
BUSY : if (aack) next = READY;
else next = BUSY;
endcase
end
module back_fsm (
output logic bvalid, // data valid / ready to load
input logic bload, // load data / send acknowledge
input logic b_en, // enable receipt of adata
input logic bclk, brst_n);
always_comb begin
case (state)
READY: if (bload) next = WAIT;
else next = READY;
WAIT : if (b_en) next = READY;
else next = WAIT;
endcase
end
SNUG Boston 2008 51 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
module bmcp_recv (
output logic [7:0] bdata,
output logic bvalid, // bdata valid
output logic b_ack, // acknowledge signal
input logic [7:0] adata, // unsynchronized adata
input logic bload, // load data and acknowledge receipt
input logic bq2_en, // synchornized enable input
input logic bclk, brst_n);
// Pulse Generator
plsgen pg1 (.pulse(b_en), .q(), .d(bq2_en),
.clk(bclk), .rst_n(brst_n), .*);
SNUG Boston 2008 52 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
module mcp_blk #(parameter type dat_t = logic [7:0]) (
output logic aready, // ready to receive next data
input logic [7:0] adatain,
input logic asend,
input logic aclk, arst_n,
SNUG Boston 2008 53 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
module amcp_send (
output logic [7:0] adata,
output logic a_en, aready,
input logic [7:0] adatain,
input logic asend,
input logic aq2_ack,
input logic aclk, arst_n);
// Pulse Generator
plsgen pg1 (.pulse(aack), .q(), .d(aq2_ack),
.clk(aclk), .rst_n(arst_n));
SNUG Boston 2008 54 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
12.3 Multi-bit 1-deep / 2-register FIFO synchronizer source code
This model requires the sync2 model shown in section 12.1.
module wctl (
output logic wrdy, wptr, we,
input logic wput, wq2_rptr,
input logic wclk, wrst_n);
`timescale 1ns/1ns
module cdc_syncfifo #(parameter type dat_t = logic [7:0]) (
// Write clk interface
input dat_t wdata,
output logic wrdy,
input logic wput,
input logic wclk, wrst_n,
// Read clk interface
output dat_t rdata,
output logic rrdy,
input logic rget,
input logic rclk, rrst_n);
SNUG Boston 2008 55 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
module dp_ram2 #(parameter type dat_t = logic [7:0])
(output dat_t q,
input dat_t d,
input logic waddr, raddr, we, clk);
assign q = mem[raddr];
endmodule
Example 16 - Dual Port Ram code - dp_ram2.sv
module rctl (
output logic rrdy, rptr,
input logic rget,rq2_wptr,
input logic rclk, rrst_n);
SNUG Boston 2008 56 Clock Domain Crossing (CDC) Design & Verification
Rev 1.0 Techniques Using SystemVerilog
Expert Verilog, SystemVerilog & Synthesis Training
SNUG-2001
San Jose, CA
Voted Best Paper
3rd Place
ABSTRACT
Designing a pure, one-clock synchronous design is a luxury that few ASIC designers will ever know. Most of the
ASICs that are ever designed are driven by multiple asynchronous clocks and require special data, control-signal
and verification handling to insure the timely completion of a robust working design.
1.0 Introduction
Most college courses teach engineering students prescribed techniques for designing completely synchronous
(single clock) logic. In the real ASIC design world, there are very few single clock designs. This paper will detail
some of the hardware design, timing analysis, synthesis and simulation methodologies to address multi-clock
designs.
This paper is not intended to provide exhaustive coverage of this topic, but is presented to share techniques learned
from experience.
2.0 Metastability
Quoting from Dally and Poulton's book[6] concerning metastability:
"When sampling a changing data signal with a clock ... the order of the events determines the outcome.
The smaller the time difference between the events, the longer it takes to determine which came first.
When two events occur very close together, the decision process can take longer than the time allotted,
and a synchronization failure occurs."
Only one
synchronizing flip-flop
aclk is
asynchronous adat bdat1
to bclk dat
aclk
bclk
Data
aclk changing
adat
bclk samples adat
while it is changing
bclk
Figure 1 shows a synchronization failure that occurs when a signal generated in one clock domain is sampled too
close to the rising edge of a clock signal from another clock domain.
Synchronization failure is caused by an output going metastable and not converging to a legal stable state by the
time the output must be sampled again. Figure 2 shows that a metastable output can cause illegal signal values to be
propagated throughout the rest of the design.
Sampling aclk ?? ??
clock bclk
aclk adat
changing
adat
Clocked signal is
initially metastable
bclk and is still meta-
stable on the next
active clock edge
bdat1
Other logic output values
are indeterminate
Figure 2 - Metastable bdat1 output propagating invalid data throughout the design
Every flip-flop that is used in any design has a specified setup and hold time, or the time in which the data input is
not legally permitted to change before and after a rising clock edge. This time window is specified as a design
parameter precisely to keep a data signal from changing too close to another synchronizing signal that could cause
the output to go metastable.
The metastable output problem shown in Figure 2 is sometimes known as the John Cooley ESNUG effect, or in
other words, the propagation of unwanted information!
(Just kidding, John! ☺)
3.0 Synchronizers
Quoting again from Dally and Poulton[7] concerning synchronizers:
"A synchronizer is a device that samples an asynchronous signal and outputs a version of the signal
that has transitions synchronized to a local or sample clock."
The most common synchronizer used by digital designers is a two-flip-flop synchronizer as shown in Figure 3.
"1" "0"
adat bdat1 bdat2
dat
aclk adat
changing
adat
Clocked signal is
initially metastable
bclk but goes "high"
before the next
active clock edge
bdat1
bSig0
aSig2
Each non-
synchronizer aSig3 sync_ cClk Logic cSig1 Simple to
module is now a2c perform static
completely
timing analysis
synchronous to
bSig2 sync_ cSig2 for each clock
just one clock
b2c
7.1 Grouping
Group together all non-synchronizer modules that are clocked within each clock domain. One group should be
formed for each clock domain in the design. These groups will be timing verified as if each were a separate,
completely synchronous design.
bdat1
bdat2
One potential solution to this problem is to assert control signals for a period of time that exceeds the cycle time of
the sampling clock as shown in Figure 6. The assumption is that the control signal will be sampled at least once and
possibly twice by the receiver clock.
bdat1
bdat2
Figure 6 - Lengthened pulse to guarantee that the control signal will be sampled
A second potential solution to this problem is to assert a control signal, synchronize it into the new clock domain
and then pass the synchronized signal back through another synchronizer into the sending clock domain as an
acknowledge signal. Although synchronizing a feedback signal is a very safe technique to acknowledge that the first
control signal was recognized and sampled into the new clock domain, there is considerable delay associated with
synchronizing control signals in both directions before releasing the control signal[2].
abdat2 abdat1
aclk
bclk
aclk bclk
domain domain
Synchronizing aclk
aclk
ab_load / ab_en
ab_load
adata abus
d q ab_en
b_load a_load
ld
"load" but no "enable"
b_en a_en en
a_load
aClk a_en
abus 00
Synchronizers
adata was not loaded
Synchronizing aclk
aclk
ab_lden
ab_lden
adata abus
d q
b_lden a_lden
ld
"load" and "enable"
en
a_lden
aClk
bClk aClk
domain domain adata 00 FF
abus 00 FF
Synchronizer
adata is loaded
Figure 9 - Solution - Consolidating control signals before passing them between clock domains
Synchronizing aclk
aclk
ab_en1 / ab_en2
ab_en1
a1 a2 a3
q q ab_en2
ben1 aen1
ben2 aen2
aen1
aClk aen2
The solution to the problem, as shown in Figure 11, is to send only one control signal into the new clock domain
and generate the second phase-shifted sequential control signal within the new clock domain.
Synchronizing aclk
aclk
ab_en
ab_en1
a1 a2 a3
q q
ben1 aen1
aen2 aen1
aClk aen2
bClk aClk
domain domain a1
a2
Synchronizers a3
a3 loaded
Figure 11 - Solution - Logic to generate the proper sequencing signals in the new clock domains
aclk
ab_dec[1:0]
ab_dec[1]
aen[3]
ab_dec[0]
bdec[1] adec[1]
aen[2]
bdec[0] adec[0] aen[1]
adec[1]
aen[0]
aClk adec[0]
bClk aClk
aen[0] aen[0] aen[2] aen[3]
domain domain aen[3]
aen[2]
Synchronizers WRONG! aen[1]
aen[2] should not
aen[0]
be asserted
bdec=0 bdec=3
bdec[1]
bdec[0]
bden_n
ab_dec[1:0] aclk
aen[3]
ab_dec[1]
bdec[1] adec[1]
aen[2] ab_dec[0]
bdec[0] adec[0] aen[1] ab_den_n
aen[0]
bden_n aden_n adec[1]
en adec[0]
aClk aden_n
bClk aClk
domain domain aen[3] "1" (off) aen[3]
aen[2] "1" (off)
Shaped enable aen[1] "1" (off)
pulse
Synchronizers aen[0] "1" (off)
Figure 13 - Solution #1 - Logic to synchronize and wave-shape an enable pulse to pass between clock domains
Under worst case conditions, the shaped enable signal will either be sampled at the same time as the encoded inputs
are sampled into the receiving clock domain, or the shaped enable signal will be de-asserted at the same time as the
encoded inputs are de-asserted in the receiving clock domain. Under best case conditions, the shaped enable pulse
will be asserted one receiving clock cycle later than the assertion of the encoded inputs and de-asserted one
receiving clock cycle before the de-assertion of the encoded inputs. This method insures that the encoded inputs are
valid before they are enabled into the receiving clock domain.
A second potential solution to this problem, as shown in Figure 14, is to decode the signals back in the sending
clock domain and then send the decoded outputs (where only one of the outputs is asserted) through synchronizers
into the new clock domain. Within the new clock domain, a state machine is used to determine when a new decoded
output has been asserted. If there are no decoded outputs, it means that one decoded output has been de-asserted and
that another decoded output is about to be asserted. If there are two asserted decoded output signals, the last
decoded output signal will cause the state machine to change states and the older decoded output signal will turn off
on the next rising clock edge in the new clock domain. It is important that the sender insure that the decoded outputs
are each asserted for a time period that is longer than the cycle time of the receiving clock domain.
!aen[0] !aen[2]
Synchronizers
!aen[3] EN2
!aen[1]
bClk aClk !a_sel2
!aen[2]
domain domain
Figure 14 - Solution #2 - FSM logic to detect one-hot control signals passed from a different clock domain
Any time there are multiple control signals crossing clock boundaries, caution must be taken to insure that the
sequencing of the control signals being passed is correct or that any potential mis-sequencing of the control signals
will not adversely impact the correct operation of the design.
Gray
Code
Gray to reg
Binary bin Binary
comb. bnext to Gray gnext
+ d q gray
logic comb.
logic
inc rst_n
clk
rst_n
Unfortunately, Verilog does not permit part selects using a variable index range so the code in Example 1, although
conceptually correct, will not compile.
Another way to think of a gray-to-binary conversion is to exclusive-or the significant gray-code bits with padded 0's
as shown in Figure 18.
The corresponding parameterized Verilog model for this algorithm is shown in Example 2. This example is
syntactically correct, will compile and does work.
always @(gray)
for (i=0; i<SIZE; i=i+1)
bin[i] = ^(gray>>i);
endmodule
Example 2 - Parameterized and correct gray-to-binary Verilog model
Instantiated
memory
module
wclk rclk
module module
wdata rdata
wdata rdata
write
write
FIFO FIFO
wptr rptr
winc inc g waddr raddr g inc rinc
wrst_n rrst_n
Full Empty
wfull rempty
flag syncronize syncronize flag
logic to write clk to read clk logic
A clever way to approach this problem suggested by Bhatnagar[3] is to use Synopsys commands to modify the SDF
backannotation of the setup and hold time on just the first stage flip-flop cells in the design. Bhatnagar points out
that the SDF file is instance based and therefore targeting the setup and hold times for the offending cells is more
easily accomplished. Bhatnagar notes:
Instead of manually removing the setup and hold-time constructs from the SDF file, a better way is to
zero out the setup and hold-times in the SDF file, only for the violating flops, i.e., replace the existing
setup and hold-time numbers with zero's.
Bhatnagar further points out that setup hold times of zero means that there can be no timing violation, therefore no
unknowns propagated to the rest of the design. The following dc_shell command, given by Bhatnagar, is used to
make setup and hold times zero:
Using a creative naming convention for the output of the first stage flip-flop of a synchronizer might make wild card
expressions possible to easily backannotate all first stage flip-flop SDF setup and hold time values to zero using
very few dc_shell commands.
13.0 Conclusions
Completely synchronous one-clock design techniques are well known. Synthesis tools do their best work on
synchronous designs. Timing analysis tools are designed to report timing problems on one-clock synchronous
designs. Synthesis scripts are easy to create for one-clock synchronous clock designs. The techniques in this paper
are aimed at making the design look like multiple single clock designs!
• Partitioning non-synchronizer blocks so that there is only one clock per module permits easy verification of
correct timing by creating clock-domain sub-blocks that can be more easily verified with static timing analysis
tools.
• Partitioning synchronizer blocks to permit inputs from one and only one clock domain and clocking the
signals with only one asynchronous clock creates manageable synchronizer sub- blocks that can also be easily
timed.
• A clock-oriented naming convention can be useful to help identify signals that need to be timed within the
different asynchronous clock domains.
• Multiple control signals crossing clock domains require special attention to ensure that all control signals are
properly sequenced into a new clock domain.
The techniques described in this paper were developed to facilitate robust development and verification of multi-
clock designs.
ABSTRACT
FIFOs are often used to safely pass data from one clock domain to another asynchronous clock domain. Using a
FIFO to pass data from one clock domain to another clock domain requires multi-asynchronous clock design
techniques. There are many ways to design a FIFO wrong. There are many ways to design a FIFO right but still
make it difficult to properly synthesize and analyze the design.
This paper will detail one method that is used to design, synthesize and analyze a safe FIFO between different clock
domains using Gray code pointers that are synchronized into a different clock domain before testing for "FIFO full"
or "FIFO empty" conditions. The fully coded, synthesized and analyzed RTL Verilog model (FIFO Style #1) is
included.
Using n-bit pointers where (n-1) is the number of address bits required to access the entire FIFO memory buffer, the
FIFO is empty when both pointers, including the MSBs are equal. And the FIFO is full when both pointers, except
the MSBs are equal.
The FIFO design in this paper uses n-bit pointers for a FIFO with 2(n-1) write-able locations to help handle full and
empty conditions. More design details related to the full and empty logic are included in section 5.0.
In the behavioral model of Example 1, it is okay to use binary-count pointers, a Verilog array to represent the FIFO
memory buffer, multi-asynchronous clocks in the same module and non-registered outputs. THIS MODEL IS NOT
INTENDED FOR SYNTHESIS! (Hopefully enough capital letters have been used in this section to discourage
anyone from trying to synthesize this model!)
Two of the always blocks in the module (the always blocks with concatenations) are included to behaviorally
represent the synchronization that will be required in the actual RTL FIFO design. They are not important to the
testing of the data transfer through the FIFO, but they are important to the testing of the correctly timed full and
empty flags in the FIFO model. The exact number of synchronization stages required in the behavioral model is
FIFO-design dependent. This model can be used to help test the FIFO design described in this paper.
Consider the example shown in Figure 6 of an 8-deep FIFO. In this example, a 3-bit Gray code pointer is used to
address memory and an extra bit (the MSB of a 4-bit Gray code) is added to test for full and empty conditions. If the
FIFO is allowed to fill the first seven locations (words 0-6) and then if the FIFO is emptied by reading back the
same seven words, both pointers will be equal and will point to address Gray-7 (the FIFO is empty). On the next
write operation, the write pointer will increment the 4-bit Gray code pointer (remember, only the 3 LSBs are being
used to address memory), making the MSBs different on the 4-bit pointers but the rest of the write pointer bits will
match the read pointer bits, so the FIFO full flag would be asserted. This is wrong! Not only is the FIFO not full,
but the 3 LSBs did not change, which means that the addressed memory location will over-write the last FIFO
memory location that was written. This too is wrong!
This is one reason why the dual n-bit Gray code counter of Figure 4 and Section 4.0 is used.
The correct method to perform the full comparison is accomplished by synchronizing the rptr into the wclk
domain and then there are three conditions that are all necessary for the FIFO to be full:
(1) The wptr and the synchronized rptr MSB's are not equal (because the wptr must have wrapped
one more time than the rptr).
(2) The wptr and the synchronized rptr 2nd MSB's are not equal (because an inverted 2nd MSB from
one pointer must be tested against the un-inverted 2nd MSB from the other pointer, which is required if the
MSB's are also inverses of each other - see Figure 6 above).
(3) All other wptr and synchronized rptr bits must be equal.
In order to efficiently register the wfull output, the synchronized read pointer is actually compared against the
wgnext (the next Gray code that will be registered in the wptr). This is shown below in the sequential always
block that has been extracted from the wptr_full.v code of Example 7:
In the above code, the three necessary conditions to check for FIFO-full are tested and the result is assigned to the
wfull_val signal, which is then registered in the subsequent sequential always block.
The continuous assignment to wfull_val can be further simplified using concatenations as shown below:
Figure 3 by placing a second adder after the Gray-to-binary combinational logic to add four to the binary value and
register the result. This registered value would then be used to do subtraction against the synchronized rptr after it
has been converted to a binary value in the wclk domain, and if the difference is less than four, an almost_full
bit could be set. A less-than operation insures that the almost_full bit is set for the full range when the wptr is
within 0-4 counts of catching up to the synchronized rptr. Similar logic could be used in the rclk-domain to
generate the almost_empty flag.
Almost full and almost empty have not been included in the Verilog RTL code shown in this paper.
`ifdef VENDORRAM
// instantiation of a vendor's dual-port RAM
vendor_ram mem (.dout(rdata), .din(wdata),
.waddr(waddr), .raddr(raddr),
.wclken(wclken),
.wclken_n(wfull), .clk(wclk));
`else
// RTL Verilog memory model
localparam DEPTH = 1<<ADDRSIZE;
reg [DATASIZE-1:0] mem [0:DEPTH-1];
//-------------------
// GRAYSTYLE2 pointer
//-------------------
always @(posedge rclk or negedge rrst_n)
if (!rrst_n) {rbin, rptr} <= 0;
else {rbin, rptr} <= {rbinnext, rgraynext};
//---------------------------------------------------------------
// FIFO empty when the next rptr == synchronized wptr or on reset
//---------------------------------------------------------------
assign rempty_val = (rgraynext == rq2_wptr);
// GRAYSTYLE2 pointer
always @(posedge wclk or negedge wrst_n)
if (!wrst_n) {wbin, wptr} <= 0;
else {wbin, wptr} <= {wbinnext, wgraynext};
//------------------------------------------------------------------
// Simplified version of the three necessary full-tests:
// assign wfull_val=((wgnext[ADDRSIZE] !=wq2_rptr[ADDRSIZE] ) &&
// (wgnext[ADDRSIZE-1] !=wq2_rptr[ADDRSIZE-1]) &&
// (wgnext[ADDRSIZE-2:0]==wq2_rptr[ADDRSIZE-2:0]));
//------------------------------------------------------------------
assign wfull_val = (wgraynext=={~wq2_rptr[ADDRSIZE:ADDRSIZE-1],
wq2_rptr[ADDRSIZE-2:0]});
8.0 Conclusions
Asynchronous FIFO design requires careful attention to details from pointer generation techniques to full and empty
generation. Ignorance of important details will generally result in a design that is easily verified but is also wrong.
Finding FIFO design errors typically requires simulation of a gate-level FIFO design with backannotation of actual
delays and a whole lot of luck!
Synchronization of FIFO pointers into the opposite clock domain is safely accomplished using Gray code pointers.
Generating the FIFO-full status is perhaps the hardest part of a FIFO design. Dual n-bit Gray code counters are
valuable to synchronize and n-bit pointer into the opposite clock domain and to use an (n-1)-bit pointer to do “full”
comparison. Synchronizing binary FIFO pointers using techniques described in section 7.0 is another worthy
technique to use when doing FIFO design.
Generating the FIFO-empty status is easily accomplished by comparing-equal the n-bit read pointer to the
synchronized n-bit write pointer.
The techniques described in this paper should work with asynchronous clocks spanning small to large differences in
speed.
Careful partitioning of the FIFO modules along clock boundaries with all outputs registered can facilitate synthesis
and static timing analysis within the two asynchronous clock domains.
10.0 Acknowledgements
I am grateful to Ben Cohen for his willingness to discuss FIFO design issues with me in preparation for writing this
paper. I would also like to thank Peter Alfke of Xilinx for also discussing with me alternate interesting approaches
to FIFO design.
A special thanks to Steve Golson for doing a great review of the paper on short notice and adding the valuable
information, techniques and advantages related to using binary pointers in FIFO design in place of the Gray code
pointers. Also for finding the original patent information on Frank Gray’s “Pulse Code Communication.”
SNUG-2002
San Jose, CA
Voted Best Paper
1st Place
ABSTRACT
An interesting technique for doing FIFO design is to perform asynchronous comparisons between the FIFO write
and read pointers that are generated in clock domains that are asynchronous to each other. The asynchronous FIFO
pointer comparison technique uses fewer synchronization flip-flops to build the FIFO. The asynchronous FIFO
comparison method requires additional techniques to correctly synthesize and analyze the design, which are detailed
in this paper.
To increase the speed of the FIFO, this design uses combined binary/Gray counters that take advantage of the built-
in binary ripple carry logic.
The fully coded, synthesized and analyzed RTL Verilog model (FIFO Style #2) is included.
This FIFO design paper builds on information already presented in another FIFO design paper where the FIFO
pointers are synchronized into the opposite clock domain before running "FIFO full" or "FIFO empty" tests. The
reader may benefit from first reviewing the FIFO Style #1 method before proceeding to this FIFO Style #2 method.
SNUG San Jose 2002 2 Simulation and Synthesis Techniques for Asynchronous
Rev 1.2 FIFO Design with Asynchronous Pointer Comparisons
This implementation requires twice the number of flip-flops, but reduces the combinatorial logic and can operate at
a higher frequency. In FPGA designs, availability of extra flip-flops is rarely a problem since FPGAs typically
contain far more flip-flops than any design will ever use. In FPGA designs, reducing the amount of combinational
logic frequently translates into significant improvements in speed.
The ptr output of the block diagram in Figure 1 is an n-bit Gray code pointer.
Note: since the MSB of a binary sequence is equal to the MSB of a Gray code sequence, this design can be further
simplified by using the binary MSB-flip-flop as the Gray code MSB-flip-flop. The Verilog code in this paper did
not implement this additional optimization. This would save one flip-flop per pointer.
Figure 2 - FIFO is going full because the wptr trails the rptr by one quadrant
If the write pointer is one quadrant behind the read pointer, this indicates a "possibly going full" situation as shown
in Figure 2. When this condition occurs, the direction latch of Figure 4 is set.
SNUG San Jose 2002 3 Simulation and Synthesis Techniques for Asynchronous
Rev 1.2 FIFO Design with Asynchronous Pointer Comparisons
Figure 3 - FIFO is going empty because the rptr trails the wptr by one quadrant
If the write pointer is one quadrant ahead of the read pointer, this indicates a "possibly going empty" situation as
shown in Figure 3. When this condition occurs, the direction latch of Figure 4 is cleared.
When the FIFO is reset the direction latch is also cleared to indicate that the FIFO “is going empty” (actually, it
is empty when both pointers are reset). Setting and resetting the direction latch is not timing-critical, and the
direction latch eliminates the ambiguity of the address identity decoder.
SNUG San Jose 2002 4 Simulation and Synthesis Techniques for Asynchronous
Rev 1.2 FIFO Design with Asynchronous Pointer Comparisons
The Xilinx FPGA logic to implement the decoding of the two wptr MSBs and the two rptr MSBs is easily
implemented as two 4-input look-up tables.
The second, and more difficult, problem stems from the asynchronous nature of the write and read clocks.
Comparing two counters that are clocked asynchronously can lead to unreliable decoding spikes when either or both
counters change multiple bits more or less simultaneously. The solution described in this paper uses a Gray count
sequence, where only one bit changes from any count to the next. Any decoder or comparator will then switch only
from one valid output to the next one, with no danger of spurious decoding glitches.
To facilitate static timing analysis of the style #2 FIFO design, the design has been partitioned into the following
five Verilog modules with the following functionality and clock domains:
• fifo2.v - (see Example 1 in section 5.1) - this is the top-level wrapper-module that includes all clock
domains. The top module is only used as a wrapper to instantiate all of the other FIFO modules used in the
design. If this FIFO is used as part of a larger ASIC or FPGA design, this top-level wrapper would probably be
discarded to permit grouping of the other FIFO modules into their respective clock domains for improved
synthesis and static timing analysis.
SNUG San Jose 2002 5 Simulation and Synthesis Techniques for Asynchronous
Rev 1.2 FIFO Design with Asynchronous Pointer Comparisons
• fifomem.v - (see Example 2 in section 5.2) - this is the FIFO memory buffer that is accessed by both the
write and read clock domains. This buffer is most likely an instantiated, synchronous dual-port RAM. Other
memory styles can be adapted to function as the FIFO buffer.
• async_cmp.v - (see Example 3 in section 5.3) - this is an asynchronous pointer-comparison module that is
used to generate signals that control assertion of the asynchronous “full” and “empty” status bits. This module
only contains combinational comparison logic. No sequential logic is included in this module.
• rptr_empty.v - (see Example 4 in section 5.4) - this module is mostly synchronous to the read-clock
domain and contains the FIFO read pointer and empty-flag logic. Assertion of the aempty_n signal (an input
to this module) is synchronous to the rclk-domain, since aempty_n can only be asserted when the rptr
incremented, but de-assertion of the aempty_n signal happens when the wptr increments, which is
asynchronous to rclk.
• wptr_full.v - (see Example 5 in section 5.5) - this module is mostly synchronous to the write-clock domain
and contains the FIFO write pointer and full-flag logic. Assertion of the afull_n signal (an input to this
module) is synchronous to the wclk-domain, since afull_n can only be asserted when the wptr
incremented (and wrst_n), but de-assertion of the afull_n signal happens when the rptr increments,
which is asynchronous to wclk.
SNUG San Jose 2002 6 Simulation and Synthesis Techniques for Asynchronous
Rev 1.2 FIFO Design with Asynchronous Pointer Comparisons
5.0 RTL code for FIFO style #2
The Verilog RTL code for the FIFO style #2 model is listed in this section.
5.1 fifo2.v - FIFO top-level module
The fifo2 top-level module is a parameterized module with all sub-blocks instantiated following safe coding
practices using named port connections.
module fifo2 (rdata, wfull, rempty, wdata,
winc, wclk, wrst_n, rinc, rclk, rrst_n);
parameter DSIZE = 8;
parameter ASIZE = 4;
output [DSIZE-1:0] rdata;
output wfull;
output rempty;
input [DSIZE-1:0] wdata;
input winc, wclk, wrst_n;
input rinc, rclk, rrst_n;
SNUG San Jose 2002 7 Simulation and Synthesis Techniques for Asynchronous
Rev 1.2 FIFO Design with Asynchronous Pointer Comparisons
5.2 fifomem.v - FIFO memory buffer
The FIFO memory buffer could be an instantiated ASIC or FPGA dual-port, synchronous memory device. The
memory buffer could also be synthesized to ASIC or FPGA registers using the RTL code in this module.
If a vendor RAM is instantiated, it is highly recommended that the instantiation be done using named port
connections.
`ifdef VENDORRAM
// instantiation of a vendor's dual-port RAM
VENDOR_RAM MEM (.dout(rdata), .din(wdata),
.waddr(waddr), .raddr(raddr),
.wclken(wclken), .clk(wclk));
`else
reg [DATASIZE-1:0] MEM [0:DEPTH-1];
SNUG San Jose 2002 8 Simulation and Synthesis Techniques for Asynchronous
Rev 1.2 FIFO Design with Asynchronous Pointer Comparisons
5.3 async_cmp.v - Asynchronous the full/empty comparison logic
The logic used to determine the full or empty status on the FIFO is the most distinctive difference between FIFO
style #1 and FIFO style #2.
Async_cmp is an asynchronous comparison module, used to compare the read and write pointers to detect full and
empty conditions.
reg direction;
wire high = 1'b1;
Three of the last seven lines of the Verilog code of Example 3 have been commented out in this model. In theory, a
synthesis tool should be capable of inferring an RS-flip-flop from the comment-removed code, but the LSI_10K
library that is included with the default installation of the Synopsys tools did not infer a correct RS-flip-flop with
this code when tested, so the always block immediately preceding the commented code was added to infer an RS-
flip-flop.
5.3.1 Asynchronous generation of full and empty
In the async_cmp code of Example 3, and shown in Figure 6, aempty_n and afull_n are the asynchronously
decoded signals. The aempty_n signal is asserted on the rising edge of an rclk, but is de-asserted on the rising
edge of a wclk. Similarly, the afull_n signal is asserted on a wclk and removed on an rclk.
The empty signal will be used to stop the next read operation, and the leading edge of aempty_n is properly
synchronous with the read clock, but the trailing edge needs to be synchronized to the read clock. This is done in a
two-stage synchronizer that generates rempty.
The wfull signal is generated in the symmetrically equivalent way.
SNUG San Jose 2002 9 Simulation and Synthesis Techniques for Asynchronous
Rev 1.2 FIFO Design with Asynchronous Pointer Comparisons
Figure 6 - Asynchronous pointer comparison to assert full and empty
5.3.2 Resetting the FIFO
The first FIFO event of interest takes place on a FIFO-reset operation. When the FIFO is reset, four important
things happen within the async_cmp module and accompanying full and empty synchronizers of the wptr_full
and rptr_empty modules (the connections between the async_cmp, wptr_full and rptr_empty modules
are shown in Figure 7):
1. The reset signal directly clears the wfull flag. The rempty flag is not cleared by a reset.
2. The reset signal clears both FIFO pointers, so the pointer comparator asserts that the pointers are equal.
3. The reset clears the direction bit.
4. With the pointers equal and the direction bit cleared, the aempty_n bit is asserted, which presets the
rempty flag.
SNUG San Jose 2002 10 Simulation and Synthesis Techniques for Asynchronous
Rev 1.2 FIFO Design with Asynchronous Pointer Comparisons
Figure 7 - async_cmp module connection to rptr_empty and wptr_full modules
The third FIFO operational event of interest occurs when the wptr is within one quadrant of catching up to the
rptr as described in section 3.0. When this happens, the dirset_n bit of Figure 6 is asserted low, which sets
the direction bit high. This means that the direction bit is set long before the FIFO is full and is not timing-
critical to assertion of the afull_n signal.
The fourth FIFO operational event of interest is when the wptr catches up to the rptr (and the direction bit is
set). When this happens, the afull_n signal presets the wfull flip-flops. The afull_n signal is asserted on a
FIFO-write operation and is synchronous to the rising edge of the wclk; therefore, asserting full is synchronous to
the wclk. See section 5.3.6 for a discussion of the critical timing path associated with assertion of the wfull
signal.
The fifth FIFO operational event of interest is when a FIFO-read operation takes place and the rptr is
incremented. At this point, the FIFO pointers are no longer equal so the afull_n signal is de-asserted, releasing
the preset control of the wfull flip-flops. After two rising edges on wclk, the FIFO will de-assert the wfull
signal. Because the de-assertion of afull_n happens on a rising rclk and because the wfull signal is clocked
by the wclk, the two-flip-flop synchronizer, shown in Figure 8, is required to remove metastability that could be
generated by the first wfull flip-flop capturing the inverted and asynchronously generated afull_n data input.
SNUG San Jose 2002 11 Simulation and Synthesis Techniques for Asynchronous
Rev 1.2 FIFO Design with Asynchronous Pointer Comparisons
clock, and must, therefore be synchronized to the write clock. The same timing issues related to the setting of the
full flag also apply to the setting of the empty flag.
5.3.4 FIFO-reads & FIFO empty
The sixth FIFO operational event of interest takes place when the rptr increments into the next Gray code
quadrant beyond the wptr. The direction bit is again set (but it was already set).
The seventh FIFO operational event of interest occurs when the rptr is within one quadrant of catching up to the
wptr. When this happens, the dirrst bit of Figure 6 is asserted high , which clears the direction bit. This
means that the direction bit is cleared long before the FIFO is empty and is not timing critical to assertion of the
aempty_n signal.
The eighth FIFO operational event of interest is when the rptr catches up to the wptr (and the direction bit is
zero). When this happens, the aempty_n signal presets the rempty flip-flops. The aempty_n signal is asserted
on a FIFO-read operation and is synchronous to the rising edge of the rclk; therefore, asserting empty is
synchronous to the rclk. See section 5.3.6 for a discussion of the critical timing path associated with assertion of
the rempty signal.
Finally, when a FIFO-write operation takes place and the wptr is incremented. At this point, the FIFO pointers are
no longer equal so the aempty_n signal is de-asserted, releasing the preset control of the rempty flip-flops. After
two rising edges on rclk, the FIFO will de-assert the rempty signal. Because the de-assertion of aempty_n
happens on a rising wclk and because the rempty signal is clocked by the rclk, the two-flip-flop synchronizer
as shown in Figure 8 is required to remove metastability that could be generated by the first rempty flip-flop.
SNUG San Jose 2002 12 Simulation and Synthesis Techniques for Asynchronous
Rev 1.2 FIFO Design with Asynchronous Pointer Comparisons
Figure 10 - Critical timing paths for asserting rempty and wfull
rclk domain. This critical timing path has a symmetrically equivalent critical timing path for the generation of the
wfull signal, also shown in Figure 10.
SNUG San Jose 2002 13 Simulation and Synthesis Techniques for Asynchronous
Rev 1.2 FIFO Design with Asynchronous Pointer Comparisons
Since aempty_n is started by one clock and terminated by the other, it has an undefined duration, and might even
be a runt pulse. A runt pulse is a Low-High-Low signal transition where the transition to High may or may not pass
through the logic-“1” threshold level of the logic family being used.
If the aempty_n control signal is a runt pulse, there are four possible scenarios that should be addressed:
(1) the runt signal is not recognized by the rempty flip-flops and empty is not asserted. This is not a problem.
(2) The runt pulse might preset the first synchronizer flip-flop, but not the second flip-flop. This is highly unlikely,
but would result in an unnecessary, but properly synchronized rempty output, that will show up on the output
of the second flip-flop one read clock later. This is not a problem.
(3) The runt pulse might preset the second synchronizer flip-flop, but not the first flip-flop. This is highly unlikely,
but would result in an unnecessary, but properly synchronized rempty output (as long as the empty critical
timing is met), that will be set on the output of the second flip-flop until the next read clock, when it will be
cleared by the zero from the first flip-flop. This is not a problem.
(4) The most likely case is that the runt pulse sets both flip-flops, thus creating a properly synchronized rempty
output that is two read-clock periods long. The longer duration is caused by the two-flip-flop synchronizer ( to
avoid metastable problems as described below). This is not a problem.
The runt pulse cannot have any effect on the synchronizer data-input, since an aempty_n runt pulse can only
occur immediately after a read clock edge, thus long before the next read clock edge (as long as critical timing is
met).
The aempty_n signal might also stay high longer and go low at any moment, even perhaps coincident with the
next read clock edge. If it goes low well before the set-up time of the first synchronize flip-flop, the result is like
scenario (4) above. If it goes low well after the set-up time, the synchronizer will stretch rempty by one more read
clock period.
If aempty_n goes low within the metstability-catching set-up time window, the first synchronizer flip-flop output
will be indeterminate for a few nanoseconds, but will then be either high or low. In either case, the output of the
second synchronizer flip-flop will create the appropriate synchronized rempty output.
The next question is, what happens if the write clock de-asserts the aempty_n signal coincident with the rising
rclk on the dual synchronizer? The first flip-flop could go metastable, which is why there is a second flip-flop in
the dual synchronizer.
But the removal of the setting signal on the second flip-flop will violate the recovery time of the second flip-flop.
Will this cause the second flip-flop to go metastable? The authors do not believe this can happen because the preset
to the flip-flop forced the output high and the input to the same flip-flop is already high, which we believe is not
subject to a recovery time instability on the flip-flop.
Challenge: if anyone can prove that a flip-flop that is set high, and is also driven by a high-data-input signal, can go
metastable if the preset signal is removed coincident with the rising edge of the clock to the same flip-flop, the
authors would like to be made aware of any such claim. The authors believe that recovery time parameters are with
respect to removing a preset when the data input value is zero. The authors could not find any published reference
to discount the possibility of metastability on the output of the second flip-flop but we believe that metastability in
this case is not possible.
Last question. Can a runt-preset pulse, where the trailing edge of the runt pulse is caused by the wclk, preset the
second synchronizer flip-flop in close proximity to a rising rclk, violate the preset recovery time and cause
metastability on the output of the second flip-flop? The answer is no as long as the aempty_n critical timing path
is met. Assuming that critical timing is met, the aempty_n signal going low should occur shortly after a rising
rclk and well before the rising edge of the second flip-flop, so runt pulses can only occur well before the rising
edge of an rclk.
Again, symmetrically equivalent scenarios and arguments can be made about the generation of the wfull flag.
SNUG San Jose 2002 14 Simulation and Synthesis Techniques for Asynchronous
Rev 1.2 FIFO Design with Asynchronous Pointer Comparisons
5.4 rptr_empty.v - Read pointer & empty generation logic
This module encloses all of the FIFO logic that is generated within the read clock domain (except synchronizers).
The read pointer is an n-bit Gray code counter. The FIFO rempty output is asserted when the aempty_n signal
goes low and the rempty output is de-asserted on the second rising rclk edge after aempty_n goes high (a rare
metastable state could cause the rempty output to be de-asserted on the third rising rclk edge). This module is
completely synchronous to the rclk for simplified static timing analysis, except for the aempty_n input, which is
de-asserted asynchronously to the rclk.
//---------------------------------------------------------------
// GRAYSTYLE2 pointer
//---------------------------------------------------------------
always @(posedge rclk or negedge rrst_n)
if (!rrst_n) begin
rbin <= 0;
rptr <= 0;
end
else begin
rbin <= rbnext;
rptr <= rgnext;
end
//---------------------------------------------------------------
// increment the binary count if not empty
//---------------------------------------------------------------
assign rbnext = !rempty ? rbin + rinc : rbin;
assign rgnext = (rbnext>>1) ^ rbnext; // binary-to-gray conversion
The last always block in this module is the asynchronously preset rempty signal generation. The presetting signal
is the aempty_n input , which is asserted when the rptr is incremented by the rclk (synchronous to this block)
as long as the rempty critical timing path (described in section 5.3.6) is satisfied. Removal of the rempty signal
occurs when the write pointer increments, which is asynchronous to the rclk domain. Because reset removal is
asynchronous to the rclk domain, a two-flip-flop synchoronizer is required to synchronize aempty_n removal to
the rclk domain.
SNUG San Jose 2002 15 Simulation and Synthesis Techniques for Asynchronous
Rev 1.2 FIFO Design with Asynchronous Pointer Comparisons
5.5 wptr_full.v - Write pointer & full generation logic
This module encloses all of the FIFO logic that is generated within the write clock domain (except synchronizers).
The write pointer is an n-bit Gray code counter. The FIFO wfull output is asserted when the afull_n signal
goes low and the wfull output is de-asserted on the second rising wclk edge after afull_n goes high (a rare
metastable state could cause the wfull output to be de-asserted on the third rising wclk edge). This module is
completely synchronous to the wclk for simplified static timing analysis, except for the afull_n input, which is
de-asserted asynchronously to the wclk.
//---------------------------------------------------------------
// GRAYSTYLE2 pointer
//---------------------------------------------------------------
always @(posedge wclk or negedge wrst_n)
if (!wrst_n) begin
wbin <= 0;
wptr <= 0;
end
else begin
wbin <= wbnext;
wptr <= wgnext;
end
//---------------------------------------------------------------
// increment the binary count if not full
//---------------------------------------------------------------
assign wbnext = !wfull ? wbin + winc : wbin;
assign wgnext = (wbnext>>1) ^ wbnext; // binary-to-gray conversion
The last always block in this module is the asynchronously preset wfull signal generation. The presetting signal is
the afull_n input , which is asserted when the wptr is incremented by the wclk (synchronous to this block) as
long as the wfull critical timing path (described in section 5.3.6) is satisfied. Removal of the wfull signal occurs
when the read pointer increments, which is asynchronous to the wclk domain. Because reset removal is
asynchronous to the wclk domain, a two-flip-flop synchoronizer is required to synchronize afull_n removal to
the wclk domain. The wfull signal must also go low when the FIFO is reset.
SNUG San Jose 2002 16 Simulation and Synthesis Techniques for Asynchronous
Rev 1.2 FIFO Design with Asynchronous Pointer Comparisons
6.0 Conclusion
This paper describes an efficient technique to implement a high-speed asynchronous FIFO, using dual-port RAMs
addressed by Gray counters This design uses an asynchronous comparator for detecting full and empty status.
The technique described implements an asynchronous assertion of the full and empty flags that requires more effort
to analyze for static timing verification.
The technique described also does not have registered full and empty status flags, so care must be taken to insure
that the generation of these flags meets the required timing to recognize assertion of full and empty in the rest of the
system.
This efficient and interesting approach to FIFO design worthy of consideration.
SNUG San Jose 2002 17 Simulation and Synthesis Techniques for Asynchronous
Rev 1.2 FIFO Design with Asynchronous Pointer Comparisons
References
[1] Clifford E. Cummings, “Simulation and Synthesis Techniques for Asynchronous FIFO Design,” SNUG 2002 (Synopsys
Users Group Conference, San Jose, CA, 2002) User Papers, March 2002, Section TB2, 2nd paper. Also available at
www.sunburst-design.com/papers
[2] Clifford E. Cummings, “Synthesis and Scripting Techniques for Designing Multi-Asynchronous Clock Designs,” SNUG
2001 (Synopsys Users Group Conference, San Jose, CA, 2001) User Papers, March 2001, Section MC1, 3rd paper. Also
available at www.sunburst-design.com/papers
[3] Clifford E. Cummings and Don Mills, “Synchronous Resets? Asynchronous Resets? I am So Confused! How Will I Ever
Know Which to Use?” SNUG 2002 (Synopsys Users Group Conference, San Jose, CA, 2002) User Papers, March 2002,
Section TB2, 1st paper. Also available at www.sunburst-design.com/papers
[4] Frank Gray, "Pulse Code Communication." United States Patent Number 2,632,058. March 17, 1953.
[5] John O’Malley, Introduction to the Digital Computer, Holt, Rinehart and Winston, Inc., 1972, pg. 190.
[6] Peter Alfke, “Asynchronous FIFO in Virtex-II™ FPGAs,” Xilinx techXclusives, downloaded from
www.xilinx.com/support/techXclusives/fifo-techX18.htm
Peter Alfke, Director, Applications Engineering, Xilinx, Inc, San Jose, CA. Email address: peter.alfke@xilinx.com
Peter Alfke came to the US in 1966, with a German MSEE degree and nine years experience in digital systems and
circuit design at LM Ericsson and Litton Industries in Sweden. He has been manager, later director of applications
engineering for 34 years, at Fairchild, Zilog, AMD, and, since 1988, at Xilinx.
He holds fifteen patents, has written many Application Notes, presented at numerous design conferences, and has
given many applications-oriented seminars in the US and in Europe. He is an active participant in the best
newsgroup for FPGA users, comp.arch.fpga.
(Data accurate as of April 19th, 2002)
SNUG San Jose 2002 18 Simulation and Synthesis Techniques for Asynchronous
Rev 1.2 FIFO Design with Asynchronous Pointer Comparisons
Synchronous Resets? Asynchronous Resets?
I am so confused!
How will I ever know which to use?
ABSTRACT
This paper will investigate the pros and cons of synchronous and asynchronous resets. It will then look at usage of
each type of reset followed by recommendations for proper usage of each type.
This paper will also detail an interesting synchronization technique using digital calibration to synchronize reset
removal on a multi-ASIC design.
1.0 resets, Resets, RESETS, and then there’s RESETS
One cannot begin to consider a discussion of reset usage and styles without first saluting the most common reset
usage of all. This undesired reset occurs almost daily in systems that have been tested, verified, manufactured, and
integrated into the consumer, education, government, and military environments. This reset follows what is often
called “The Blue Screen of Death” resulting from software incompatibilities between the OS from a certain software
company, the software programs the OS is servicing, and the hardware on which the OS software is executing.
Why be concerned with these annoying little resets anyway? Why devote a whole paper to such a trivial subject?
Anyone who has used a PC with a certain OS loaded knows that the hardware reset comes in quite handy. It will put
the computer back to a known working state (at least temporarily) by applying a system reset to each of the chips in
the system that have or require a reset.
For individual ASICs, the primary purpose of a reset is to force the ASIC design (either behavioral, RTL, or
structural) into a known state for simulation. Once the ASIC is built, the need for the ASIC to have reset applied is
determined by the system, the application of the ASIC, and the design of the ASIC. For instance, many data path
communication ASICs are designed to synchronize to an input data stream, process the data, and then output it. If
sync is ever lost, the ASIC goes through a routine to re-acquire sync. If this type of ASIC is designed correctly, such
that all unused states point to the “start acquiring sync” state, it can function properly in a system without ever being
reset. A system reset would be required on power up for such an ASIC if the state machines in the ASIC took
advantage of “don’t care” logic reduction during the synthesis phase.
It is the opinion of the authors that in general, every flip-flop in an ASIC should be resetable whether or not it is
required by the system. Further more, the authors prefer to use asynchronous resets following the guidelines detailed
in this paper. There are exceptions to these guidelines. In some cases, when follower flip-flops (shift register flip-
flops) are used in high speed applications, reset might be eliminated from some flip-flops to achieve higher
performance designs. This type of environment requires a number of clocks during the reset active period to put the
ASIC into a known state.
Many design issues must be considered before choosing a reset strategy for an ASIC design, such as whether to use
synchronous or asynchronous resets, will every flip-flop receive a reset, how will the reset tree be laid out and
buffered, how to verify timing of the reset tree, how to functionally test the reset with test scan vectors, and how to
apply the reset among multiple clock zones.
In addition, when applying resets between multiple ASICs that require a specific reset release sequence, special
techniques must be employed to adjust to variances of chip and board manufacturing. The final sections of this
paper will address this latter issue.
Figure 1 - Bad coding style yields a design with an unnecessary loadable flip-flop
library ieee;
use ieee.std_logic_1164.all;
entity goodFFstyle is
port (
clk : in std_logic;
rst_n : in std_logic;
d : in std_logic;
q2 : out std_logic);
end goodFFstyle;
process (clk)
begin
if (clk'event and clk = '1') then
q2 <= q1;
end if;
end process;
end rtl;
Example 2b - Good VHDL coding style to model dissimilar flip-flops
It should be noted that the extraneous logic generated by the code in Example 1a and Example 1b is only a result of
using a synchronous reset. If an asynchronous reset approach had be used, then both coding styles would synthesize
to the same design without any extra combinational logic. The generation of different flip-flop styles is largely a
function of the sensitivity lists and if-else statements that are used in the HDL code. More details about the
sensitivity list and if-else coding styles are detailed in section 3.1.
process (clk)
begin
if (clk'event and clk = '1') then
if (rst_n = '0') then
count <= (others => '0'); -- sync reset
elsif (ld = '1') then
count <= '0' & d; -- sync load
else
count <= count + 1; -- sync increment
end if;
end if;
end process;
end rtl;
Example 3b - VHDL code for a loadable counter with synchronous reset
library ieee;
The approach to synthesizing asynchronous resets will depend on the designers approach to the reset buffer tree. If
the reset is driven directly from an external pin, then usually doing a set_drive 0 on the reset pin and doing a
set_dont_touch_network on the reset net will protect the net from being modified by synthesis. However,
there is at least one ESNUG article that indicates this is not always the case[16].
One ESNUG contributor[15] indicates that sometimes set_resistance 0 on the reset net might also be needed.
And our colleague, Steve Golson, has pointed out that you can set_resistance 0 on the net, or create a custom
wireload model with resistance=0 and apply it to the reset input port with the command:
set_wire_load -port_list reset
A recently updated SolvNet article also notes that starting with Synopsys release 2001.08 the definition of ideal nets
has slightly changed[24] and that a set_ideal_net command can be used to create ideal nets and “get no timing
updates, get no delay optimization, and get no DRC fixing.”
Another colleague, Chris Kiegle, reported that doing a set_disable_timing on a net for pre-v2001.08 designs helped
to clean up timing reports[2], which seems to be supported by two other SolvNet articles, one related to synthesis
and another related to Physical Synthesis, that recommend usage of both a set_false_path and a
set_disable_timing command[21][25].
4.2 Modeling Verilog flip-flops with asynchronous reset and asynchronous set
One additional note should be made here with regards to modeling asynchronous resets in Verilog. The simulation
model of a flip-flop that includes both an asynchronous set and an asynchronous reset in Verilog might not simulate
correctly without a little help from the designer. In general, most synchronous designs do not have flop-flops that
contain both an asynchronous set and asynchronous reset, but on the occasion such a flip-flop is required. The
coding style of Example 6 can be used to correct the Verilog RTL simulations where both reset and set are asserted
simultaneously and reset is removed first.
First note that the problem is only a simulation problem and not a synthesis problem (synthesis infers the correct flip-
flop with asynchronous set/reset). The simulation problem is due to the always block that is only entered on the
active edge of the set, reset or clock signals. If the reset becomes active, followed then by the set going active, then
if the reset goes inactive, the flip-flop should first go to a reset state, followed by going to a set state. With both
// synopsys translate_off
always @(rst_n or set_n)
if (rst_n && !set_n) force q = 1;
else release q;
// synopsys translate_on
endmodule
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity ctr8ar is
port (
clk : in std_logic;
rst_n : in std_logic;
d : in std_logic;
ld : in std_logic;
q : out std_logic_vector(7 downto 0);
co : out std_logic);
end ctr8ar;
process (clk)
begin
if (rst_n = '0') then
count <= (others => '0'); -- sync reset
elsif (clk'event and clk = '1') then
if (ld = '1') then
count <= '0' & d; -- sync load
else
count <= count + 1; -- sync increment
end if;
end if;
end process;
end rtl;
Example 7b- VHDL code for a loadable counter with asynchronous reset
Another advantage favoring asynchronous resets is that the circuit can be reset with or without a clock present.
The experience of the authors is that by using the coding style for asynchronous resets described in this section, the
synthesis interface tends to be automatic. That is, there is generally no need to add any synthesis attributes to get the
synthesis tool to map to a flip-flop with an asynchronous reset pin.
4.4 Disadvantages of asynchronous resets
There are many reasons given by engineers as to why asynchronous resets are evil.
The Reuse Methodology Manual (RMM) suggests that asynchronous resets are not to be used because they cannot
be used with cycle based simulators. This is simply not true. The basis of a cycle based simulator is that all inputs
change on a clock edge. Since timing is not part of cycle based simulation, the asynchronous reset can simply be
applied on the inactive clock edge.
For DFT, if the asynchronous reset is not directly driven from an I/O pin, then the reset net from the reset driver must
be disabled for DFT scanning and testing. This is required for the synchronizer circuit shown in section 6.
Some designers claim that static timing analysis is very difficult to do with designs using asynchronous resets. The
reset tree must be timed for both synchronous and asynchronous resets to ensure that the release of the reset can
occur within one clock period. The timing analysis for a reset tree must be performed after layout to ensure this
timing requirement is met.
The biggest problem with asynchronous resets is that they are asynchronous, both at the assertion and at the de-
assertion of the reset. The assertion is a non issue, the de-assertion is the issue. If the asynchronous reset is released
at or near the active clock edge of a flip-flop, the output of the flip-flop could go metastable and thus the reset state
of the ASIC could be lost.
Another problem that an asynchronous reset can have, depending on its source, is spurious resets due to noise or
glitches on the board or system reset. See section 8.0 for a possible solution to reset glitches. If this is a real
problem in a system, then one might think that using synchronous resets is the solution. A different but similar
problem exists for synchronous resets if these spurious reset pulses occur near a clock edge, the flip-flops can still go
metastable.
A closer examination of the timing now shows that reset distribution timing is the sum of the a clk-to-q propagation
delay, total delay through the reset distribution tree and meeting the reset recovery time of the destination registers
and flip-flops, as shown in Figure 7.
The code for the reset synchronizer circuit is shown in Example 8.
library ieee;
use ieee.std_logic_1164.all;
entity asyncresetFFstyle is
port (
clk : in std_logic;
asyncrst_n : in std_logic;
rst_n : out std_logic);
end asyncresetFFstyle;
In order to help speed the reset arrival to all the system flip-flops, the reset-driver flip-flop is clocked with an early
clock as shown in Figure 10. Post layout timing analysis must be made to ensure that the reset release for
asynchronous resets and both the assertion and release for synchronous reset do not beat the clock to the flip-flops;
meaning the reset must not violate setup and hold on the flops. Often detailed timing adjustments like this can not be
made until the layout is done and real timing is available for the two trees.
In order to add the delay, some vendors provide a delay hard macro that can be hand instantiated. If such a delay
macro is not available, the designer could manually instantiate the delay into the synthesized design after
optimization – remember not to optimize this block after the delay has been inserted or it will be removed. Of
course the elements could have don’t touch attributes applied to prevent them from being removed. A second
approach is to instantiated a slow buffer in a module and then instantiated that module multiple times to get the
desired delay. Many variations could expand on this concept.
This glitch filter is not needed in all systems. The designer must research the system requirements to determine
whether or not a delay is needed.
For this type of design, only the highest priority asynchronous reset synchronizer input is tied high. The other
asynchronous reset synchronizer inputs are tied to the master resets from higher priority clock domains.
For this digital acquisition system, as soon as reset is removed, the ASICs must start capturing data and generating
memory addresses to write the data to memory. Both data acquisition and address generation are continuously
running, capturing data samples and overwriting previous written memory locations until a trigger circuit causes the
address counters to stop and hold the data that has been most recently captured. Frequently, the trigger is set to hold
and show 90% of the waveform as pre-trigger data and 10% of the waveform as post-trigger data. Since it is
generally impossible to predict when the trigger will occur, it is necessary to continuously acquire data after reset
removal until a trigger signal stops the data acquisition.
The approach that was used in this design to do high-speed data acquisition was to use four demux ASICs that
capture every fourth point of the digitized waveform. Since the demux ASICs typically ran at very fast clock rates,
and since each demux ASIC also had to generate accompanying address count values to store the data samples to
memory, it was important that all four demux ASICs start their respective address counters in the correct sequence to
insure that the data samples stored in memory could be easily read-back to draw waveforms on the DSO display.
The problem with this type of design was to accurately remove the reset signal from the four ASIC devices at the
same time (in the same relative clock period) so that the four ASICs captured the correctly sequenced data samples
that corresponded to address-#0 on all four ASICs, followed by address-#1 on all four ASICs, etc., so that the data
stored to memory could be read back from memory (after triggering the DSO) in the correct sequence to display an
accurate waveform on the DSO screen.
For this type of design, there are a number of factors that work against correct reset-removal and hence correct
sequencing of the data values being written to memory.
First, for very high-speed designs (DSOs are typically very high-speed designs in order to capture an adequate
number of data samples while probing other high-speed circuits), the relative board trace length of reset signals to
the four ASICs would have to be held to a very tight tolerance; hence, board layout is an issue.
Second, process variations within or between batches of manufactured ASICs can create delays that exceed the ultra-
short ASIC clock periods. Choosing four ASICs to insert during manufacture can result in selection of four devices
The multi-ASIC reset removal synchronization logic is handled using the logic shown in Figure 15. This logic is
common to both master and slave ASICs.
Asserting reset (rst_n going low in Figure 15) asynchronously resets the master reset signal, mstrrst_n, which
is driven through a reset-tree to the rest of the resetable logic on all ASICs (both master and slave ASICs); therefore,
reset is asynchronous and immediate.
Each ASIC has three pins dedicated to reset-removal synchronization.
The first pin on each ASIC is a dedicated master/slave selection pin. When this pin is tied high, the ASIC is placed
into master mode. When the pin is tied low, the ASIC is placed into slave mode.
The second pin on each ASIC is the sync_out pin. On the slave ASICs, the sync_out pin is unused and left
dangling. The master ASIC generates the sync_out pulse when reset is removed (when reset_n goes high). The
sync_out signal is driven out of the master ASIC and is tied to the sync_in input on both master and slave
ASICs through board-trace connections. The sync_out pin is the pin that controls reset removal on both the
master ASIC and the slave ASICs.
The programmable digital delay block, shown in Figure 16, is a set of delay stages connected in series with each
delay-stage output driving both the next delay-stage input and an input on a multiplexer. The delay stages could be
simple buffers or they could be pairs of inverters. The number of delay stages selected was equal to almost three
ASIC clock cycles.
A processor interface is used to program the delay select register, which enables the multiplexer select lines to
choose which delayed sync_in signal (sdly0 to sdly15) would be driven to the mux output and used to remove
the reset on the ASIC.
In order to determine the correct delay settings for each ASIC, a software digital calibration technique was
employed.
To help calibrate the demux ASICs, as well as other analog devices on the data acquisition board, the board was
designed to capture a selectable on-board ramp signal through the data acquisition path. The ramp signal was used to
calibrate the delays on the four demux ASICs.
In Figure 17-Figure 19, the software programmable, digital calibration procedure is shown with just two of the four
demux ASICs.
ASIC #1 is given the initial delay setting of 11 (to drive the sdly11 signal to the mux output). ASIC #2 is given
another delay setting and a ramp signal is captured by the data acquisition board. If the delay setting on ASIC #2 is
too small, such as a delay value of 0-4 as shown in Figure 17, the ramp values captured by ASIC #2 will be sampled
early compared to the data points sampled by ASIC #1. This is manifest by the fact that each ramp data point
captured by ASIC #2 is larger than the next data point captured by ASIC #1.
If the delay setting on ASIC #2 is in the correct range, such as a delay value of 5-11 as shown in Figure 18, the ramp
values captured by ASIC #2 will be sampled in the correct order compared to the data points sampled by ASIC #1.
This is manifest by the fact that each ramp data point captured by ASIC #2 is larger than the previous data point
captured by ASIC #1 and smaller than the next data point captured by ASIC #1.
If the delay setting on ASIC #2 is too large, such as a delay value of 12-15 as shown in Figure 19, the ramp values
captured by ASIC #2 will be sampled late compared to the data points sampled by ASIC #1. This is manifest by the
fact that each ramp data point captured by ASIC #2 is smaller than the next data point captured by ASIC #1.
Once the correct range is determined for ASIC #2, the center point in the range is chosen to be the ASIC #2
sync_in delay setting. The center point is the safest setting in the range since this setting is approximately a half-
cycle between the previous and next rising clock edges for the reset-removal synchronization flip-flop.
After determining the correct ASIC #2 setting, the correct ASIC #1 range surrounding the initial setting (the setting
of 11 is used in Figure 17) must be determined to find the correct ASIC #1 mid-point setting. After determining the
correct ASIC #1 setting, a similar process is used to find the correct delay setting for ASIC #3, followed by finding
the correct setting for ASIC #4.
After digital calibration, there was no need to use a second reset-removal synchronization flip-flop because a mid-
clock setting was used to insure that the flip-flop recovery time was met and to insure that no metastability problems
would arise.
In the actual design, after determining a valid set of mid-point delay settings for the four ASICs on one of the data
acquisition prototype boards, these values were programmed into a ROM and used as initial settings for all
manufactured boards and variations from the initial settings were tracked. What was interesting was that the
calibrated delay values for each board rarely strayed more than one or two delay stages up or down from the original
settings of the initial data acquisition prototype board.
12.0 Conclusions
Using asynchronous resets is the surest way to guarantee reliable reset assertion. Although an asynchronous reset is a
safe way to reliably reset circuitry, removal of an asynchronous reset can cause significant problems if not done
properly.
The proper way to design with asynchronous resets is to add the reset synchronizer logic to allow asynchronous reset
of the design and to insure synchronous reset removal to permit safe restoration of normal design functionality.
Using DFT with asynchronous resets is still achievable as long as the asynchronous reset can be controlled during
test.
Don Mills is an independent EDA consultant, ASIC designer, and Verilog/VHDL trainer with 16 years of
experience.
Don has inflicted pain on Aart De Geuss for too many years as SNUG Technical Chair. Aart was more than happy to
see him leave! Not really, Don chaired three San Jose SNUG conferences: 1998-2000, the first Boston SNUG 1999,
and is currently chair of the Europe SNUG 2001- present.
Don holds a BSEE from Brigham Young University.
E-mail Address: mills@lcdm-eng.com
An updated version of this paper can be downloaded from the web site: www.sunburst-design.com/papers or from
www.lcdm-eng.com
(Data accurate as of April 19th, 2002)
Abstract: With the increasing trend towards SOCs, designs with multiple
asynchronous clock domains are getting commonplace today. The design of
asynchronous clock domain crossing (CDC) interfaces is required to follow strict
design principles to ensure reliable operation in the presence of metastability.
With the emergence of CDC verification tools, users have a way to verify their
designs. However, first generation CDC tools provide inadequate support for a
top-down, bottom-up CDC verification methodology. Also, extensive manual
setup and signoff requirements create serious deployment limitations. This
causes inconsistent usage of the tools and wasted engineering resources without
covering the CDC failure risk.
The first generation CDC tools allowed improved verification of CDC interfaces.
However, these tools suffered from extensive manual and signoff requirements.
As a result, the deployment of these tools posed challenges as the design size
and complexity continued to increase. Hence, we are seeing ineffective usage of
these tools, wasting engineering resources without covering the CDC failure risk.
The paper is organized into eight sections, including this introduction. The
second section introduces metastability and the CDC reliability problem. The
third section introduces metastability fundamentals and principles for CDC
interface design. The fourth section identifies the verification principles for CDC
verification. The fifth section discusses practical usage of CDC tools and the
engineering resource requirements. The sixth section outlines an efficient CDC
verification methodology. Finally, the seventh section summarizes the metrics to
evaluate the quality of CDC solutions.
2.1) Understanding Metastability: When the latch input transitions within the
setup and hold window around the latching clock transition, the latch output can
become metastable at an intermediate voltage between logical zero and one.
Figure 1 shows a simplified latch implementation. Metastable state is a very
high-energy state as shown in Figure 2. Because of noise in the chip
environment, this metastable voltage gets disturbed and eventually resolves to a
logical value. The resolution time is dependent upon the load on the latch output
Real Intent Inc. & Sunburst Design, Inc. Page 2
and the gain through the feedback loop. However, it is impossible to predict this
logical value. Also, there is an inherent delay in the resolution of the metastable
output as shown in the timing diagram of Figure 3. This logical and timing
uncertainty introduces unreliable behavior in the design and, without proper
protection, can cause it to fail in unpredictable manners.
Real Intent Inc. & Sunburst Design, Inc. Page 3
For synchronous clock design, timing closure with static timing analysis ensures
that all paths meet timing. Metastability is avoided and the design operates
reliably.
2.3) CDC terminology: A clock domain is defined as the set of all flops that are
clocked by the associated clock. A clock domain crossing (CDC) is defined as a
flop-to-flop path where the transmitting flop is triggered by a clock that is
asynchronous to the receiving flop clock. These two clock domains are
considered to be relatively asynchronous. Figure 4 describes the CDC
terminology used in this paper. The receiving flops are referred to as CDC flops.
The signals feeding the CDC flops are referred to as CDC signals.
Real Intent Inc. & Sunburst Design, Inc. Page 4
2.4) Unavoidable Metastability and the CDC problem: Asynchronous clocks
operate without any mutual frequency and phase relationships. As a result, it is
impossible to guarantee timing on CDC paths because the launch and capture
clock edges can be arbitrarily close. Hence, metastability is unavoidable for CDC
designs. This invalidates both functional simulation and formal verification
assumptions and robust design behavior can’t be assured using simulation and
Static Timing Analysis. Without proper design, CDC errors can cause random
and unpredictable failures in the chip that are impossible to debug.
2.5) CDC Errors: Metastability introduces the following failure modes in the
design:
E1) Loss of correlation. This happens when two or more correlated CDC flops
become metastable as shown in Figure 5. Figure 6 shows the timing diagram
where these flops resolve to arbitrary logical values and hence, lose correlation
leading to a bad design state.
E2) Hazard capture. A hazard on a CDC path can get captured in the CDC flop
leading to bad design state as shown in Figure 7.
E3) Loss of signal. CDC signals that are stable for less than one clock cycle of
the receiving clock may not get captured in the receiving domain because of
clock network uncertainties, clock alignment and metastability. Figure 8 shows
the situation where functional verification view concludes signal transmission.
However, the signal transmission can actually fail leading to a bad state in the
design.
Real Intent Inc. & Sunburst Design, Inc. Page 5
Figure 6: Loss of Correlation Timing Diagram
Real Intent Inc. & Sunburst Design, Inc. Page 6
Figure 8: Loss of Signal
where τ is the resolution time constant dependent upon the latch characteristics
and ambient noise. This configuration resolves metastability with a very high
probability leading to a very large mean time between failures as governed by the
equation:
Real Intent Inc. & Sunburst Design, Inc. Page 7
where P is the probability that metastability is not resolved within one clock cycle.
Triple or higher flop configurations may be used for very fast designs.
Real Intent Inc. & Sunburst Design, Inc. Page 8
Data across the interface. Feedback Signal completes the handshake.
Transition on Feedback Signal is detected to drive Next Data to the interface.
Figure 11 shows the timing diagram for the protocol. It should be noted that this
is a simplified concept of the interface. We have not incorporated the logic
initializing the interface, detecting transition in Data Ready and dealing with
stalling conditions. All these considerations, combined with latency minimization
add complexity to the design of the interface.
Real Intent Inc. & Sunburst Design, Inc. Page 9
Figure 11: CDC Protocol Timing Diagram
All verification processes are iterative and achieves design quality by iteratively
identifying design errors, debugging and fixing errors and re-running verification
until no more errors are detected
Real Intent Inc. & Sunburst Design, Inc. Page 10
4) Verification run-time cost
5) Template recognition vs. Report quality tradeoff
6) Top level vs. Block Level verification tradeoff
7) RTL vs. Netlist verification tradeoff
There is consistent feedback from the users that the minimization of engineering
cost for high quality verification is critical for effective deployment of the CDC
tools.
5.1) Coverage of error sources: CDC errors can creep into a design from
multiple sources. The first is inadvertent clock domain crossing where there is an
assumption mismatch or oversight at block interfaces. The second is faulty block
level design. The designers, because of oversight or because of the pressure to
design correct and high performing interface, can make a design error. As an
example, consider the protocol in Figure 12. Here, tapping Feedback Signal
from an earlier flop stage can reduce the latency across the interface. However,
correct operation of this interface requires that the transmitting clock frequency
be slower than the receiving clock frequency. Otherwise, it is possible to signal
New Data before Load Data is completed.
These two error sources are properly covered by RTL analysis. They can also be
covered by Netlist analysis. However, not all CDC error sources are covered by
RTL analysis. That is because CDC errors are dependent upon glitches and
hazards. It is a well-known phenomenon that synthesis transformations can
introduce hazards in the design. Hazards in CDC logic lead to CDC failures.
Figure 13 shows an example of a design failure caused by synthesis. Here the
multiplexor implementation created a logic hazard that violated the multi-cycle
path requirement on the data bus. We are aware of multiple design failures
because of this phenomenon.
Real Intent Inc. & Sunburst Design, Inc. Page 11
Figure 13: Logic Hazard Caused CDC Failure
5.2) Design setup cost: Design setup starts with importing the design. With the
increasing complexity of SOCs, designs include RTL and netlist blocks in a
Verilog and VHDL mixed language environment. In addition functional setup is
required for good quality of verification. A typical SOC has multiple modes of
operation characterized by clocking schemes, reset sequences and mode
controls. Functional setup requires the design to be set up in functionally valid
modes for verification, by proper identification of clocks, resets and mode select
pins. Bad setup can lead to poor quality of verification results.
Given the design management complexity for the multitude of design tasks, it is
highly desirable that there be a large overlap between setup requirements for
different flows. For example, design compilation can be accomplished by
processing the existing simulation scripts. Also, there is a large overlap between
the functional setup requirements for CDC and that for static timing analysis.
Hence, STA setup, based upon SDC, can be leveraged for cost effective
functional setup.
Correct functional setup of large designs may require setup of a very large
number of signals. This cumbersome and time-consuming drudgery can be
avoided with automatic setup generation. Also, setup has the first order effect on
Real Intent Inc. & Sunburst Design, Inc. Page 12
the quality of verification. Hence, early feedback on setup quality can lead to
easy and effective setup refinement for high quality of verification.
5.3) Debugging and sign-off cost: The debugging cost is dependent upon the
number of errors flagged by the CDC tool. Assuming good setup, this in turn
depends upon the size and CDC complexity of the design and the maturity of the
design. Typically, debugging cost for top-level runs on immature designs will be
high. This is because the design may contain a large number of immature CDC
interfaces. This can generate a large number of failures requiring significant
debugging effort. Also, the ownership of these CDC interfaces may be
distributed between multiple designers.
Debugging cost is heavily dependent upon the reporting style of the tools. The
source code oriented reporting relates the errors to the real source: HDL
Real Intent Inc. & Sunburst Design, Inc. Page 13
functionality. Also, it produces much more compact reports. CDC verification
employs multiple technologies of increasing sophistication, like structural analysis
and formal analysis. Hence, a composite report is essential to determine the
overall quality of CDC verification.
Good clock domain, functional, structural and VCD visualization is essential for
effective debugging. Automated and advanced preprocessing of these views, to
isolate the error context, further reduces the debugging cost. Finally, debugging
support requires advanced sign-off capabilities so that the same issues are not
analyzed multiple times in the iterative verification flow.
As an example, consider the design in Figure 12. This reduced latency design
can operate correctly or can be erroneous depending upon the relative frequency
of the clock domains. Also, this structure can be included in a more complex
interface that handles stall and other issues making precise structural
identification difficult. If a structural technique does not compromise the quality of
checking, it has to flag this interface for manual review and signoff.
Formal application needs to be seamlessly integrated into the application all the
way from invocation to reporting and debugging. This eliminates a huge
overhead of integrating external formal analysis tools into the flow and to
correlate the results from these different tools to arrive at an integrated view of
verification status.
Real Intent Inc. & Sunburst Design, Inc. Page 14
As the computational complexity of formal analysis is very high, this can require a
large amount of computation time. However, this cost is well worth as it provides
significant savings in debugging and sign-off cost.
5.5) Template recognition vs. Report quality tradeoff: The first generation
CDC tools employed structural analysis as the primary verification technology.
Given the lack of precision of this technology, users are often required to specify
structural templates for verification. Given the size and complexity to today’s
SOCs, this template specification becomes a cumbersome process where
debugging cost is traded off for setup cost. Also, the checking limitations
imposed by templates may reduce the report volume but they also increase the
risk of missing errors. In general, template based checking requires large
manual effort for effective utilization.
5.6) Top-level vs. Block Level verification tradeoff: The top-level verification
reduces the setup requirements for CDC verification but can result in higher
Real Intent Inc. & Sunburst Design, Inc. Page 15
debugging cost as the design maturity improves iteratively. On the other hand,
block-level verification identifies errors earlier and at smaller complexity levels
there by creating a cleaner top-level verification. Hence, top-level debugging
cost reduces but the overall setup and run-time cost increases.
5.7) RTL vs. Netlist verification tradeoff: As mentioned before, Netlist analysis
can cover all the CDC error sources. The debugging cost is very high for
application at the Netlist level. Also, the delay in detecting errors until much later
in the design cycle can have a serious schedule impact. However, RTL analysis
does not cover all CDC error sources. This requires that CDC verification must
also be run on Netlists.
Real Intent Inc. & Sunburst Design, Inc. Page 16
Figure 16: Top Down-Bottom Up Verification Flow
Real Intent Inc. & Sunburst Design, Inc. Page 17
7) A framework for evaluating CDC solutions: Based upon the above
presentation, we have formulated the metrics for evaluating the quality of CDC
solutions. Our attempt is to summarize the relationship between various
attributes. We use a generic symbol f(attribute) to represent the quantification
associated with the attribute. For example, f(types_of_err) is the factor
contributed the extensiveness of error checking conducted by the tools and
f(templ_req) is the factor measuring the complexity of setting up the checking
templates. These metrics are defined below.
1 _ – _
2 _ _ _ _ – 2 _
3 .
4
_ _ _ _
# _
5
# _
,
6
# _ _
7 _ , _ _ _
Figure 17: Spiderchart for 1st and 2nd Generation CDC Tools
Real Intent Inc. & Sunburst Design, Inc. Page 18
About the Authors:
He was the project leader for test and verification for UltraSPARC
IIi at Sun Microsystems. He was an architect of the Mercury
Design System at AMD He has architected and developed CAD
tools for test and verification for IBM EDA.
Clifford E. Cummings
Cliff holds a BSEE from Brigham Young University and an MSEE from Oregon
State University.
Real Intent Inc. & Sunburst Design, Inc. Page 19
Bibliography
Cummings, C. (2001, 3 31). Synthesis and Scripting Techniques for Designing
Multi-Asynchronous Clock Designs. Retrieved 2 1, 2008, from Sunburst Design,
Inc.: http://www.sunburst-
design.com/papers/CummingsSNUG2001SJ_AsyncClk.pdf