# Clock and Data Recovery/Structures and types of CDRs/The CDR Phase and Frequency Detector PFD

Many practical (slave) clock recovery circuits with a PLL architecture require some type of frequency acquisition aid.
Exceptions are only found where very stable VCOs, such as crystal oscillators, are used to insure that the frequency error is never larger than the natural acquisition range of the PLL (a range that is close to the PLL closed-loop bandwidth ).
Excluding these stable VCOs, and other acquisition aids, such as frequency sweeping, a frequency discriminator is required as an integral part of any phase-detector for modern monolithic CDRs ( pages 259..260 ).

## Frequency (comparison and) detection

A serial stream of NRZ data arriving at a pulse frequency f$_p$ is not distinguishable from a stream at 2f$_p$ made of pairs of identical pulses, nor from a stream at 3f$_p$ made of triplets of identical pulses.
Some additional information about the absolute value of f$_p$ is necessary to correctly recover clock and data. Since the uncertainty comes in steps of 100% of f$_p$, an indication of f$_p$ with an approximation of +/- 50% is (barely) sufficient.
In practical CDR applications the uncertainty is always contained within ± 25% and in most cases within ±5% (most of this uncertainty comes from the inaccuracy of the VCO free running frequency) . Additional circuitry that can detect the frequency of the incoming data in that range will be adequate, as it will be shown.
       In frequency synthesisers the problem of frequency aided acquisition is equally important as in CDRs, but in synthesisers the incoming signal and the local clock are both perfectly periodic waveforms and a phase and frequency detector with a simple architecture can be used. A straight forward comparison of the respective cycle period is possible, and effective. On the other hand, synthesizers often require capture ranges well in excess of +/- 25%.
       In CDRs instead, the missing transitions of the incoming signal make the frequency comparison with the local clock a more complex affair.

### Need for frequency detection (in addition to phase detection) in CDRs

A loop filter is inserted between phase comparator and VCO, in CDRs where jitter and noise performances are important (Architectures 2 - 1 and 2 - 2).
Both for architectures 2-1 and 2-2, when high transmission speed is involved, a jitter-out / jitter-in bandwidth of about 1/1000 of the bit rate is specified by most standards.
       The "jitter-out /jitter-in" bandwidth, called ω$_{n2}$ in the modeling of these 2nd order loops, is therefore specified and made by design to be around ω$_p$/1000 ( ω$_p$ is the angular frequency of the pulses of the received stream, 2π f$_p$ = ω$_p$).
A significant ω$_{fr}$ / ω$_p$ mismatch (much larger than the capture range) is often the case, in particular in large volume, cost-effective monolithic implementation, where the VCO free-running angular frequency ω$_{fr}$ is no more accurate than about +/- 5% ( ICs manufacturing tolerances are not tighter than ± 25%, but recourse to end-of-production trimming can correct them and reduce the inaccuracy range to something like within ± 5% ).
       The accuracy of f$_p$ is not the problem in modern networks, where it is better than +/- 50 ppm. It is the poor accuracy of the VCO free-running frequency f$_{fr}$ that makes the aid to the acquisition necessary. ω$_p$ = 2 π f$_p$; ω$_{fr}$ = 2 π f$_{fr}$
       There are many more slave nodes than master nodes in a network, and the master nodes are more critical than the slaves. A larger cost (-> including a tighter accuracy) can be afforded for the masters, making ω$_p$ -that originates in a master node- (much) more accurate than ω$_{fr}$ -that originates in a slave receiver-.
Without aids, the capture range of the CDR is approximately coincident with +/-( jitter-in / jitter-out bandwidth) around the free-running frequency of the VCO.
If the free-running frequency is so shifted (away from the incoming pulse frequency) that the capture range does not include the frequency of the data to lock into, the phase comparator alone cannot make the acquisition possible.
       The data transitions pass in front of the local clock faster than it can shift its frequency to catch one of them, with no chance to achieve phase lock.
       In fact, these CDRs react in a time of about 1/(2 times the capture range), and a new input transition shifts inside the range of the phase comparator (while the previous one drifts away), before a significant part of that time has elapsed.
       The PLL goes through alternate periods of accelerating and decelerating, with slips in between, but never achieves phase lock.
       Sometimes, when ω$_p$ is close to ω$_{fr}$ ± ω$_{n2}$, a series of slips may eventually end in a good phase lock. The acquisition may be achieved but with slips and unpredictably long times.
       Aided acquisition is then mandatory.
In such cases the acquisition must be aided by additional circuits that widen the capture range.
       Inside of a complex system another clock with good enough accuracy may be available. A frequency close to f$_p$ can be easily synthesized, and a frequency detector of clock differences can be used. Its output will be summed to the CDR PD output.
       There have been also cases where frequency sweeping was used to have the capture range overlap f$_p$.
       Note that the VCO must be driven by a unique signal, even if the drive signal is obtained by combination of two separate ones. (A VCO with two inputs is a "bad idea" within the scope of stable control systems, see also at page 261).
Tight jitter bandwidth and wide acquisition range can be achieved together if the CDR includes a Frequency Detector (FD) in addition to its Phase Detector (PD), as it is often the case.
       Sometimes a separate FD for CDRs is used in parallel to the PD, but this is a rare occurrence.
The two blocks are normally physically and functionally combined, and the overall block/function is named phase-frequency detector PFD, which also offers the benefit of automatic transition from the operation of the one to the other as soon as lock is achieved.
A PFD may incorporate one to two linear PDs, but more often incorporates bang-bang PD(s).
The bang-bang structure of the PFD in practical applications is a consequence of the application requirements. It will be shown that the (bang-bang) PFD is used in CDRs of the 2-2 type, that are made with bang-bang phase detectors.
    Architectures of the 2-1 type normally find application in association with accurate VCOs, and architectures of the 1-1 type are used for phase aligners that have a perfectly accurate local clock by definition.
The frequency detection in practical applications is part of a monolithic implementation of the CDR, working at the highest speed that the chip technology allows. Then the implementation will be based on discrete time instants and binary signal levels, as mentioned already for PDs.
    To reinforce the general validity of the above point, another aspect of the IC industry must be appreciated. When a new, faster chip technology appears, it will be used to create new CDRs at higher speed, as the mentioned paper emphasizes. But this new technology will NOT be used for a redesign of the CDRs made in an earlier technology pushing that technology to its speed limit. The semiconductor industry is always short of good designers, and at the same time it is difficult to replicate exactly the performances of an IC in a different, though older, technology. Additionally, customers are reluctant to undergo again the cost of chip qualification. Scarcity of design resources, risk of not making a good replica and customer reluctance for a re-qualification, all cooperate to the result that a successful mixed-signal chip is practically never redesigned. This also implies that architectural alternatives of an existing solution (that become possible with the appearance of a later and faster technology) are practically never implemented!
In a CDR the Frequency Detector must accomplish a very basic, simple task: bring the VCO frequency close enough to the pulse frequency of the incoming signal, so that the Phase Detector can take effect and drive the phase lock.
Simple tasks mean simple requirements: the Frequency Detector need not be linear, need not offer the highest gain possible, it shall just ensure a reasonably fast frequency acquisition for realistic frequency differences and must become unnoticeable as soon as the Phase Detector is able to take over. The important performance of the CDR are influenced by the PD, not by the FD: the FD is just required not to limit the PD performances.
The PFD used in CDRs are of the bang-bang type. The FD function is active outside of the frequency range where the PD can capture the incoming signal, and the FD effect disappears completely as soon as the PD function can take over.
    This is why the Frequency Detector is normally neglected in modeling and often also in simulation of the CDRs.

## Methods of frequency detection in CDR

Many different types of PFD for CDR can be conceived, with different levels of complexity and performance.
    $_{Asexplainedinthepreviousparagraph,thePFDforCDRisactuallyimplementedinthesimplestpossibleform.}$
It has been shown earlier that to detect a phase difference in the CDR, the transitions of the data signal are compared with the transitions of one clock.
To detect a frequency difference f$_p$ - f$_{VCO}$, the transitions of the data signal shall be compared with the transitions of two clocks of equal frequency (f$_{VCO}$) that just have a constant phase distance. (= difference):
      * the only time-base available in a CDR to generate t$_1$ and t$_0$ is the VCO itself. In fact, t$_1$ and t$_0$ shall come from VCO dedicated waveforms (= clocks).
      * t$_1$ and t$_0$ shall have a fixed phase distance inside the VCO cycle.

### Two comparators

In the right hand side of the last equation, the two differences of the nominator have been highlighted with bold characters and underlined.
They represent the outputs of two phase comparators, the first comparing the data transitions with transitions ( of a VCO clock ) in t$_1$ , and the second comparing the data transitions with transitions ( of a second -shifted- VCO clock ) in t$_0$ .
    Each individual phase difference will vary with time, and indicate a constant frequency difference if it exhibits a cyclic behavior, but neither alone can tell the sign of the frequency difference!
Combining the results of the two comparisons together it is possible to identify also the sign of the frequency difference.
          ( Provided the two clocks do not differ in phase exactly by 0$^0$ nor by 180$^0$: the frequency difference signal would be completely attenuated in those two extreme cases!
          The two phase comparators -different just because their two versions of the VCO clock are separated by 0° or by 180°- would always produce either coincident results or always complementary results, i.e. the very same information! )
          Note that phase comparators used in CDRs have a characteristic that is periodic with an odd symmetry and that is growing and monotonic inside each period.
The best discrimination (= the most robust signal) is obtained when the distance between the two identical comparators is chosen to be exactly 90$^0$ (or 270$^0$).

### Two clocks with 50% duty-cycle and separated by 90°

Two clocks with 50% duty-cycle and orthogonal with each other (that is 90$^0$ or π/2 out of phase) make the two phase comparators divide all the 360$^0$ of their period into 4 quadrants.
The two phase comparators together indicate the quadrant where the data signal transition is located, and this info can be updated at every new data transition.
       This type of frequency detectors are called "rotational" frequency detectors.
       In the same paper Donald Richman first introduced the term "quadricorrelator" applying PFD to NTSC color carrier detection in color television and describing an analog version of the circuit that uses both an In-phase and a Quadrature clock to obtain a beat note at double frequency and a d.c. component proportional to the frequency difference. (Quadrants defined with Phase and Quadrature clocks, hence the name quadricorrelator). Although the quadricorrelator operation may not be very good with the random transitions of a NRZ data stream without some modifications ( page 269), the I and Q technique is good also for CDR PFDs.
* I (lag in the figure), is the reference and defines with its positive transition the 0$^o$ instants. I stands for In-phase; (When PD and FD are combined and part of a CDR, then I is the clock used for data regeneration).
* Q (lead by 90° in the figure) identifies the -90$^o$ or 270$^o$instants. Q stands for "Quadrature".
       Before lock, the data transitions shift with respect to the two clocks.
       When a data transition is first detected inside the interval "I leads Q" and then detected inside the interval "Q leads I", the data transitions are shifting to the left.
       The data transitions are therefore based on a frequency lower than the frequency of the two clocks.
       In such condition, the VCO of a PLL shall be driven towards a lower frequency, that is with a lower level of the VCO drive signal.
       When a data transition is first detected inside the interval "Q leads I" and then inside the interval "I leads Q", the data transitions are shifting to the right.
       The data transitions are then based on a frequency higher than the frequency of the two clocks.
       In such condition, the VCO of a PLL shall be driven towards a higher frequency, that is with a higher level of the VCO drive signal.
If the two I and Q clocks have both 50% duty cycle, using also their negative transitions, all 4 quadrants can be identified.
       The frequency sign can be obtained each time the data transitions, after a detection in a given quadrant, cause a detection in a quadrant to the left (f$_p$ lags f$_{VCO}$), or to the right. (f$_p$ leads f$_{VCO}$)

### Bang-bang = just the sign of the frequency difference

The PFD is mostly used for monolithic CDRs made with the 2 - 2 architecture, where the Phase Detector is of the bang-bang type.
Therefore, the PFD will be of the bang-bang type as well.
* the two PDs of the PFD are of the bang-bang type to start with. Their outputs only give one bit indication. The nominator in the PFD formula is reduced to a sigle bit as well. (Or to a "ternary" type of output, if the overall CDR needs minimum jitter generation).
* the time difference in the denominator of the PFD formula is a fixed fraction of the local clock (=VCO) cycle. It has always a positive sign, even if it may vary (inversely) with the VCO frequency. Therefore, it is disregarded in a bang-bang PFD (replaced by a constant +1).
In other words, the PFD will just output an indication as simple ( binary or ternary ) as the phase detector that operates on its I clock.

## How a bang-bang PFD is made

It is made up of two PDs and one final block that processes the outputs of the two PDs.
One PD operates on the input data stream and on the VCO clock that shall be locked to the data. This clock is called the I (= In phase) clock.
The other PD operates on the input data stream and on a VCO clock that is 90°, i.e. π/2, out of phase with the previous one. This clock is called the Q (= Quadrature) clock. It could be +90° or -90° out of phase with I : let's choose here +90°, which means that the Q waveform lags the I waveform.
In a typical example, the two outputs from the two PDs are put together in a following block that is essentially the same as the output stage of the "hold" bang-bang PD.
This structure works with signals as follows:
* the clocks of the first PD are:
   * the clock that regenerates the data and
   * its 180° shifted version
* the clocks of the second PD are both shifted versions of CK$_0$ that regenerates the data, respectively:
   * by 90° and
   * by 270°,
which partitions the VCO period into the four quadrants already mentioned.
The two clocks of each PD are 180° out of phase with each other.
The outputs of the two PDs are combined in a final stage identical to the final stage of the "hold" PD: this PFD becomes a "hold" (= binary) PFD.
The output of the PFD may be present a polarity inversion if:
* the shift of the Q clock of the second PD is -90° instead of +90° with respect to the clock I (the other clocks do not matter, as +180° is indistinguishable from -180°);
* the final stage either uses an inversion after the top flip-flop or an inversion after the bottom flip-flop.
An example of the waveforms in case of a constant frequency difference is shown in the following figure (note the inversion of the PFD output):
This system is a discrete time system with samples at frequency f$_{VCO}$, and a data transition should be sampled at least once every time it drifts through one of the four quadrants. Each drift trough a quadrant should last at least 1/ (4f$_{VCO}$).
A data transition has been sampled inside one quadrant. The following data transition (D$_T$ = 100%), while the data stream drifts across the quadrants defined by Q and I, should preferably be sampled (at least once) inside each quadrant. The sampling takes place if the period of 1/f$_{VCO}$ stays inside the range 1/$_{fp}$ +/- 25%.
D$_T$ is normally lower than 100%. The maximum Δf that this type of PFD can detect is ±25%, even if the technique of "hold"ing the detection when no transition is present could extend the theoretical range to ±50%.
If the frequency difference to detect is in the range of ±15% or larger, then it is preferable that the two PDs artificially "hold" the previous detection of the phase until a new significant detection can be made, and that the FD does the same (Binary PFD ).
If instead the frequency difference to detect does not exceed ±10%, then the two PDs might still be of the "hold" type, but the last PFD stage would be improved to a "free running" type (Ternary PFD).
       The feature can be obtained in principle by a retrofit that:
      * extracts also the T signal from the PD operating on the I clock
      * drives the charge pump following the PFD output with the two signals: UP = T + E ; DOWN = T*E.

#### A bang-bang Phase Detector that "holds", in a different representation

This kind of PD has already been introduced in the previous page about PDs.
It is presented again here with identical behavior, but using a different set of circuit symbols that better represent the circuit elements of a high-frequency integrated circuit.
High frequency circuits are fully differential for noise immunity, making a signal and its complement always available together. Exchanging one wire with the other of a differential pair corresponds to the inversion of the signal: no inverter stage is needed. Multiplexers are easy to implement. Two flip-flops and a multiplexer make up a double edge triggered flip-flop DETFF.
In this case, the two DETFFs allow the use of clocks at half the frequency because both edges of the clocks are used (clocks must have 50% duty cycle).
The clocks that drive the two flip-flops, are indicated as the I (lead) and Q (lag, i.e. 90° late) clock phases coming out of an oscillator that runs at half the data pulse frequency. They are equivalent to two clocks of double frequency and separated by 180°.
This anticipates the incorporation of two of these PDs in a PFD that uses their outputs to detect the sign of the frequency difference, in a CDR that uses a muli-phase VCO at half the frequency.
The output of the first DTEFF carries the regenerated data, the output of the second DETFF carries the cross-over samples taken at the instant when a data transition is expected.
It may be noted that this PD is made up of three DETFFs, but the third is slightly modified with an inversion at the output of its upper flip-flop.
This inversion in the upper branch of the last stage sends to the output:
* the last cross-over sample when the data have a positive transition (and as long as they stay high);
* the opposite of the last cross-over sample when the data have a negative transition (and as long as they stay low).
Inverting on negative transitions and not inverting on positive ones makes the PD output go high if the clock lags the data, and viceversa.

#### A bang-bang PFD with reduced VCO frequency for easier implementation inside an IC

The following figure redraws the PFD presented earlier changing two aspects:
* the elementary blocks of high frequency monolithic circuits are used (DETFF, differential connections and the multiplexer),
* the input clocks come from a VCO at half the frequency.
A very similar one, just with I that lags Q, is described in.
The Q clock lags the I by 90°. When acquisition is achieved, CK$_0$( i.e. I) is where it should be. The PD$_2$ will output a constant 1, because Q is late by exactly 90° and should accelerate.
But in this condition the output of PD$_1$ is replicated at the output of the PFD and drives the PLL alone. PD$_2$ remains constantly at 1, phase-locked into its 90° lag state by the PLL operation.
Otherwise said, when the PFD is part of a CDR that reaches the phase lock, its output replicates the output (or the inverted output) of the PD that acts as clock of the PFD final stage.
This means inverting the output of the top flip-flop in the final stage if the second PD uses a clock 90° late (like in the waveforms below and in the schematic of the figure above), and inverting the output of the bottom flip-flop in the final stage if the second PD uses a clock that is 90° early.
The figures that follow represent the waveforms at the external connections as well as at the internal nodes of one PFD like in the figure above.
The first figure describes the case of an input signal with the highest possible DT (i.e. 100% and a data pattern 101010..).
The second figure describes the case of an input signal with a random data pattern.
In both cases the clocks (nominally at half frequency) and the input data of the PFD correspond to frequency ratios different from the nominal value of 50%.
In the case of maximum transition density (in spite of a large frequency difference) the waveforms are as regular as it could be expected. The two phase detectors toggle at the beat frequency, and overlap each other transitions.
The PFD output (almost) immediately reaches a stable indication of the sign of the frequency difference. In a closed loop this means the fastest possible acquisition transient.
With a random pattern of the received pulses, the waveforms are much less regular.
As a result, the PFD output is far from stable, but at least its average deviates from 50% enough to give a clear indication of the frequency difference.
Every time the generation and recording of these waveforms are repeated, the figure for 101010 data is practically the same.
The figure for random input data instead changes significantly with the change of the sample of the input pattern, but the average value of the PFD output, although variable as well, remains on the correct side of 50%.

## Acquisition of Frequency and Phase Lock

The following example refers to a CDR with a 2 -2 architecture, incorporating a PFD like the one described in the previous paragraph.
The figure is obtained by a simulation with 3000 time steps.
The waveforms of the two Phase Detectors are shown at the top, translated higher not to overlap the analog waveforms.
       Neither the line pulse sequence nor its frequency are used in the simulation of the waveforms of the voltages and angular values depicted.
       Therefore the Q clock operation is simulated by the trick of replicating at the PD2 input the input signal phase with a 90° shift (= delay, Q lags I).
Initially (100 time steps) no signal is present, LOS is asserted and the VCO runs free.
Then the signal appears (LOS=0), and the frequency locks begins.
       The PD1 and PD2 gains correspond to the maximum transition density, to simplify the simulation and to shorten the acquisition for easier fitting inside the figure.
After about half a μsec the square waves coming from the two PDs widen clearly their periods and the filter output follows a linear ramp towards the driving voltage that brings the VCO to the lock frequency.
After a little more than 3 μsec and some phase undershoot the acquisition is complete.
The bang-bang tracking begins, and the output phase tracks the input (that has a slight downward slope because its frequency is slightly lower than its nominal frequency).
The error function becomes stable at about -50 rad, that correspond to the slips before lock.
Sometimes later, a little before 6 μsec have elapsed, a substantial input sinusoidal jitter appears. The filter output shows that the limits of tracking ability of the loop are slightly exceeded during every jitter cycle. But not much, as the error function does not show a strong evidence of it.

## External References

* 1 2 3 4 5 Richard C. Walker (2003). "Designing Bang-Bang PLLs for Clock and Data Recovery in Serial Data Transmission Systems" (PDF). pp. 34-45, a chapter appearing in "Phase-Locking in High-Performance Systems - From Devices to Architectures", edited by Behzad Razavi, IEEE Press, 2003, ISBN 0-471-44727-7.
* ↑ http://www.unhas.ac.id/rhiza/arsip/research-stuffs/Phase-Locked/218-PhaseDetector-2.pdf
* ↑ Clock Recovery Primer, Part 2 by Guy Foster, par.10: Survey of Clock Recovery Used in Selected Standards
* 1 2 3 Aaron BUCHWALD Hong Kong University of Science & Technology, Kenneth W. MARTIN University of Toronto Toronto, Ontario, Canada. "Integrated Fiber-Optic Receivers" (PDF).{{cite web}}: CS1 maint: multiple names: authors list (link)
* ↑ Behzad Razavi, Design of Monolithic Phase-Locked Loops and Clock Recovery Circuits-A Tutorial, 4.6 Aided Acquisition, downloadable at: http://itee.uq.edu.au/~coms3100/coms3100/Lecture%20Notes/Razavi1996_PLL_IEEExplore.PDF
* ↑ S. Tontisirin and R. Tielert, 2.5 Gbps clock data recovery using 1/4th-rate quadricorrelator frequency detector and skew-calibrated multi-phase clock generator, Adv. Radio Sci., 4, 287–291, 2006 http://www.adv-radio-sci.net/4/287/2006/ars-4-287-2006.pdf © Author(s) 2006. This work is licensed under a Creative Commons License. Advances in Radio Science
* ↑ Donald Richman. Color-carrier reference phase synchronization accuracy in NTSC color television. Proc. IRE, 42:106–133, January 1954.
* ↑ P.E.Allen, June 26 2003, Lecture 200 - Clock and Data Recovery Circuits from ECE 6440, page 200-15..17, http://users.ece.gatech.edu/pallen/Academic/ECE_6440/Summer_2003/L200-CDR-I(2UP).pdf
* ↑ Jafar Savoj and Behzad Razavi, A 10Gb/s CMOS Clock and Data Recovery Circuit with Frequency Detection, ISCC 2001
| ← Clock and Data Recovery/Structures and types of CDRs/The CDR phase comparator | Clock and Data Recovery | Clock and Data Recovery/Structures and types of CDRs/The CDR' VCO → |