Algorithmcore
Decision feedback equalizer
Also called DFE.
Cancels the postcursor ISI by subtracting a filtered copy of past decisions and handles the precursor ISI with a linear filter. With ideal feedback the MMSE design is one Wiener solve.
- Solves
- Channel equalization
- Time
- O(N^2 (N + L) + K (N + L)) worst
- Space
- O(N (N + L)) extra
- Where
- K = the number of symbols; L = the number of channel taps; N = the number of feedforward taps
- Model
- Real RAM
- Properties
- biaseddeterministicerror propagationnot linearneeds noise level
- Evidence
- Proof sketchCode in 1 languages
- Origin
- M. E. Austin, J. Salz, 1967
The decision feedback equalizer is a linear equalizer with a second filter that runs on the decisions. A channel of taps adds echoes of each symbol to the later samples (postcursor ISI) and, after a delay, to the earlier ones (precursor ISI). The feedforward filter works on the received samples and handles the precursors and the noise. The feedback filter works on the symbols already decided: it rebuilds their echoes and subtracts them before the slicer. These echoes are removed without any noise gain, which the linear MMSE equalizer and the zero-forcing equalizer cannot do. The cost is that a wrong decision feeds a wrong echo back, so errors come in bursts. The MMSE-DFE canonical theorem shows that the infinite-length MMSE-DFE with correct feedback loses no capacity. Tomlinson-Harashima precoding moves the feedback to the transmitter, where there are no wrong decisions. The Viterbi equalizer decides the whole sequence and has no error propagation, at a cost exponential in . The same idea on a channel matrix instead of a convolution is V-BLAST and successive interference cancellation.
In plain words
Each received sample contains the wanted symbol, echoes of older symbols and noise. A linear equalizer removes the echoes by filtering, and this also amplifies the noise. A DFE notices that the older symbols were already decided. If those decisions are right, the receiver knows the echoes exactly and can subtract them. Subtraction adds no noise. A short linear filter in front still handles the echoes of the symbols not yet decided. The weak point is a wrong decision: the receiver then subtracts the wrong echo, and the next decision is more likely to be wrong too.
The problem
The input is the channel , the noise power , the symbol energy , the alphabet, the filter lengths and , the delay , and the received samples at one sample per symbol, with independent symbols of mean zero and . The slicer input for the symbol is
The design problem is to choose and to minimize , under the assumption that the past decisions are correct. The run then produces the decisions one at a time.
The algorithm
Stack the samples in as for the linear equalizer, where is the convolution matrix with . With correct feedback, the symbols in the positions are known, so the feedforward filter does not need to fight them. The design removes their columns from and solves the Wiener problem against the rest. The feedback taps are then the postcursors of the combined response .
MMSE-DFE(h, Nf, Nb, Δ, N0, Es, y, K)- 1
H[i][j] ← h[j - i] for 0 ≤ i < Nf, 0 ≤ j < Nf + L - 1 - 2
K ← the columns j of H with j ≤ Δ or j > Δ + Nb ▷ remove the fed-back symbols - 3
R ← Es H_K H_Kᴴ + N0 I - 4
r ← Es H e_Δ - 5
f ← R⁻¹ r; c ← conj(f) ▷ the feedforward taps - 6
J ← Es - rᴴ f ▷ the error with correct feedback - 7
g ← c * h ▷ the combined response - 8
b[j] ← g[Δ + j] for j = 1 .. Nb ▷ the feedback taps - 9
for k ← 0 to K - 1 - 10
z ← Σ_i c[i] y[k + Δ - i] - 11
q ← z - Σ_j b[j] x̂[k - j] ▷ subtract the known echoes - 12
x̂[k] ← the alphabet point nearest to q / (1 - J/Es) - 13
return x̂
Lines L1 to L8 run once per channel. Line L5 is one Hermitian positive definite solve. Line L8 makes the feedback cancel exactly the postcursors that the feedforward filter leaves. Lines L9 to L12 run once per symbol. Line L12 divides by the bias : the MMSE output is a shrunk copy of the symbol, which matters for QAM and PAM but not for BPSK or PSK. The ZF-DFE is the limit . For it can take , and .
Example
Take , and (10 dB). With and , the error for each delay is:
| 0 | 1 | 2 | 3 | 4 | 5 | |
|---|---|---|---|---|---|---|
| 0.090909 | 0.089069 | 0.088705 | 0.088634 | 0.088620 | 0.778511 |
At the only postcursor is outside the filter span, so the feedback has nothing to cancel. The best delay is 4, with the feedforward taps and the feedback tap . The cursor of is . The unbiased SNR is , or 10.12 dB. For comparison, at the same SNR on the same channel:
| receiver | SNR at the slicer |
|---|---|
| infinite-length linear MMSE | 9.07 dB |
| ZF-DFE, , | 10.00 dB |
| MMSE-DFE, , | 10.12 dB |
| infinite-length MMSE-DFE | 10.12 dB |
| matched filter bound, | 10.97 dB |
The infinite-length value is , where is the geometric mean of . This gives . The DFE gains 1 dB over the linear equalizer here. On the channel B of Proakis, at 20 dB, an MMSE-DFE with and reaches , an unbiased SNR of 15.14 dB, against 6.60 dB for a 31-tap linear MMSE equalizer. That channel has a spectral null, which hurts every linear equalizer.
Error propagation. Run the ZF-DFE on with BPSK and the noise :
| 0 | 1 | 2 | 3 | 4 | |
|---|---|---|---|---|---|
| 1 | 1 | -1 | -1 | 1 | |
| 1.0 | -0.1 | -0.4 | -1.3 | 0.5 | |
| 1.0 | -0.6 | 0.1 | -1.8 | 1.0 | |
| 1 | -1 | 1 | -1 | 1 |
The large noise sample at causes the first error. The wrong feedback at adds to , which turns a correct decision into a second error. With correct feedback, at would be . At the error happens to push the right way, and the burst ends. In a simulation of 40000 symbols at (seed 7206), this receiver made 201 errors with ideal feedback, close to , and 257 errors with its own decisions. On the ratio grows to about 1.9 (195 against 375, seed 7207).
Correctness
Claim. If the past decisions are correct, lines L5 and L8 give the unique taps that minimize , the minimum is line L6, and the cursor is . With the design is the linear MMSE equalizer, and more feedback taps never increase .
Key step. With correct feedback, the error is , where holds the feedback positions. The feedback taps appear only in the middle sum, which is zero for . What remains is a Wiener problem for against the regressor with the columns removed, which completing the square solves. Without noise and with a small residual ISI, an induction on shows that every decision is correct, so the assumption holds. With noise, a burst of errors ends after correct decisions in a row. The proofs folder has the details.
Proof: With ideal feedback, the MMSE-DFE feedback taps are the postcursors of the combined response and the feedforward taps solve a Wiener problem with the feedback columns removedfull
The channel taps are , not all zero. The received samples are , where the symbols are independent with mean zero and , and the noise samples are independent of each other and of the symbols. The feedforward filter has the taps and the output . The feedback filter has the taps . The slicer input for the symbol is
and the decision is the alphabet point nearest to for a fixed gain (lines L9 to L12).
Let and . As for the linear equalizer, with the matrix (line L1) and the noise vector , with , and . Write , so , and , so is the gain from to . Let be the feedback positions and the other column indices (line L2). Entries of at indices past its end are 0.
Ideal feedback means for . The design (lines L1 to L8) assumes it. Theorem 3 says when the decisions are in fact correct.
Lemma 1 (the error of any taps). With ideal feedback, for every and ,
Proof. . The terms are independent with mean zero, so the variances add.
Lemma 2 (the best feedback for fixed feedforward taps). For a fixed , the unique minimizer of is for , and then
where , with the columns of in and the entries of in .
Proof. In Lemma 1, appears only in the middle sum, which is zero exactly when for every . The remaining two terms are the error of the filter against the regressor by the same computation as Lemma 1, because .
Lemma 3 (R is positive definite). (line L3) is Hermitian, and it is positive definite if .
Proof. For , .
If , can be singular, because removing the columns can make the rows of dependent. The implementation then raises an error.
Theorem 1 (the MMSE-DFE). Let (line L4). Since , for the matching unit vector , so . If is positive definite, the taps with (line L5) and (lines L7 and L8) are the unique joint minimizer of , and the minimum is (line L6).
Proof. By Lemma 2, , and the minimizing is unique for each . The right side is a Wiener problem with the covariance and the cross-correlation . Expanding it gives , and completing the square gives
The last term is positive for because is positive definite. So is the unique minimizer, with the value .
Corollary 1 (the bias). The cursor of the combined response is , a real number in when .
Proof. , which is real and nonnegative. By Theorem 1 it equals . when because unless , and gives .
So with ideal feedback , where has mean zero and is uncorrelated with , by the orthogonality of the Wiener error. Line L12 divides by before the slicer.
Corollary 2 (more feedback taps never hurt). For fixed and , the minimum does not increase with . In particular, with it is the error of the linear MMSE equalizer, so the MMSE-DFE with ideal feedback is never worse than the linear MMSE equalizer of the same length.
Proof. A DFE with taps and is a DFE with taps. So the set over which Theorem 1 minimizes grows with .
Theorem 2 (the zero-forcing DFE). If , , and , the taps and remove all ISI, and the error is .
Proof. , so , and cancels every postcursor in Lemma 1. The only term left is .
Theorem 3 (no error propagation without noise). Let be the minimum distance of the alphabet, over the alphabet, and let the taps satisfy and
If and the symbols before are 0 in both the channel and the run, then line L12 decides every symbol correctly.
Proof. By induction on . Assume for all . Then the feedback at step equals the ideal feedback, and by the computation of Lemma 1 with , . Its modulus is at most . So , and is the unique nearest point.
For the MMSE taps with , the term is 0 by Corollary 1 and the second sum is 0 by Theorem 1. The condition then asks only that the residual precursor and far postcursor ISI is small, which holds for long filters at high SNR.
Corollary 3 (recovery after errors). Assume the condition of Theorem 3, let be the margin, and let the noise term have modulus less than from step on. If the decisions before step are correct, every decision from step on is correct.
Proof. The induction step of Theorem 3 uses only the decisions before the current step, because the feedforward filter does not use decisions. With the noise term added, the bound on becomes less than , and the induction goes through.
So a wrong decision enters the next slicer inputs with the weights and can cause more errors, but the burst ends after correct decisions in a row when the noise is small.
The size of the error bursts with noise is a property of the channel and the SNR. The page gives a measurement, not a bound.
Complexity
The design costs for and for the solve. is a Toeplitz matrix minus a matrix of rank , so fast solvers exist, but the direct solve is cheap for the usual lengths. The run costs complex multiplications per symbol. With , symbols cost in the real RAM with , and the extra space is for and .
Properties
- No noise gain for the postcursors. The feedback removes the echoes of past symbols by subtraction, so on a minimum-phase channel the ZF-DFE needs only one feedforward tap and has the noise gain . On this is 1, against 1.333 for the linear ZF equalizer.
- Nonlinear. The slicer is inside the loop, so the DFE is not a linear filter, and its BER is not a function of alone.
- Error propagation. A wrong decision makes the next slicer inputs worse. This is a measurement for each channel; no simple closed form gives the BER.
- Biased. With correct feedback, plus an uncorrelated error. The unbiased SNR is .
- Optimal with ideal feedback in the limit. The infinite-length MMSE-DFE has , and its unbiased SNR gives the mutual information of the channel with Gaussian inputs; see the MMSE-DFE canonical theorem.
- Causality. The feedback can only use decided symbols, so the precursor ISI must be handled by the feedforward filter. A channel with strong precursors needs a long feedforward filter and a large delay.
Variants and improvements
- ZF-DFE. The limit . It is simpler and needs no noise estimate, but it enhances noise from the precursors.
- Adaptive DFE. Both filters adapt with the LMS algorithm or the RLS algorithm, with the decisions as the reference; see adaptive equalization.
- Fractionally spaced feedforward filter. A fractionally spaced feedforward filter makes the DFE insensitive to the sampling phase.
- Precoding. Tomlinson-Harashima precoding runs the feedback filter at the transmitter with a modulo operation, so there is no error propagation and coding works as on an ISI-free channel.
- Sequence estimation with feedback. Reduced-state sequence estimation keeps a short trellis for the first taps and uses feedback per survivor for the rest; it lies between the DFE and the Viterbi equalizer.
- Soft feedback. In turbo equalization, the soft interference cancellation equalizer subtracts the mean of each symbol from a decoder instead of a hard decision.
When to use it
Use a DFE when the channel has strong postcursors or spectral nulls and a linear equalizer loses too much SNR, but the Viterbi equalizer is too expensive because or the alphabet is large. It was the standard receiver of voiceband modems and is common in high-speed serial links. When the code needs reliable symbols before decoding, or when error propagation is too costly, move the feedback to the transmitter with precoding, or iterate with the decoder.
Pitfalls
- Designing with real decisions in mind. The MMSE formulas assume correct feedback. Measure the BER of the real loop, and compare it with a run that feeds back the true symbols to separate error propagation from the noise.
- The wrong delay. On with and , the error is 0.0886 at and 0.7785 at , where the feedback is outside the span. Keep and search over the delays.
- Feedback indexing. multiplies the decision just before the current one. An off-by-one shift subtracts the wrong echo on every symbol, and the loop can still look stable at high SNR.
- The bias with multilevel alphabets. For 16-QAM or 4-PAM, slice . Without the scaling, the outer points fall short.
- Startup. Before the first decision, the feedback has no history. Start with a known preamble, or treat the symbols before the block as known zeros, as the implementation does.
- Coding. A decoder needs soft values for all symbols of a block, but the DFE needs hard decisions now. Tentative decisions from the slicer are less reliable than the decoded symbols, which is a reason for precoding.
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/.
"""Complex baseband tools for the communications pages.
Vectors are lists of complex numbers. Matrices are lists of rows. The
functions here are plain building blocks: small linear algebra, convolution,
the DFT as a direct sum, the Gaussian Q function, dB conversion, complex
Gaussian noise and the Wilson score interval. No page algorithm (equalizer,
estimator, synchronizer, detector, precoder, demapper or power allocation)
lives in this file.
Conventions (prompts of the communications area):
- dft is X[k] = sum_n x[n] e^(-j 2 pi k n / N) with no factor; idft has 1/N.
- udft and uidft are the unitary pair, with 1/sqrt(N) on both sides.
- qfunc(x) = 0.5 erfc(x / sqrt(2)); it never computes 1 - Phi(x).
- cn(rng, var) draws CN(0, var): real and imaginary parts are independent
with variance var / 2 each, so E|w|^2 = var.
"""
import cmath
import math
import random
# ---------------------------------------------------------------- vectors and matrices
def zeros(rows: int, cols: int | None = None) -> list:
"""A zero vector of length rows, or a rows by cols zero matrix."""
if cols is None:
return [0j] * rows
return [[0j] * cols for _ in range(rows)]
def eye(n: int) -> list[list[complex]]:
"""The n by n identity matrix."""
return [[1 + 0j if i == k else 0j for k in range(n)] for i in range(n)]
def add(a: list, b: list) -> list:
"""Elementwise a + b for two vectors or two matrices of the same shape."""
if len(a) != len(b):
raise ValueError("shapes differ")
if a and isinstance(a[0], list):
return [add(r, s) for r, s in zip(a, b)]
return [x + y for x, y in zip(a, b)]
def sub(a: list, b: list) -> list:
"""Elementwise a - b for two vectors or two matrices of the same shape."""
if len(a) != len(b):
raise ValueError("shapes differ")
if a and isinstance(a[0], list):
return [sub(r, s) for r, s in zip(a, b)]
return [x - y for x, y in zip(a, b)]
def scale(c: complex, a: list) -> list:
"""The scalar c times a vector or a matrix."""
if a and isinstance(a[0], list):
return [scale(c, r) for r in a]
return [c * x for x in a]
def matmul(a: list[list[complex]], b: list[list[complex]]) -> list[list[complex]]:
"""The matrix product a b."""
if not a or not b or len(a[0]) != len(b):
raise ValueError("inner dimensions differ")
cols = list(zip(*b))
return [[sum(x * y for x, y in zip(row, col)) for col in cols] for row in a]
def matvec(a: list[list[complex]], x: list[complex]) -> list[complex]:
"""The matrix times vector product a x."""
if a and len(a[0]) != len(x):
raise ValueError("inner dimensions differ")
return [sum(p * q for p, q in zip(row, x)) for row in a]
def herm(a: list) -> list:
"""The conjugate transpose of a matrix. A vector gives its conjugate."""
if a and isinstance(a[0], list):
return [[complex(a[i][k]).conjugate() for i in range(len(a))] for k in range(len(a[0]))]
return [complex(x).conjugate() for x in a]
def dot(x: list[complex], y: list[complex]) -> complex:
"""The inner product x^H y = sum of conj(x_i) y_i."""
if len(x) != len(y):
raise ValueError("lengths differ")
return sum(complex(p).conjugate() * q for p, q in zip(x, y))
def norm2(x: list) -> float:
"""The squared Euclidean norm sum |x_i|^2 (squared Frobenius norm for a matrix)."""
if x and isinstance(x[0], list):
return sum(norm2(r) for r in x)
return sum(abs(v) ** 2 for v in x)
# ---------------------------------------------------------------- linear systems
def _lu(a: list[list[complex]]) -> tuple[list[list[complex]], list[int], int]:
"""LU factorization with partial pivoting. Returns (lu, perm, sign)."""
n = len(a)
if any(len(r) != n for r in a):
raise ValueError("matrix is not square")
m = [[complex(v) for v in r] for r in a]
perm = list(range(n))
sign = 1
for k in range(n):
p = max(range(k, n), key=lambda i: abs(m[i][k]))
if abs(m[p][k]) == 0.0:
raise ValueError("matrix is singular")
if p != k:
m[k], m[p] = m[p], m[k]
perm[k], perm[p] = perm[p], perm[k]
sign = -sign
for i in range(k + 1, n):
f = m[i][k] / m[k][k]
m[i][k] = f
if f != 0:
rk, ri = m[k], m[i]
for c in range(k + 1, n):
ri[c] -= f * rk[c]
return m, perm, sign
def _lu_solve(lu: list[list[complex]], perm: list[int], b: list[complex]) -> list[complex]:
n = len(lu)
y = [complex(b[perm[i]]) for i in range(n)]
for i in range(n):
for c in range(i):
y[i] -= lu[i][c] * y[c]
for i in range(n - 1, -1, -1):
for c in range(i + 1, n):
y[i] -= lu[i][c] * y[c]
y[i] /= lu[i][i]
return y
def solve(a: list[list[complex]], b: list) -> list:
"""Solve a x = b by Gaussian elimination with partial pivoting.
b is a vector, or a matrix whose columns are right-hand sides.
Raises ValueError if a is singular.
"""
lu, perm, _ = _lu(a)
if b and isinstance(b[0], list):
cols = [list(c) for c in zip(*b)]
xs = [_lu_solve(lu, perm, c) for c in cols]
return [list(r) for r in zip(*xs)]
if len(b) != len(a):
raise ValueError("lengths differ")
return _lu_solve(lu, perm, b)
def inv(a: list[list[complex]]) -> list[list[complex]]:
"""The inverse of a square matrix."""
return solve(a, eye(len(a)))
def det(a: list[list[complex]]) -> complex:
"""The determinant of a square matrix (0 for a singular matrix)."""
try:
lu, _, sign = _lu(a)
except ValueError as e:
if "singular" in str(e):
return 0j
raise
d = complex(sign)
for i in range(len(lu)):
d *= lu[i][i]
return d
def cholesky(a: list[list[complex]]) -> list[list[complex]]:
"""The lower triangular L with a = L L^H, for a Hermitian positive definite a.
Raises ValueError if a is not positive definite (to rounding).
"""
n = len(a)
low = zeros(n, n)
for i in range(n):
for k in range(i + 1):
s = complex(a[i][k]) - sum(low[i][c] * low[k][c].conjugate() for c in range(k))
if i == k:
if s.real <= 0.0:
raise ValueError("matrix is not positive definite")
low[i][i] = complex(math.sqrt(s.real))
else:
low[i][k] = s / low[k][k].real
return low
# ---------------------------------------------------------------- convolution and the DFT
def conv(a: list[complex], b: list[complex]) -> list[complex]:
"""Linear convolution, of length len(a) + len(b) - 1."""
if not a or not b:
return []
out = [0j] * (len(a) + len(b) - 1)
for i, x in enumerate(a):
for k, y in enumerate(b):
out[i + k] += x * y
return out
def cconv(a: list[complex], b: list[complex], n: int | None = None) -> list[complex]:
"""Circular convolution of length n (default: the longer length).
Both inputs are padded with zeros to length n, or must not be longer than n.
"""
if n is None:
n = max(len(a), len(b))
if len(a) > n or len(b) > n:
raise ValueError("input longer than n")
out = [0j] * n
for i, x in enumerate(a):
for k, y in enumerate(b):
out[(i + k) % n] += x * y
return out
def _twiddles(n: int, sign: int) -> list[complex]:
return [cmath.exp(sign * 2j * math.pi * t / n) for t in range(n)]
def dft(x: list[complex]) -> list[complex]:
"""X[k] = sum over n of x[n] e^(-j 2 pi k n / N), as a direct O(N^2) sum."""
n = len(x)
w = _twiddles(n, -1)
return [sum(x[t] * w[(k * t) % n] for t in range(n)) for k in range(n)]
def idft(xf: list[complex]) -> list[complex]:
"""x[n] = (1/N) sum over k of X[k] e^(j 2 pi k n / N), the inverse of dft."""
n = len(xf)
w = _twiddles(n, 1)
return [sum(xf[k] * w[(k * t) % n] for k in range(n)) / n for t in range(n)]
def udft(x: list[complex]) -> list[complex]:
"""The unitary DFT: dft(x) / sqrt(N)."""
s = 1.0 / math.sqrt(len(x)) if x else 1.0
return [v * s for v in dft(x)]
def uidft(xf: list[complex]) -> list[complex]:
"""The unitary inverse DFT: sqrt(N) idft(X), the inverse of udft."""
s = math.sqrt(len(xf)) if xf else 1.0
return [v * s for v in idft(xf)]
# ---------------------------------------------------------------- Q function and dB
def qfunc(x: float) -> float:
"""Q(x) = P(Z > x) for a standard normal Z, computed as 0.5 erfc(x / sqrt(2))."""
return 0.5 * math.erfc(x / math.sqrt(2.0))
def qinv(p: float) -> float:
"""The x with Q(x) = p, for 0 < p < 1, by bisection on Q (which decreases)."""
if not 0.0 < p < 1.0:
raise ValueError("p must be in (0, 1)")
lo, hi = -40.0, 40.0
for _ in range(200):
mid = 0.5 * (lo + hi)
if qfunc(mid) > p:
lo = mid
else:
hi = mid
if hi - lo <= 1e-15 * max(1.0, abs(mid)):
break
return 0.5 * (lo + hi)
def db(x: float) -> float:
"""10 log10(x), for a ratio of powers or energies."""
return 10.0 * math.log10(x)
def undb(d: float) -> float:
"""10^(d / 10), the inverse of db."""
return 10.0 ** (d / 10.0)
# ---------------------------------------------------------------- noise and statistics
def cn(rng: random.Random, var: float) -> complex:
"""One sample of CN(0, var): independent real and imaginary parts of variance var / 2."""
s = math.sqrt(var / 2.0)
return complex(rng.gauss(0.0, s), rng.gauss(0.0, s))
def awgn(rng: random.Random, x: list[complex], n0: float) -> list[complex]:
"""x plus independent CN(0, n0) noise on each sample."""
return [v + cn(rng, n0) for v in x]
def wilson(k: int, n: int, z: float = 3.29) -> tuple[float, float]:
"""The Wilson score interval for k successes in n trials (z = 3.29 is about 0.999 two-sided)."""
if n <= 0 or not 0 <= k <= n:
raise ValueError("need 0 <= k <= n and n > 0")
p = k / n
z2 = z * z
den = 1.0 + z2 / n
mid = (p + z2 / (2 * n)) / den
half = z * math.sqrt(p * (1 - p) / n + z2 / (4 * n * n)) / den
return max(0.0, mid - half), min(1.0, mid + half)
decision_feedback_equalizer.py 109 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/decision-feedback-equalizer/. The authors are listed in prov/K3EMZX.jsonl.
"""The finite-length MMSE decision feedback equalizer.
The channel is y[k] = sum_{l=0}^{L-1} h[l] x[k-l] + w[k] at one sample per
symbol, with independent symbols of mean zero and E|x|^2 = Es, and noise
CN(0, N0). The feedforward filter c has Nf taps and its output
z[k] = sum_i c[i] y[k-i] estimates x[k - D]. The feedback filter b has Nb taps
and subtracts sum_j b[j] xhat[k - D - j], j = 1..Nb, built from past decisions.
The design assumes correct past decisions (ideal feedback). With the regressor
u = H s + w, H[i][j] = h[j - i], the feedback removes the columns D + 1, ...,
D + Nb of H. The feedforward taps are the Wiener solution against the rest:
R f = r with R = Es H_K H_K^H + N0 I and r = Es H e_D, c = conj(f). The
feedback taps are the postcursors of the combined response g = c * h:
b[j] = g[D + j]. The minimum mean squared error is J = Es - r^H f.
"""
import cbb
def channel_matrix(h: list[complex], nf: int) -> list[list[complex]]:
"""The Nf by Nf + L - 1 matrix H with H[i][j] = h[j - i]."""
taps = len(h)
if taps < 1 or nf < 1:
raise ValueError("need L >= 1 and Nf >= 1")
return [[complex(h[j - i]) if 0 <= j - i < taps else 0j for j in range(nf + taps - 1)] for i in range(nf)]
def dfe_design(h: list[complex], nf: int, nb: int, delay: int, n0: float, es: float = 1.0) -> tuple[list[complex], list[complex], float]:
"""The MMSE-DFE taps (c, b) and the mean squared error J, under ideal feedback.
b[0] is the tap of the decision xhat[k - D - 1], b[1] that of xhat[k - D - 2], and so on.
"""
if n0 < 0 or es <= 0 or nb < 0:
raise ValueError("need N0 >= 0, Es > 0 and Nb >= 0")
if not 0 <= delay <= nf + len(h) - 2:
raise ValueError("need 0 <= delay <= Nf + L - 2")
hm = channel_matrix(h, nf) # @line L1
m = len(hm[0])
keep = [j for j in range(m) if not delay < j <= delay + nb] # @line L2
big_r = [[es * sum(hm[i][t] * hm[k][t].conjugate() for t in keep) + (n0 if i == k else 0) for k in range(nf)] for i in range(nf)] # @line L3
r = [es * hm[i][delay] for i in range(nf)] # @line L4
try:
f = cbb.solve(big_r, r) # @line L5
except ValueError:
raise ValueError("R is singular: N0 = 0 and the kept columns of H do not span") from None
c = [v.conjugate() for v in f]
j = es - cbb.dot(r, f).real # @line L6
g = cbb.conv(c, [complex(v) for v in h]) # @line L7
b = [g[delay + t] if delay + t < len(g) else 0j for t in range(1, nb + 1)]
return c, b, j # @line L8
def combined_response(c: list[complex], h: list[complex]) -> list[complex]:
"""g = c * h, the response from the symbols to the feedforward output."""
return cbb.conv(c, [complex(v) for v in h])
def mse(c: list[complex], b: list[complex], h: list[complex], delay: int, n0: float, es: float = 1.0) -> float:
"""E|z[k] - feedback - x[k - D]|^2 for any taps, with ideal feedback.
It is Es times the squared error of the combined response after the feedback,
plus N0 ||c||^2.
"""
g = combined_response(c, h)
e = 0.0
for t, v in enumerate(g):
want = 1.0 if t == delay else 0.0
if delay < t <= delay + len(b):
v = v - b[t - delay - 1]
e += abs(v - want) ** 2
return es * e + n0 * cbb.norm2(c)
def nearest(q: complex, alphabet: list[complex]) -> complex:
"""The point of the alphabet closest to q."""
return min(alphabet, key=lambda a: abs(q - a))
def dfe_run(c: list[complex], b: list[complex], delay: int, y: list[complex], count: int, alphabet: list[complex], gain: float = 1.0, known: list[complex] | None = None) -> list[complex]:
"""Equalize y and return the decisions on x[0], ..., x[count - 1].
The symbols before x[0] are taken as 0. gain is the bias factor 1 - J / Es that
the slicer divides by. If known is given, the feedback uses the true symbols
(ideal feedback, a genie) instead of the decisions.
"""
dec = []
nb = len(b)
for k in range(count): # @line L9
n = k + delay
z = sum(c[i] * y[n - i] for i in range(len(c)) if 0 <= n - i < len(y)) # @line L10
past = known if known is not None else dec
fb = sum(b[t] * past[k - 1 - t] for t in range(nb) if k - 1 - t >= 0)
q = z - fb # @line L11
dec.append(nearest(q / gain, alphabet)) # @line L12
return dec # @line L13
def soft_outputs(c: list[complex], b: list[complex], delay: int, y: list[complex], count: int, known: list[complex]) -> list[complex]:
"""The slicer inputs q[k] with ideal feedback from the known symbols."""
out = []
for k in range(count):
n = k + delay
z = sum(c[i] * y[n - i] for i in range(len(c)) if 0 <= n - i < len(y))
fb = sum(b[t] * known[k - 1 - t] for t in range(len(b)) if k - 1 - t >= 0)
out.append(z - fb)
return out
test_decision_feedback_equalizer.py 148 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/decision-feedback-equalizer/. The authors are listed in prov/K3EMZX.jsonl.
import math
import random
import pytest
import cbb
from decision_feedback_equalizer import (
channel_matrix,
combined_response,
dfe_design,
dfe_run,
mse,
soft_outputs,
)
PROAKIS_B = [0.407, 0.815, 0.407]
QPSK = [complex(a, b) / math.sqrt(2) for a in (-1, 1) for b in (-1, 1)]
def infinite_dfe_j(h, n0, es=1.0, grid=4096):
# N0 / (geometric mean of |H|^2 + N0 / Es), by the midpoint rule on the unit circle
s = 0.0
for k in range(grid):
w = 2 * math.pi * (k + 0.5) / grid
hw = sum(v * complex(math.cos(w * l), -math.sin(w * l)) for l, v in enumerate(h))
s += math.log(abs(hw) ** 2 + n0 / es)
return n0 / math.exp(s / grid)
def test_example_on_the_page() -> None:
want = [0.090909, 0.089069, 0.088705, 0.088634, 0.08862, 0.778511]
for d, w in enumerate(want):
assert abs(dfe_design([1, 0.5], 5, 1, d, 0.1)[2] - w) < 1e-6
c, b, j = dfe_design([1, 0.5], 1, 1, 0, 0.1)
assert abs(c[0] - 1 / 1.1) < 1e-12 and abs(b[0] - 0.5 / 1.1) < 1e-12 and abs(j - 0.1 / 1.1) < 1e-12
jinf = 0.1 / ((1.35 + math.sqrt(1.35**2 - 1)) / 2)
assert abs(jinf - 0.0886164) < 1e-7
assert abs(dfe_design([1, 0.5], 15, 1, 14, 0.1)[2] - jinf) < 1e-7
assert abs(cbb.db(1 / jinf - 1) - 10.12) < 0.005
j = min(dfe_design(PROAKIS_B, 11, 2, d, 0.01)[2] for d in range(12))
assert abs(j - 0.0296778) < 1e-6 and abs(cbb.db(1 / j - 1) - 15.14) < 0.01
def test_long_filters_reach_the_infinite_length_error() -> None:
for h, n0 in (([1, 0.5], 0.1), (PROAKIS_B, 0.01), ([0.5, 1], 0.1)):
jinf = infinite_dfe_j(h, n0)
j = min(dfe_design(h, 25, len(h) - 1, d, n0)[2] for d in range(26))
assert j >= jinf - 1e-9 and j - jinf < 1e-4
def test_design_error_matches_the_error_of_the_taps_and_is_minimal() -> None:
rng = random.Random(7201)
for _ in range(40):
taps, nf = rng.randint(1, 4), rng.randint(1, 6)
nb = rng.randint(0, 3)
h = [cbb.cn(rng, 1.0) for _ in range(taps)]
n0, es = rng.uniform(0.01, 1.0), rng.uniform(0.5, 2.0)
d = rng.randint(0, nf + taps - 2)
c, b, j = dfe_design(h, nf, nb, d, n0, es)
assert abs(mse(c, b, h, d, n0, es) - j) < 1e-9
# the cursor is the bias factor 1 - J / Es
g = combined_response(c, h)
assert abs(g[d] - (1 - j / es)) < 1e-9
# the feedback cancels the postcursors exactly
for t, v in enumerate(b, start=1):
assert abs(v - (g[d + t] if d + t < len(g) else 0)) < 1e-12
for _ in range(5):
c2 = [v + cbb.cn(rng, 0.01) for v in c]
b2 = [v + cbb.cn(rng, 0.01) for v in b]
assert mse(c2, b2, h, d, n0, es) > j
assert mse(c2, b, h, d, n0, es) > j
def test_feedback_never_hurts_with_ideal_decisions() -> None:
rng = random.Random(7202)
for _ in range(30):
h = [cbb.cn(rng, 1.0) for _ in range(rng.randint(2, 4))]
nf, n0 = rng.randint(2, 6), rng.uniform(0.01, 0.5)
d = rng.randint(0, nf - 1)
js = [dfe_design(h, nf, nb, d, n0)[2] for nb in range(4)]
assert all(js[i + 1] <= js[i] + 1e-12 for i in range(3))
def test_noiseless_qpsk_is_recovered_with_decision_feedback() -> None:
rng = random.Random(7203)
for _ in range(10):
h = [complex(1.0)] + [0.4 * cbb.cn(rng, 1.0) for _ in range(rng.randint(1, 3))]
nf = 8
best = min((dfe_design(h, nf, len(h) - 1, d, 1e-8)[2], d) for d in range(nf + len(h) - 1))
d = best[1]
c, b, j = dfe_design(h, nf, len(h) - 1, d, 1e-8)
x = [rng.choice(QPSK) for _ in range(300)]
y = cbb.conv(x, h)
assert dfe_run(c, b, d, y, len(x), QPSK, 1 - j) == x
def test_mse_with_ideal_feedback_matches_j() -> None:
rng = random.Random(7204)
h, n0, nf, nb, d = [0.8 + 0.2j, -0.5, 0.3j], 0.05, 6, 2, 3
c, b, j = dfe_design(h, nf, nb, d, n0)
count = 20000
x = [rng.choice(QPSK) for _ in range(count)]
y = cbb.awgn(rng, cbb.conv(x, h), n0)
q = soft_outputs(c, b, d, y, count, x)
e = [abs(q[k] - x[k]) ** 2 for k in range(20, count)]
m = sum(e) / len(e)
sd = math.sqrt(sum((v - m) ** 2 for v in e) / (len(e) - 1))
assert abs(m - j) < 3.29 * sd / math.sqrt(len(e))
def test_zf_dfe_bpsk_error_rate_with_ideal_feedback() -> None:
# c = 1 and b = 0.5 cancel the ISI of (1, 0.5) with noise gain 1, so the BER is Q(sqrt(2 / N0))
rng = random.Random(7205)
n0, count = 0.3, 40000
x = [rng.choice((-1, 1)) for _ in range(count)]
y = [v + rng.gauss(0.0, math.sqrt(n0 / 2)) for v in cbb.conv(x, [1, 0.5])[:count]]
dec = dfe_run([1], [0.5], 0, y, count, [-1, 1], known=x)
err = sum(1 for p, q in zip(dec, x) if p != q)
p = cbb.qfunc(math.sqrt(2 / n0))
assert p * count >= 100
lo, hi = cbb.wilson(err, count)
assert lo <= p <= hi
def test_error_propagation_is_measured() -> None:
# the same noise with decided feedback: more errors than with ideal feedback, but not many more
rng = random.Random(7206)
n0, count = 0.3, 40000
x = [rng.choice((-1, 1)) for _ in range(count)]
y = [v + rng.gauss(0.0, math.sqrt(n0 / 2)) for v in cbb.conv(x, [1, 0.5])[:count]]
genie = sum(1 for p, q in zip(dfe_run([1], [0.5], 0, y, count, [-1, 1], known=x), x) if p != q)
real = sum(1 for p, q in zip(dfe_run([1], [0.5], 0, y, count, [-1, 1]), x) if p != q)
assert genie < real < 2 * genie
def test_channel_matrix_and_input_checks() -> None:
assert channel_matrix([1, 2], 2) == [[1, 2, 0], [0, 1, 2]]
with pytest.raises(ValueError):
dfe_design([1, 0.5], 3, 1, 4, 0.1)
with pytest.raises(ValueError):
dfe_design([1, 0.5], 3, -1, 0, 0.1)
with pytest.raises(ValueError):
dfe_design([1, 0.5], 0, 1, 0, 0.1)
with pytest.raises(ValueError):
dfe_design([1, 0.5], 3, 1, 0, -0.1)
History
Austin proposed decision feedback for digital communication over dispersive channels in a 1967 MIT report. In 1973, Salz derived the optimum mean-square DFE of infinite length and its minimum error, the geometric mean form above. The DFE became a common receiver for voiceband modems. Tomlinson in 1971 and Harashima and Miyakawa in 1972 moved the feedback to the transmitter. In 1995, Cioffi, Dudevoir, Eyuboglu and Forney showed that the unbiased MMSE-DFE is canonical: with ideal feedback and Gaussian codes, it reaches the capacity of the ISI channel.
References
- John G. Proakis and Masoud Salehi, Digital Communications, fifth edition, McGraw-Hill, 2008, Section 9.5 (decision-feedback equalization), with 9.5-1 (coefficient optimization) and 9.5-2 (performance and error propagation)
- John R. Barry, Edward A. Lee and David G. Messerschmitt, Digital Communication, third edition, Kluwer Academic Publishers, 2004, Chapter 8 (equalization)
- M. E. Austin, Decision-feedback equalization for digital communication over dispersive channels, Technical Report 461, MIT Research Laboratory of Electronics, August 1967, the decision feedback structure
- J. Salz, Optimum mean-square decision feedback equalization, Bell System Technical Journal 52(8), 1973, pages 1341 to 1373, the infinite-length MMSE-DFE and its error
Where this leads
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 K3EMZX Edit this page History Report an error Markdown