Algorithmcore
Decision-directed carrier recovery
Also called decision-directed phase tracking.
Rotates each sample by the phase estimate, decides the nearest symbol and uses Im(z conj(a_hat)) as the phase error of a tracking loop. With correct decisions it has no squaring loss.
- Solves
- Carrier recovery
- Time
- O(N) worst
- Space
- O(1) extra
- Counts
- time brute force decisions O(N M) worst
- Where
- M = the number of constellation points; N = the number of symbols
- Model
- Real RAM
- Properties
- decision directeddeterministiconline
- Evidence
- Proof sketchCode in 1 languages
- Origin
- William C. Lindsey, Marvin K. Simon, 1973
Decision-directed (DD) carrier recovery tracks the carrier phase with the receiver's own symbol decisions. It rotates each sample by the current estimate, decides the nearest constellation point , and feeds the phase error to the loop filter and the oscillator of a phase-locked loop. When the decisions are right, the detector output is plus noise, as if the data were known, so the loop has no squaring loss and works for any constellation, including QAM. This is the decision-directed member of the carrier recovery family, in the split described in data-aided synchronization. The Costas loop and the squaring loop remove the data without decisions, and the Viterbi and Viterbi estimator does it in a block. For QPSK, the hard-limited Costas detector is times the DD detector. The DD loop needs a phase error small enough for correct decisions, so it is usually started by a pilot, a preamble or one of those methods, and it shares their ambiguity: it locks modulo the rotation symmetry of the constellation, for QPSK and square QAM, and wrong decisions in noise can trigger a cycle slip.
In plain words
The receiver must keep its picture of the constellation lined up with the received points. For each received point it asks: which symbol was this most likely? It then measures the angle between the received point and that symbol. If the points are turned a little to the left of the symbols they were decided as, the receiver turns its picture a little to the left, and the other way round. While the picture is close to right, almost all guesses are right, and the method works as well as if the receiver knew the data. If the picture is turned too far, the guesses go wrong, the measured angles point the wrong way, and the method can stick at a wrong angle.
The problem
The input is , , one sample per symbol after matched filtering and correct timing, with data uniform on a signal constellation of points normalized to , and white, . The phase changes slowly. The loop must output an estimate from and the decisions on them. If the symbols are known (a preamble or pilots), the same loop uses them in place of the decisions; that is the data-aided form.
The algorithm
DD-LOOP(r[0..N-1], A, Kp, Ki, known, phi0)- 1
phi <- phi0; s <- 0 - 2
for k <- 0 to N - 1 do - 3
est[k] <- phi - 4
z <- r[k] * exp(-j * phi) ▷ derotate - 5
a_hat <- known[k] if known, else the point of A nearest to z - 6
e <- Im(z * conj(a_hat)) ▷ |a|^2 sin(theta - phi) + noise - 7
s <- s + Ki * e - 8
phi <- phi + Kp * e + s - 9
return est, decisions
Line L5 is the minimum distance detector, a slicer in for PSK and square QAM. Line L6 is the cross product of the sample and the decision. Its mean slope at is , so the gains come from the PLL design rule with detector gain 1. Some designs divide by , which gives for every symbol and a noise that is larger on the inner points. Lines L7 and L8 are the second-order loop filter and the oscillator.
Example
Take 16-QAM (raw levels , divided by ), rad (), no noise, random data (seed 1), and the gains for : , . The columns , and are in raw units (times ); and are for the unit-energy points:
| (line L4) | (line L6) | new (line L8) | |||
|---|---|---|---|---|---|
| 0 | |||||
| 1 | |||||
| 2 | |||||
| 3 |
The corner point at has , so it gives a larger error signal than the point at , with . The error is at , at , at and at .
The starting error matters. For 16-QAM, every noise-free decision is right only while , where the corner points reach a decision boundary. Started at rad (), the loop does not reach . It settles near a false lock point, with an error that swings between and rad around a mean of rad (), and 75 percent of the decisions are wrong. The data-aided form on the same samples, with the known symbols, locks to , and from rad as well. QPSK has no false lock: its S-curve is on all of , and the loop locks from rad.
In noise, with (exact ), the linear model gives the variance . Simulations of 30000 symbols measured these ratios to it (measurements):
| case | symbol error rate | DD ratio | data-aided ratio |
|---|---|---|---|
| QPSK, 10 dB, seed 3 | |||
| 16-QAM, 20 dB, seed 4 | |||
| 16-QAM, 15 dB, seed 5 |
At 15 dB, about 2 percent of the 16-QAM decisions are wrong, close to the exact value , and they raise the variance by about a quarter over the data-aided loop.
Correctness
Claim. If the decisions are correct, line L6 outputs plus white noise of variance . So the loop behaves like a PLL with detector gain , and in the linear model its phase error variance is . Without noise, the decisions are correct for for QPSK and for 16-QAM, and the S-curve is there.
Key steps. With , , where is the rotated noise, still circular Gaussian. The decision is correct as long as the rotated point stays in its own decision region. For 16-QAM the corner point reaches the line first, at . Beyond this angle the S-curve is a broken function of , and the full proof locates its sign changes and the false lock between and . The variance claim is a closed form under assumptions (the linear model, correct decisions); the effect of wrong decisions and the false lock are measurements here.
Proof: With correct decisions the DD detector outputs |a|^2 sin(delta), the loop locks with variance B_L T/SNR, and for 16-QAM the decisions stay correct only for errors below 16.87 degreesfull
The input is , where the are independent and uniform on a constellation with , and white, . Line L4 forms , line L5 picks , the point of nearest to (or the known in the data-aided form), and line L6 outputs . Lines L7 and L8 are the loop filter and oscillator of the phase-locked loop, whose proof gives the linear closed loop, the stability conditions and . Write .
Lemma 1 (the detector with a correct decision). If , then , with independent of the past. The noise term has mean and variance .
Proof. . The law of follows from the rotation invariance of circular Gaussian noise, as in the PLL proof. is circular with variance , and its imaginary part has half of it.
Theorem 1 (the data-aided loop). With the known symbols in line L5, the mean detector output is , for every . So the only stable lock point modulo is , and in the linear model the phase error variance is .
Proof. By Lemma 1 with always, the mean of over the data is , whose stable zero is (slope ) and unstable zero is . Near lock the detector gain is and the noise is white with variance , so the PLL proof gives the variance .
For QAM the gain changes from symbol to symbol. The linear model uses its mean, which is exact for the mean response and adds a small self noise that is second order near lock.
Theorem 2 (the decision-directed loop without noise). Let be the largest angle such that lies in the decision region of for every and every . Then without noise the DD detector equals the data-aided detector for , and the mean S-curve is there. For QPSK, . For 16-QAM, .
Proof. Without noise, , and exactly when is in the decision region of . Then Theorem 1 applies. For QPSK, the regions are the quadrants and each point is at from both boundaries. For 16-QAM with raw levels , the boundaries are the lines and . The inner points have modulus and reach the boundary or only after . A point has modulus and angle ; it reaches the line when , at , and when rotated the other way it reaches the line at . The point is its mirror image, with the angles and . The corner point has modulus at ; it reaches when , at , and by symmetry at . The smallest of these angles over all points, by the symmetry of the constellation, is .
Beyond some decisions are wrong, and the mean S-curve departs from . For 16-QAM, a direct evaluation over the 16 points shows that it drops at , changes sign from positive to negative at (where the points of the type cross an axis into the next quadrant) and changes sign from negative to positive between and . A zero where the S-curve rises is a stable lock point, so the DD loop has a false lock there. The tests check these values and show the loop, started at rad, settle with a mean error of rad ().
Theorem 3 (variance with correct decisions). If the decisions are correct at lock, the DD loop has the variance of Theorem 1 in the linear model.
Proof. With the recursion is that of the data-aided loop.
Wrong decisions make the detector output biased toward zero and add noise. At a symbol error rate the effect is of order ; the tests compare the variance at 10 dB for QPSK () and 20 dB for 16-QAM () with within a factor of 1.25.
Complexity
Each symbol costs one rotation, one decision and arithmetic. With a slicer, the decision is , so symbols cost in the real RAM, with extra space. The implementation decides by brute force over the points, , so that it is easy to check against the shared brute-force ML detector; the tests do this on 64-QAM and 8-PSK as well.
Properties
- No squaring loss. With correct decisions, the noise is that of the data-aided loop. This is the main advantage over the Costas and squaring loops, and it holds for any constellation.
- Needs a good start. The linear range ends where decisions go wrong: for QPSK, for 16-QAM, and less for larger QAM. Outside it, the loop can false-lock, as in the example.
- Ambiguity. The decided symbols are rotated with the constellation, so the loop locks modulo the symmetry of : for BPSK, for QPSK and square QAM, for M-PSK. The data-aided form has no ambiguity.
- Threshold. As the symbol error rate grows, wrong decisions reduce the detector gain and add noise. In the example at 15 dB, 2 percent wrong 16-QAM decisions raised the variance by 27 percent; at lower SNR the loop slips.
- Decision delay. The decision must be ready before the loop update. If decisions come from a decoder, they arrive late, and the delay in the loop reduces its stability margin.
Variants and improvements
- Data-aided mode. Use known symbols during a preamble or on pilot symbols, as in pilot-symbol-assisted modulation, then switch to decisions. This avoids false lock and the ambiguity.
- Normalized detector. gives the same restoring force on every point.
- Reduced constellation. For large QAM, use only the corner points or the points of largest modulus during acquisition, because they give the largest and most reliable phase information; switch to all points after lock.
- Feedforward DD. Estimate the phase over a block by and iterate. This is the decision-directed form of the block ML estimator.
- Per-survivor processing. In a Viterbi receiver, each survivor path keeps its own phase estimate, updated with its own tentative decisions; see per-survivor processing.
When to use it
Use a DD loop to track the carrier of QAM or high-order PSK after acquisition, or in steady state on a continuous link, when the symbol error rate is low (below about 1 percent). Start it with a preamble, pilots, a Viterbi and Viterbi estimate or a Costas loop. At low SNR, or when decisions are unreliable, use a non-data-aided method or pilots.
Pitfalls
- Acquiring with decisions. Starting a 16-QAM DD loop at a phase error above about can end in a false lock with most decisions wrong, as in the example. Nothing in the loop shows it except a high error rate.
- Forgetting the ambiguity. After lock, the decisions may be rotated by a multiple of . Use differential encoding of the quadrant bits or a known word.
- Wrong scaling of the constellation. Line L5 assumes that the received points have the scale of . If an automatic gain control leaves the samples 20 percent too large, outer QAM points are decided wrong even at zero phase error. Fix the gain first.
- Using decisions from a different phase. Line L5 must decide on the derotated , not on . Deciding on makes every decision depend on the raw carrier phase.
- Ignoring decision errors in the noise budget. The variance assumes correct decisions. At a symbol error rate of a few percent the measured variance is noticeably higher.
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
# Shared helper of the communications pages of https://algorithm.tamnd.com/. The authors are listed in prov/.
"""Constellations, Gray labels and brute-force maximum likelihood detection.
Each constellation function returns a list of M complex points with unit
average energy, ordered by label: points[i] is the point whose bit label is
the integer i, and bits(i, log2 M) gives that label, most significant bit
first. The labels follow the communications area rules:
- M-PAM: the point with amplitude index m = 0, ..., M-1 (raw amplitude
M - 1 - 2m, from the most positive) gets the Gray label gray(m).
So 2-PAM maps bit 0 to +1 and bit 1 to -1.
- Square M-QAM, M = 4^k: the label is the in-phase PAM label followed by the
quadrature PAM label, each of log2(sqrt(M)) bits.
- M-PSK: the point e^(j(2 pi m / M + phase0)) gets the label gray(m).
PAM points are returned as complex numbers with zero imaginary part.
This file imports nothing from cbb.py. It holds no demapper: soft and
max-log demapping are algorithm pages of their own.
"""
import cmath
import itertools
import math
def gray(n: int) -> int:
"""The binary reflected Gray code of n: n XOR (n >> 1)."""
return n ^ (n >> 1)
def _gray_inv(g: int) -> int:
n = 0
while g:
n ^= g
g >>= 1
return n
def bits(i: int, m: int) -> list[int]:
"""The m bits of the integer i, most significant bit first."""
if i < 0 or i >= 1 << m:
raise ValueError("i does not fit in m bits")
return [(i >> (m - 1 - t)) & 1 for t in range(m)]
def _log2(m: int) -> int:
if m < 2 or m & (m - 1):
raise ValueError("M must be a power of two, at least 2")
return m.bit_length() - 1
def pam(m: int) -> list[complex]:
"""Unit-energy M-PAM, ordered by Gray label."""
_log2(m)
s = math.sqrt((m * m - 1) / 3.0)
return [complex((m - 1 - 2 * _gray_inv(lab)) / s, 0.0) for lab in range(m)]
def qam(m: int) -> list[complex]:
"""Unit-energy square M-QAM (M = 4, 16, 64, ...), ordered by label (in-phase bits first)."""
k = _log2(m)
if k % 2:
raise ValueError("square QAM needs M = 4^k")
side = 1 << (k // 2)
s = math.sqrt(2.0 * (m - 1) / 3.0)
raw = [side - 1 - 2 * _gray_inv(lab) for lab in range(side)]
return [complex(raw[lab // side], raw[lab % side]) / s for lab in range(m)]
def psk(m: int, phase0: float = 0.0) -> list[complex]:
"""Unit-energy M-PSK with first point at angle phase0, ordered by Gray label."""
_log2(m)
return [cmath.exp(1j * (2.0 * math.pi * _gray_inv(lab) / m + phase0)) for lab in range(m)]
def energy(points: list[complex]) -> float:
"""The average energy (1/M) sum |p|^2 of equally likely points."""
return sum(abs(p) ** 2 for p in points) / len(points)
def ml_detect(y: complex, points: list[complex], h: complex = 1) -> int:
"""The index of the point p that minimizes |y - h p|^2, by brute force (lowest index on a tie)."""
best, arg = math.inf, -1
for i, p in enumerate(points):
d = abs(y - h * p) ** 2
if d < best:
best, arg = d, i
return arg
def ml_vector(y: list[complex], h: list[list[complex]], points: list[complex]) -> list[int]:
"""The index vector that minimizes ||y - H x||^2 over all M^n vectors x, by brute force.
h is the m by n channel matrix as a list of rows; the result has n indices.
The first minimizer in lexicographic order of the indices wins a tie.
"""
n = len(h[0])
best, arg = math.inf, None
for idx in itertools.product(range(len(points)), repeat=n):
x = [points[i] for i in idx]
d = 0.0
for yi, row in zip(y, h):
d += abs(yi - sum(a * b for a, b in zip(row, x))) ** 2
if d < best:
best, arg = d, idx
return list(arg)
def bit_errors(a, b) -> int:
"""The number of differing bits between two integer labels, or summed over two equal-length lists."""
if isinstance(a, int) and isinstance(b, int):
return bin(a ^ b).count("1")
if len(a) != len(b):
raise ValueError("lengths differ")
return sum(bit_errors(x, y) for x, y in zip(a, b))
decision_directed_carrier_recovery.py 64 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/decision-directed-carrier-recovery/. The authors are listed in prov/EVQ8KF.jsonl.
"""Decision-directed (DD) carrier phase tracking with a second-order loop.
Each sample is rotated by the current phase estimate, z = r e^(-j phi), and
the nearest constellation point a_hat is decided. The phase detector is
e = Im(z conj(a_hat)),
which is |a|^2 sin(theta - phi) without noise when the decision is right.
Averaged over unit-energy data its gain is E|a|^2 = 1. A second-order loop
filter and an oscillator close the loop, as in a phase-locked loop.
If the transmitted symbols are known (a preamble or pilots), pass them as
`known`: the detector then uses them instead of decisions. This is the
data-aided form of the same loop, and it has no phase ambiguity.
"""
import cmath
import math
from typing import Optional, Sequence
def loop_gains(bl_t: float, zeta: float = 1.0 / math.sqrt(2.0)) -> tuple[float, float]:
"""(kp, ki) for the noise bandwidth B_L T and damping zeta, with detector gain 1."""
wn_t = 2.0 * bl_t / (zeta + 1.0 / (4.0 * zeta))
return 2.0 * zeta * wn_t, wn_t * wn_t
def nearest(z: complex, points: Sequence[complex]) -> complex:
"""The point of the constellation closest to z (the first one on a tie)."""
best, arg = math.inf, points[0]
for p in points:
d = abs(z - p) ** 2
if d < best:
best, arg = d, p
return arg
def dd_detector(z: complex, points: Sequence[complex]) -> float:
"""The DD phase error Im(z conj(a_hat)) for a derotated sample z."""
return (z * nearest(z, points).conjugate()).imag
def dd_loop(
r: Sequence[complex],
points: Sequence[complex],
kp: float,
ki: float,
known: Optional[Sequence[complex]] = None,
phi0: float = 0.0,
) -> tuple[list[float], list[complex]]:
"""Run the loop. Returns the phase estimate used on each r[k] and the decisions."""
phi = phi0 # @line L1
s = 0.0 # @line L1
est, dec = [], []
for k, x in enumerate(r): # @line L2
est.append(phi) # @line L3
z = x * cmath.exp(-1j * phi) # @line L4
a_hat = known[k] if known is not None else nearest(z, points) # @line L5
dec.append(a_hat)
e = (z * a_hat.conjugate()).imag # @line L6
s += ki * e # @line L7
phi += kp * e + s # @line L8
return est, dec # @line L9
test_decision_directed_carrier_recovery.py 94 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/decision-directed-carrier-recovery/. The authors are listed in prov/EVQ8KF.jsonl.
import cmath
import math
import random
import constel
from decision_directed_carrier_recovery import dd_detector, dd_loop, loop_gains, nearest
QPSK = constel.psk(4, math.pi / 4)
QAM16 = constel.qam(16)
def s_curve(deg, points):
"""The mean detector output without noise, over all points, at a phase error in degrees."""
d = math.radians(deg)
return sum(dd_detector(a * cmath.exp(1j * d), points) for a in points) / len(points)
def noise_bandwidth(kp, ki):
b0, b1, a1, a2 = kp + ki, -kp, kp + ki - 2.0, 1.0 - kp
return 0.5 * ((b0 * b0 + b1 * b1) * (1 + a2) - 2 * b0 * b1 * a1) / ((1 - a2) * ((1 + a2) ** 2 - a1 * a1))
def test_decisions_match_brute_force_ml() -> None:
rng = random.Random(7)
for pts in (QPSK, QAM16, constel.qam(64), constel.psk(8)):
for _ in range(2000):
z = complex(rng.uniform(-1.5, 1.5), rng.uniform(-1.5, 1.5))
assert nearest(z, pts) == pts[constel.ml_detect(z, pts)]
def test_s_curves_without_noise() -> None:
# QPSK: sin(delta) for |delta| < 45 degrees.
for i in range(-449, 450):
assert abs(s_curve(i / 10, QPSK) - math.sin(math.radians(i / 10))) < 1e-12
# 16-QAM: sin(delta) while every decision is right, up to 16.87 degrees, where the
# corner point crosses a boundary: arccos(2/(3 sqrt 2)) - 45 degrees.
edge = math.degrees(math.acos(2 / (3 * math.sqrt(2)))) - 45
assert abs(edge - 16.874) < 1e-3
for i in range(-168, 169):
assert abs(s_curve(i / 10, QAM16) - math.sin(math.radians(i / 10))) < 1e-12
assert s_curve(16.9, QAM16) < 0.5 * math.sin(math.radians(16.9))
# The mean output changes sign at arctan(1/3) = 18.435 degrees, and again between
# 25 and 30 degrees, from negative to positive: a stable false lock point.
assert s_curve(18.4, QAM16) > 0 > s_curve(18.47, QAM16)
assert s_curve(25, QAM16) < 0 < s_curve(30, QAM16)
def test_lock_without_noise() -> None:
kp, ki = loop_gains(0.02)
for pts, th in ((QPSK, 0.7), (QAM16, 0.25)):
rng = random.Random(1)
r = [rng.choice(pts) * cmath.exp(1j * th) for _ in range(1500)]
est, _ = dd_loop(r, pts, kp, ki)
assert max(abs(th - p) for p in est[300:]) < 1e-3
assert abs(th - est[-1]) < 1e-9
def test_qam_false_lock_and_the_data_aided_form() -> None:
kp, ki = loop_gains(0.02)
rng = random.Random(1)
a = [rng.choice(QAM16) for _ in range(8000)]
r = [x * cmath.exp(0.7j) for x in a]
# Decision-directed from 0.7 rad (40 degrees): the loop settles near the false
# lock point of about 28 degrees, and most decisions are wrong.
est, dec = dd_loop(r, QAM16, kp, ki)
tail = [0.7 - p for p in est[5000:]]
assert 0.40 < min(tail) and max(tail) < 0.58
assert abs(sum(tail) / len(tail) - 0.487) < 0.01 # 27.9 degrees
assert sum(1 for x, y in zip(dec[5000:], a[5000:]) if x != y) > 2000
# Data-aided: the known symbols give |a|^2 sin(delta), with no ambiguity at all.
est, _ = dd_loop(r, QAM16, kp, ki, known=a)
assert abs(0.7 - est[-1]) < 1e-9
r2 = [x * cmath.exp(2.5j) for x in a[:3000]]
est, _ = dd_loop(r2, QAM16, kp, ki, known=a[:3000])
assert abs(2.5 - est[-1]) < 1e-9
def test_variance_against_the_linear_model() -> None:
# With correct decisions the variance is B_L T / SNR. B_L T = 0.01; factor 1.25.
kp, ki = loop_gains(0.01)
bl = noise_bandwidth(kp, ki)
for pts, snr_db, seed in ((QPSK, 10, 3), (QAM16, 20, 4)):
snr = 10 ** (snr_db / 10)
sd = math.sqrt(0.5 / snr)
rng = random.Random(seed)
r = [rng.choice(pts) * cmath.exp(0.2j) + complex(rng.gauss(0, sd), rng.gauss(0, sd)) for _ in range(30000)]
err = [0.2 - p for p in dd_loop(r, pts, kp, ki, phi0=0.2)[0][1000:]]
m = sum(err) / len(err)
var = sum((e - m) ** 2 for e in err) / len(err)
assert abs(m) < 0.01
assert 0.8 < var / (bl / snr) < 1.25
History
Decision-directed ideas came with adaptive data modems in the 1960s, where the receiver's own decisions also drove adaptive equalizers. In the early 1970s, data-aided carrier loops were analyzed next to the squaring loop and the Costas loop, among others by Lindsey and Simon, and they were shown to avoid the squaring loss when decisions are reliable. With high-order QAM in telephone line modems, microwave radio and later cable and satellite systems, decision-directed tracking after a training or blind start became the common design. Mengali and D'Andrea's book of 1997 derives it as the decision-directed form of the maximum likelihood phase estimator.
References
- Umberto Mengali and Aldo N. D'Andrea, Synchronization Techniques for Digital Receivers, Plenum Press, 1997, Section 5.2 (clock-aided and data-aided phase recovery) and Section 5.3 (decision-directed phase recovery with non-offset modulation)
- John G. Proakis and Masoud Salehi, Digital Communications, fifth edition, McGraw-Hill, 2008, Section 5.2-4 (decision-directed loops)
- Heinrich Meyr, Marc Moeneclaey and Stefan A. Fechtel, Digital Communication Receivers, Wiley, 1998, Chapter 5 (synthesis of synchronization algorithms, the decision-directed approach) and Chapter 6 (performance analysis of synchronizers)
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 EVQ8KF Edit this page History Report an error Markdown