Algorithmcore
Early-late gate synchronizer
Also called early-late gate, early-late timing detector.
A timing loop that compares the energy of the matched filter output a little before and a little after the sampling instant, and moves the instant toward the side with more energy.
- Solves
- Symbol timing recovery
- Time
- O(N) worst
- Space
- O(1) extra
- Where
- N = the number of symbols
- Model
- Real RAM
- Properties
- carrier phase invariantdeterministicnon data aidedonline
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Marvin K. Simon, 1970
The early-late gate synchronizer is a feedback loop for symbol timing recovery. The output of the matched filter has its largest energy at the correct sampling instant, and the energy curve is symmetric around that point. So the loop takes two extra samples, one a time before the current instant (early) and one a time after it (late), and uses the difference of their squared magnitudes as the timing error. A loop filter and an accumulator, as in a phase-locked loop, move the instant until the two energies balance. The detector needs no decisions and no carrier phase. For raised cosine pulses its mean output is for the timing error , so it works only with excess bandwidth , and it gives no error signal at all when . The same early-late structure tracks a spreading code in the delay-locked loop. The Gardner detector uses fewer samples and has less self-noise, and the Mueller and Muller detector uses decisions at one sample per symbol.
In plain words
Each received pulse rises to a peak and falls again, and the receiver should read it at the peak. The receiver does not know where the peak is, so it takes three readings: one at its current guess, one a little earlier and one a little later. If the later reading is stronger, the peak is later than the guess, and the guess moves forward a small step. If the earlier reading is stronger, the guess moves back. Since one pulse overlaps its neighbors and the data change from symbol to symbol, a single comparison can point the wrong way. The loop takes small steps, so these errors average out over many symbols. The comparison uses only the strength of the signal, so it works before the receiver knows the data or the phase of the carrier.
The problem
Times are in symbol periods, . The receiver can sample the matched filter output
at any time : with an analog-to-digital converter whose clock it controls, or with an interpolator such as the Farrow interpolator on a fixed sample grid. Here is the overall pulse (a raised cosine with roll-off in the analysis), are unknown independent symbols with and , is an unknown carrier phase, is the filtered noise with , and is the unknown delay, which may drift slowly. The loop must output estimates such that the strobes are taken at the pulse peaks.
The algorithm
EARLY-LATE-GATE(y, N, Kp, Ki, tau0, d)- 1
tau <- tau0; s <- 0 - 2
for k <- 0 to N - 1 do - 3
early <- |y(k + tau - d)|^2 - 4
late <- |y(k + tau + d)|^2 - 5
e <- late - early ▷ positive: the strobe is early - 6
est[k] <- tau; strobe[k] <- y(k + tau) - 7
s <- s + Ki * e ▷ loop filter - 8
tau <- tau + Kp * e + s ▷ timing accumulator - 9
return est, strobe
Lines L3 and L4 take the early and late samples at a distance from the strobe; gives the largest slope. Line L5 is the square-law detector. Line L6 is the on-time sample that goes to the detector of the data. Lines L7 and L8 are the loop of the PLL, with the phase replaced by the delay: gives a first-order loop, which follows a constant delay, and gives a second-order loop, which also follows a clock frequency offset (a delay that grows linearly). For a first-order loop with noise bandwidth , the gain is , with the detector slope at unit symbol energy.
Example
Take QPSK data (seed 1), , the true delay , no noise and no carrier phase. The gate half-width is , so , and gives with . The loop starts at :
| early (L3) | late (L4) | (L5) | (L8) | ||
|---|---|---|---|---|---|
| 0 | |||||
| 1 | |||||
| 2 |
The mean error at is , but single values range from to in these three steps: the data pattern decides each one. The error is at , at , at , at and at . After that the loop does not settle to a point. It jitters around the delay with an rms error of and peaks of , without noise, because the detector has self-noise. For alternating data the self-noise is zero, and the tests check that the loop then stays at to .
In noise at dB with , the loop form of the MCRB is , with for . Three runs of 2400 symbols (seeds 7, 8 and 9) measured a variance of to times this bound (measurement).
Correctness
Claim. For raised cosine pulses and independent zero-mean data, the mean of with held fixed is with , for every carrier phase and every stationary noise. So the loop has its stable points at and behaves near lock as a PLL with detector gain .
Key steps. The mean of is plus the noise power, because the cross terms between symbols have mean zero. By Poisson summation, this folded energy of a raised cosine is : only the spectral lines at and survive, since has a band below 2 cycles per symbol. The late sample minus the early sample removes the constant and the noise power and leaves the sine. The full proof is in the proofs file.
The S-curve is a closed form under assumptions: raised cosine pulses, independent data, and constant while the mean is taken. The jitter of the example is a measurement.
Proof: The square-law early-late gate has the S-curve (beta/2) sin(2 pi d) sin(2 pi Delta) for raised cosine pulses, so the loop locks at the true delayfull
Times are in symbol periods, . The matched filter output is , where is a raised cosine pulse with roll-off , the data are independent with and , is any carrier phase and is noise independent of the data. Line L6 strobes at . Lines L3 and L4 take the early sample and the late sample , and line L5 forms . Write for the timing error. The S-curve is the mean of over data and noise with held fixed.
Lemma 1 (folded energy of the raised cosine). For every real ,
Proof. The function is integrable and its Fourier transform is , where is the raised cosine spectrum. is for , for , and beyond. By the Poisson summation formula, . is zero for , and , so only remain. First, . Second, , and the product is nonzero only for with . There and , so the product is and its integral is . because is even. So the sum is .
Lemma 2 (mean energy at an offset). Without noise, . With noise, a constant is added if is stationary.
Proof. . The factor has modulus one. Expand and take the mean: the cross terms are zero for , so the mean is . Lemma 1 with the integer shift gives the formula. The noise is independent of the data and has zero mean, so its cross terms with the signal vanish too.
Theorem 1 (S-curve). For every gate half-width and every carrier phase ,
The slope at is . It is largest at and zero at .
Proof. By Lemma 2 with and , the constant terms and the noise power cancel, and
The derivative in at is .
Theorem 2 (lock points). For , the mean error is zero at . The points are stable for the update with , and the points are unstable. So, in the mean, the loop locks at modulo one symbol.
Proof. is zero exactly at . Near , with , so a positive error (the receiver is early) gives a positive step of , which reduces . Near the slope is and the step moves the error away. The linear analysis of the phase-locked loop, with the phase replaced by , gives convergence for in the first-order loop and for the Jury conditions in the second-order loop.
Theorem 3 (exact lock on alternating data). If and there is no noise, then exactly, for every , so is an exact fixed point of the loop.
Proof. By Poisson summation, . Only and fall in the band, and for every , so . Then , and the same subtraction as in Theorem 1 gives the result. At the error is , and with lines L7 and L8 leave unchanged.
The S-curve is a closed form under assumptions: raised cosine pulses, independent zero-mean data, and constant while the mean is taken. With random data the error also has a part that depends on the data pattern and is not zero at (self-noise), so the loop jitters around the lock point even without noise. Theorem 3 shows that this part is zero for alternating data. The tests check Theorem 1 by averaging over 1280 random QPSK symbols at three offsets, and Theorem 3 to .
Complexity
Each symbol needs three samples of (lines L3, L4 and L6), two squared magnitudes of two real multiplications and one addition each, one subtraction, and the four operations of lines L7 and L8. With an interpolator of taps, each sample costs more multiply-adds, so a symbol costs operations. The loop is per symbol and for symbols in the real RAM, with extra space besides the output. It is sequential, like every feedback loop.
Properties
- Non-data-aided and phase-free. The detector uses only , so a carrier phase or a slow frequency offset does not change it. Timing can be recovered before the carrier.
- Needs excess bandwidth. The slope is proportional to the roll-off . For the energy of the signal no longer varies with on average, and the detector has no mean output.
- Self-noise. At the mean is zero, but each depends on the neighboring symbols, so the loop jitters even without noise. The jitter falls with the loop bandwidth.
- Mean offset in the loop (measurement). In the runs of the tests and the example, the mean of was about without noise: at and at , over three seeds each. A likely cause is that depends on past symbols that also enter through the pulse tails (heuristic). The offset shrinks with the bandwidth.
- Gain depends on amplitude. scales with the square of the signal amplitude, so the loop bandwidth changes with the received level unless an automatic gain control keeps it fixed.
Variants and improvements
- Absolute-value gate. . Simon analyzed this form in 1970 and found it less noisy than two other bit synchronizers of that time.
- Derivative form. As , . This is the non-data-aided maximum likelihood timing detector at low SNR. It needs a derivative filter instead of two extra samples.
- Decision-directed gate. uses the decision . It removes most of the self-noise at high SNR, but it needs the carrier phase.
- Integrate-and-dump gates. For rectangular pulses, analog bit synchronizers integrate the signal over an early half and a late half of the symbol and compare the magnitudes. This is the classic form in telemetry receivers.
- Delay-locked loop. The same early-late structure on a known spreading code tracks the code phase; see delay-locked loop.
- Fewer samples. The Gardner detector needs two samples per symbol, and the Mueller and Muller detector needs one.
When to use it
Use an early-late gate when the receiver has three samples per symbol or a continuous-time signal, the pulses have a clear excess bandwidth, and the timing must be found before the carrier. It is easy to build in analog hardware, which is why older bit synchronizers used it. In a digital modem at two samples per symbol, the Gardner detector does the same job with less self-noise. At high SNR with a known carrier phase, a decision-directed detector is more accurate.
Pitfalls
- Gate half-width . For raised cosine pulses, and the square-law gate has no restoring force. Use near .
- Wrong sign of the update. The error is positive when the strobe is early. If the update subtracts it, the loop locks at the worst point, half a symbol from the peak.
- Gain not divided by . The slope depends on , and the signal power. Using a fixed for another roll-off or another level changes the loop bandwidth.
- Too wide a loop. The self-noise grows with . A loop that is fast enough for acquisition may be too noisy for tracking; switch to a narrower bandwidth after lock.
- Small roll-off. At the slope is a fifth of that at , and the self-noise is relatively larger. Narrowband systems need a data-aided or decision-directed detector.
Implementations
Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/early-late-gate-synchronizer/. The authors are listed in prov/Z897RY.jsonl.
"""The early-late gate symbol synchronizer, in its square-law (non-data-aided) form.
Times are in symbol periods T. The receiver has a sampler y(t) for the matched
filter output: an ADC with a controlled clock, or an interpolator on a fixed
sample grid. The symbols sit at t = k + tau for an unknown delay tau. For the
estimate tau_k, the gate takes the early sample y(k + tau_k - d) and the late
sample y(k + tau_k + d) and forms
e_k = |y(k + tau_k + d)|^2 - |y(k + tau_k - d)|^2.
If the receiver samples too early (tau_k < tau), the late sample is nearer the
peak of the pulse and e_k > 0. A first- or second-order loop moves tau_k:
s <- s + ki e_k, tau_{k+1} = tau_k + kp e_k + s.
For raised cosine pulses with roll-off beta and i.i.d. zero-mean data with
E|a|^2 = 1, the mean of e_k is (beta/2) sin(2 pi d) sin(2 pi delta), where
delta = tau - tau_k. The slope at lock is pi beta sin(2 pi d): it is largest
at d = 1/4 and it is zero at d = 1/2.
"""
import math
from typing import Callable
Sampler = Callable[[float], complex]
def detector(sample: Sampler, t: float, d: float = 0.25) -> float:
"""The early-late error at the strobe time t, with the gate half-width d."""
late = sample(t + d) # @line L4
early = sample(t - d) # @line L3
return abs(late) ** 2 - abs(early) ** 2 # @line L5
def s_curve(delta: float, beta: float, d: float = 0.25) -> float:
"""Mean detector output for raised cosine pulses and i.i.d. data, E|a|^2 = 1."""
return 0.5 * beta * math.sin(2 * math.pi * d) * math.sin(2 * math.pi * delta)
def gain_for_bandwidth(bl_t: float, kd: float) -> float:
"""kp of a first-order loop with noise bandwidth B_L T for the detector slope kd."""
return 4.0 * bl_t / ((1.0 + 2.0 * bl_t) * kd)
def early_late_gate(
sample: Sampler,
n: int,
kp: float,
ki: float = 0.0,
tau0: float = 0.0,
d: float = 0.25,
) -> tuple[list[float], list[complex]]:
"""Run the loop over n symbols. Return the estimates tau_k and the strobes y(k + tau_k)."""
tau, s = tau0, 0.0 # @line L1
taus: list[float] = []
strobes: list[complex] = []
for k in range(n): # @line L2
t = k + tau
taus.append(tau)
strobes.append(sample(t)) # @line L6
e = detector(sample, t, d) # @line L3
s += ki * e # @line L7
tau += kp * e + s # @line L8
return taus, strobes # @line L9
test_early_late_gate_synchronizer.py 146 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/early-late-gate-synchronizer/. The authors are listed in prov/Z897RY.jsonl.
import cmath
import math
import random
from early_late_gate_synchronizer import detector, early_late_gate, gain_for_bandwidth, s_curve
BETA = 0.5
TAU = 0.3
QPSK = [cmath.exp(1j * (math.pi / 4 + m * math.pi / 2)) for m in range(4)]
def rc(t, b):
"""The raised cosine pulse with roll-off b and T = 1."""
if abs(t) < 1e-12:
return 1.0
if abs(abs(t) - 1 / (2 * b)) < 1e-9:
return math.pi / 4 * math.sin(math.pi / (2 * b)) / (math.pi / (2 * b))
return math.sin(math.pi * t) / (math.pi * t) * math.cos(math.pi * b * t) / (1 - (2 * b * t) ** 2)
def rrc(t, b):
"""The root raised cosine pulse with roll-off b and T = 1."""
if abs(t) < 1e-12:
return 1 - b + 4 * b / math.pi
if abs(abs(t) - 1 / (4 * b)) < 1e-9:
return b / math.sqrt(2) * ((1 + 2 / math.pi) * math.sin(math.pi / (4 * b)) + (1 - 2 / math.pi) * math.cos(math.pi / (4 * b)))
return (math.sin(math.pi * (1 - b) * t) + 4 * b * t * math.cos(math.pi * (1 + b) * t)) / (math.pi * t * (1 - (4 * b * t) ** 2))
def make_sampler(a, tau, n0=0.0, seed=0, theta=0.0, span=4, reach=8):
"""Matched filter output y(t) = e^(j theta) sum a_k g(t - k - tau) + v(t), g raised cosine.
The noise is v(t) = sum_n w_n rrc(t - n h) with h = 1/2 and w_n i.i.d.
CN(0, h n0). Since rrc has bandwidth (1 + beta)/2 < 1/(2h), v is stationary
with autocorrelation n0 g(t - s): the matched filter output of white noise
of density n0 (up to the cut of rrc at span symbols).
"""
rot = cmath.exp(1j * theta)
h = 0.5
n_lo = int(-6 / h)
w = None
if n0 > 0:
rng = random.Random(seed)
sd = math.sqrt(h * n0 / 2)
w = [complex(rng.gauss(0, sd), rng.gauss(0, sd)) for _ in range(int((len(a) + 12) / h))]
reach_w = int(span / h)
def sample(t):
k0 = int(round(t - tau))
acc = 0j
for k in range(max(0, k0 - reach), min(len(a), k0 + reach + 1)):
acc += a[k] * rc(t - k - tau, BETA)
acc *= rot
if w is not None:
c = int(round(t / h))
for n in range(c - reach_w, c + reach_w + 1):
acc += w[n - n_lo] * rrc(t - n * h, BETA)
return acc
return sample
def qpsk(n, seed):
rng = random.Random(seed)
return [rng.choice(QPSK) for _ in range(n)]
def test_exact_lock_on_alternating_data():
# With a_k = (-1)^k the signal is cos(pi (t - tau)) and the error is
# sin(2 pi d) sin(2 pi (tau - tau_k)) exactly, so the loop has no self-noise.
a = [(-1) ** k + 0j for k in range(400)]
sample = make_sampler(a, TAU)
taus, _ = early_late_gate(sample, 360, kp=0.1)
for t in taus[300:]:
assert abs(t - TAU) < 1e-9
def test_detector_mean_matches_s_curve():
a = qpsk(1300, 2)
sample = make_sampler(a, TAU)
for delta in (-0.3, 0.1, 0.2):
es = [detector(sample, k + TAU - delta) for k in range(10, 1290)]
mean = sum(es) / len(es)
# The standard error of the mean is about 0.02 here.
assert abs(mean - s_curve(delta, BETA)) < 0.06
def test_gate_half_width_one_half_gives_no_error_signal():
a = qpsk(1300, 3)
sample = make_sampler(a, TAU)
es = [detector(sample, k + TAU - 0.2, d=0.5) for k in range(10, 1290)]
assert abs(sum(es) / len(es)) < 0.04
assert abs(s_curve(0.2, BETA, d=0.5)) < 1e-15
def test_carrier_phase_does_not_change_the_loop():
a = qpsk(300, 4)
t1, _ = early_late_gate(make_sampler(a, TAU), 250, kp=0.05)
t2, _ = early_late_gate(make_sampler(a, TAU, theta=1.1), 250, kp=0.05)
assert max(abs(x - y) for x, y in zip(t1, t2)) < 1e-9
def test_random_data_noiseless_settles_near_true_delay():
a = qpsk(1700, 5)
kd = math.pi * BETA * math.sin(2 * math.pi * 0.25)
kp = gain_for_bandwidth(0.0025, kd)
taus, _ = early_late_gate(make_sampler(a, TAU), 1650, kp=kp)
tail = taus[800:]
mean = sum(tail) / len(tail)
assert abs(mean - TAU) < 0.006
assert max(abs(t - TAU) for t in tail) < 0.015
def test_second_order_loop_tracks_clock_offset():
# A sampler whose symbols drift by 1e-3 T per symbol: tau grows like a ramp.
a = [(-1) ** k + 0j for k in range(700)]
drift = 1e-3
def sample(t):
k0 = int(round(t))
acc = 0j
for k in range(max(0, k0 - 16), min(len(a), k0 + 17)):
acc += a[k] * rc(t - k - TAU - drift * k, BETA)
return acc
taus, _ = early_late_gate(sample, 600, kp=0.1, ki=0.005)
for k in range(450, 600):
assert abs(taus[k] - (TAU + drift * k)) < 2e-3
def test_noise_variance_against_mcrb():
snr = 10.0
bl_t = 0.01
xi = 1.0 / 12.0 + BETA ** 2 * (0.25 - 2.0 / math.pi ** 2)
mcrb = bl_t / (4 * math.pi ** 2 * xi * snr)
a = qpsk(2400, 6)
sample = make_sampler(a, TAU, n0=1.0 / snr, seed=7)
kd = math.pi * BETA
taus, _ = early_late_gate(sample, 2350, kp=gain_for_bandwidth(bl_t, kd))
tail = taus[400:]
mean = sum(tail) / len(tail)
var = sum((t - mean) ** 2 for t in tail) / len(tail)
assert 1.0 <= var / mcrb <= 4.0
History
Range trackers in radar keep a gate centered on an echo pulse by comparing the energy in an early half gate and a late half gate, and early bit synchronizers for digital telemetry used the same idea. Marvin K. Simon, at the Jet Propulsion Laboratory, published a nonlinear analysis of the absolute-value early-late gate bit synchronizer in 1970, with its S-curve and its steady-state timing error. With digital modems, the gate became a few lines of code on interpolated samples, as above, and later detectors such as Gardner's (1986) reduced the number of samples per symbol.
References
- M. K. Simon, Nonlinear analysis of an absolute value type of an early-late gate bit synchronizer, IEEE Transactions on Communication Technology 18(5), 1970, pages 589 to 596, the absolute-value early-late gate, its S-curve and its steady-state timing error by the Fokker-Planck method
- John G. Proakis and Masoud Salehi, Digital Communications, fifth edition, McGraw-Hill, 2008, Section 5.3 (symbol timing estimation, with the early-late gate synchronizer as a non-decision-directed method)
- Umberto Mengali and Aldo N. D'Andrea, Synchronization Techniques for Digital Receivers, Plenum Press, 1997, Chapter 7 (timing recovery in baseband transmission) and Chapter 8 (timing recovery with linear modulations)
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag Z897RY Edit this page History Report an error Markdown