Fractional-N Frequency Synthesizer

Design Spectra Loop Filter MASH Simulation Back to projects 15-25 MHz Synthesizer

MASH Sequence

The output of the MASH structure is a repetitive pseudo-random sequence. The mean value of ΔN has a very useful property

Where MOD is the modulus of the overflowing accumulators within the MASH. The length of the sequence depends on MOD and is typically very long. The range of values which ΔN can take depends on the number of stages (order) of the MASH.

Noise shaping

MASH output noise is concentrated at higher frequencies which are attenuated by the loop. The graph opposite illustrates the effect, known as noise shaping. This is the spectral content of the PFD output. The log frequency scale is normalised to sequence repetition rate, which is a very low frequency. I simulated a 4th order MASH with 16-bit accumulators and fractional command F=1.

  Here's the code which generated the graph opposite.
Right-click and Save-Target-As to download Mash.cpp

Since MASH output noise rises at 80 dB per decade for a 4-stage MASH, and the divide-by-N (ΔN freq phase) is an integration, I expected a 60 dB per decade slope; but, as another simulation better illustrates, there are distortion products rising at 20 dB per decade superimposed on the anticipated 60 dB slope. The PFD output is a form of PWM, which is inherently distorting; but why the 20 dB slope?

Software simulation

Although the PFD output waveform is complex, it is (a) predictable and (b) periodic enabling us to perform Fourier analysis. The procedure is actually very simple:

  • Generate MASH sequence
  • Calculate the position of every edge in the PFD output waveform
  • Perform Fourier analysis on the superposition of pulse trains
Having thus calculated PFD output noise, we could estimate VCO phase noise by overlaying the PLL closed-loop gain: i.e. multiplying the complex Fourier coefficients by the PLL transfer function at each offset. Finally, since modulation index is very low, spur amplitude can be predicted using the NBFM approximation. The only problem is: this analysis starts with the assumption of zero jitter at the VCO output! Oh dear. How to close the loop? A Google search turned-up several interesting papers on this subject.

Update May 2007: Please visit my PLL Simulation page.

Returning to my "open loop" simulation, the MASH sequence ΔN is generated using C++ class MASH as follows:

    MASH m;

    for (int i=0; i<SEQLEN; i++) Delta[i] = m.Clock();

From the ΔN sequence, it's easy to calculate the position, width and polarity of every PFD output pulse:

    int t=0;

    for (i=0; i<SEQLEN; i++)
        t += Delta[i];

        tVCO[i] = (i+1)*N + t;
        tREF[i] = (i+1)*N + (i+1)*double(F)/double(MODULO);
tVCO and tREF are the positions of the VCO and Reference edges. See below for derivations.
tVCO is integral because times are normalised to VCO period.

Finally, we calculate Fourier series coefficents for the repetitive PFD output waveform:

    // 2L = Sequence length (in VCO periods)
    const double L = SEQLEN/2 * (N + double(F)/double(MODULO));

    for (double h=1; h<1e7; h=h<100?h+1:h*1.01)
        double a=0, b=0, n=floor(h);

        // Superposition of pulses
        for (i=0; i<SEQLEN; i++)
            // Fourier series integrals over period 0....2L for nth harmonic
            a += 1.0/n/PI * (sin(n*PI/L*tVCO[i]) - sin(n*PI/L*(tREF[i])));
            b -= 1.0/n/PI * (cos(n*PI/L*tVCO[i]) - cos(n*PI/L*(tREF[i])));

        printf("%g,%g\n", log10(n), 10*log10(a*a + b*b));
See below for derivations.
By replacing 1.0/n/PI with (tREF[i]<tVCO[i]?1.01:1.0)/n/PI, a 1% charge pump imbalance can be investigated.

For clarity, this code is unoptimised. It's unnecessary and inefficient to call trig functions in a loop like this. A dramatic performance improvement can be realised using recurrence relations, which made it practical for me to do a 24-bit simulation for my MASH theory page.

PFD Output waveform

Relationship between reference period and VCO period

All times are normalised to the VCO period in the C++ code.

Position of i th reference edge

Position of i th VCO-divider edge

Fourier series

The Fourier series coefficients an, bn of the nth harmonic of a repetitive function f(x) with period 2L are

Using the principle of superposition, the Fourier coefficients of the PFD output sequence can be found by calculating and summing the coefficients of each individual pulse separately. The coefficients for a pulse of amplitude IPD starting at time t1 and ending at time t2 are

The following limits are substituted into the above integrals

Leading edge Polarity Integral limits
IPD > 0
t1 = tREF
t2 = tVCO
IPD < 0
t1 = tVCO
t2 = tREF

Negative signs conveniently cancel yielding the same expressions for both +ve and -ve pulses

Fractional-N PLL Simulation Links

A digression ...

PWM Distortion

The Fourier analysis technique used above can be applied to any repetitive rectangular signal. Take 65536 uniform PWM samples over 64 cycles of a sine wave for example:

#define SEQLEN 65536

for (int i=0; i<SEQLEN; i++)
    tRise[i] = i;
    tFall[i] = i + 0.5 + 0.5 * sin(2*PI*64*i/SEQLEN);

// 2L = Sequence length
const double L = SEQLEN/2.0;

The graph reveals harmonic distortion at 128, 192, 256 and 320. The sampling rate is visible at 65536.

Let's try a 2-tone test:

  tFall[i] = i + 0.5 + 0.25 * sin(2*PI*69*i/SEQLEN)
                     + 0.25 * sin(2*PI*64*i/SEQLEN);
1st   fa = 69
fb = 64
2nd fa−fb = 5   2fa = 138
2fb = 128
fa+fb = 133
3rd   2fa−fb = 74
2fb−fa = 59
  3fa = 207
3fb = 192
2fa+fb = 202
2fb+fa = 197
4th 2fa−2fb = 10   3fa−fb = 143
3fb−fa = 123
  4fa = 276
4fb = 256
3fa+fb = 271
3fb+fa = 261
2fa+2fb = 266

Now we've got intermodulation distortion (IMD) as well. The lowest beat note is 69 - 64 = 5. The product amplitudes give a clue to their order.

The intrinsic nonlinearity of uniformly sampled PWM produces in-band distortion: the signal is corrupted; a perfect replica of the baseband cannot be recovered by low-pass filtering. Naturally sampled PWM on the other hand, which can be generated by applying the signal and a triangle wave to a comparator, is linear within the baseband frequency range.