---
title: Coded modulation
heading: Trellis-coded modulation by set partitioning, its gains without extra bandwidth, BICM and shaping
eyebrow: S8 · Lesson 39 · Coded modulation
xp: 50
---

::: hook
The codes of lessons 34 to 37 add redundant bits, and on a band-limited channel those bits cost bandwidth or force a denser constellation. Ungerboeck's insight in 1982 was to design the code and the constellation together: double the constellation (8-PSK instead of QPSK for 2 bits per symbol) to make room for one redundant bit, and use the code to guarantee that only points far apart can be confused. The result gains 3 to 6 dB with no extra bandwidth, and its descendants, bit-interleaved coded modulation with strong binary codes, carry almost every modern wireless and cable link.
:::

::: play
- The stems are the minimum squared distance within the subsets of 8-PSK (unit energy) at each level of Ungerboeck's set partitioning: $4\sin^2(\pi 2^\ell/8)$.
- Splitting the 8 points into two QPSK subsets raises the distance from 0.586 to 2; splitting again into antipodal pairs raises it to 4.
- The code's job is to choose the subset; the uncoded bits choose the point within it, protected by the subset's large internal distance.
:::

```sim plot
view: graph
x: l = 0..2
y: d = 0..4.5
samples: 3
plot: 4*sin(pi*2^l/8)^2 | stems | label: squared distance within subsets
```

::: predict
## A 4-state trellis code sends 2 bits per symbol on 8-PSK, against uncoded QPSK at the same symbol rate and energy. What asymptotic gain does it give?

- [ ] None: 8-PSK's points are closer together
- [x] 3 dB, with no bandwidth expansion
- [ ] 6 dB, at twice the bandwidth
- [ ] 1.5 dB

::: reveal
Its free squared distance is 4 (set by parallel transitions between the antipodal points of a level-2 subset), against 2 for QPSK: $10\log_{10}(4/2) = 3.0$ dB. Both send one symbol per 2 bits, so the bandwidth is unchanged. An 8-state code reaches $d_\text{free}^2 = 2 + 0.586 + 2 = 4.586$: 3.6 dB.
:::
:::

::: nameit
## Set partitioning

Split a $2^{m+1}$-point constellation into two subsets with larger minimum distance, then each of those into two, and so on. For 8-PSK at unit energy the squared distances are $\Delta_0^2 = 0.586$, $\Delta_1^2 = 2$, $\Delta_2^2 = 4$; for square QAM each split doubles the squared distance. A rate $\tilde m/(\tilde m + 1)$ convolutional code picks the subset; the remaining uncoded bits pick a point within it, giving **parallel transitions** whose distance is the final subset's.

## Ungerboeck's rules

- Transitions leaving or entering the same state use subsets from the same first-level split, so the distance between diverging paths starts at $\Delta_1^2$.
- Parallel transitions use the most widely separated points.
- All points are used equally often.

## Gain

The asymptotic gain over an uncoded constellation of the same rate is
$$G = 10\log_{10}\frac{d_\text{free}^2/E_s^{\text{coded}}}{d_\text{min}^2/E_s^{\text{uncoded}}}$$
For 8-PSK against QPSK: 3.0 dB with 4 states, 3.6 dB with 8, and approaching 6 dB with hundreds of states. Doubling the constellation first costs $10\log_{10}(2/0.586) = 5.3$ dB in minimum distance, which the code must more than win back.

## BICM and shaping

**Bit-interleaved coded modulation** separates the two again: a strong binary code (turbo or LDPC), a bit interleaver and a Gray-labeled constellation, with the receiver computing per-bit likelihoods. Over fading channels it does better than TCM, and with modern codes it sits within about a decibel of capacity. Uniformly used points leave one more gap: the ideal input is Gaussian-like, and **shaping** (using inner points more often, or a near-spherical constellation boundary) can recover up to $10\log_{10}(\pi e/6) = 1.53$ dB.
:::

::: example
## Check the 8-state 8-PSK code's free distance and gain.

::: solution
1. **Shortest error event.** With no parallel transitions it leaves through a level-1 split ($\Delta_1^2 = 2$), passes one step at the closest distance ($\Delta_0^2 = 0.586$), and returns through another level-1 split (2).
2. **Free distance.**
   $$\begin{aligned} d_\text{free}^2 &= 2 + 0.586 + 2 \\ &= 4.586 \end{aligned}$$
3. **Gain over QPSK.** Against QPSK's 2:
   $$10\log_{10}2.293 = 3.6\ \text{dB}$$
   with the same bits per symbol and the same bandwidth.

**Answer:** $d_\text{free}^2$ = 4.586, a gain of 3.6 dB over QPSK.
:::
:::

::: example
## A 16-QAM constellation with points 2d apart is partitioned for a TCM code. What squared distance does each level's subsets have?

::: solution
1. **Level 0.** All 16 points:
   $$(2d)^2 = 4d^2$$
2. **Each split.** It doubles the squared distance: $8d^2$, $16d^2$ and $32d^2$ for subsets of 8, 4 and 2 points.
3. **Using it.** A code carrying 3 bits on 16-QAM can then aim to beat uncoded 8-PSK or 8-QAM at the same rate by protecting the subset choice.

**Answer:** $4d^2$ for all 16 points, then $8d^2$, $16d^2$ and $32d^2$ for subsets of 8, 4 and 2 points.
:::
:::

::: example
## An uncoded 64-QAM link at 10⁻⁵ is about 9 dB from capacity. A modern code recovers 7 dB and shaping 1 dB. How far from capacity is it?

::: solution
1. **Subtract the gains.**
   $$9 - 7 - 1 = 1\ \text{dB}$$
2. **Shaping's cap.** Shaping's ultimate 1.53 dB caps that part; the rest of the gap comes from finite code lengths and decoding complexity.
3. **In practice.** The best modern standards, such as DVB-S2 with its long LDPC codes, operate about this close.

**Answer:** about 1 dB from capacity.
:::
:::

::: check
kind: parts
given: l = 0 | 1 | 2; E = 1 | 2.5

## An 8-PSK constellation of symbol energy {E} is set-partitioned.

::: part
answer: 4*E*sin(pi*2^l/8)^2
tolerance: 0.5%

### What is the minimum squared distance within level-{l} subsets?

::: misses
- [any] $4E_s\sin^2(\pi2^\ell/8)$.
:::
:::
:::

::: check
kind: parts
given: f = 4 | 4.586 | 5.17; u = 2 | 2.5

## A trellis code reaches $d_\text{free}^2$ = {f} (energy-normalized); the uncoded scheme at the same rate has $d_\text{min}^2$ = {u}.

::: part
answer: 10*log(f/u)
unit: dB
tolerance: 0.5%

### What asymptotic gain does it give?

::: misses
- [20*log(f/u)] These are squared distances: 10 log.
- [any] $10\log_{10}(d_\text{free}^2/d_\text{min}^2)$.
:::
:::
:::

::: check
kind: parts
given: d = 0.5 | 1 | 2; l = 1 | 2 | 3

## A square QAM constellation with points 2d apart, d = {d}, is set-partitioned.

::: part
answer: 4*d^2*2^l
tolerance: 0.5%

### What is the minimum squared distance at level {l}?

::: misses
- [4*d^2*l] Each split doubles it.
- [any] $4d^2 \cdot 2^\ell$.
:::
:::
:::

::: check
kind: parts
given: m = 2 | 3 | 5

## A TCM scheme sends {m} bits per symbol with one redundant coded bit.

::: part
answer: 2^(m + 1)
unit: points
tolerance: 0

### How many points must its constellation have?

::: misses
- [2^m] The redundant bit doubles the constellation.
- [any] $2^{m+1}$.
:::
:::

::: part
answer: m/(m + 1)
tolerance: 0.5%

### What is the code rate on the coded-plus-uncoded bits?

::: misses
- [any] m/(m + 1).
:::
:::
:::

::: check
kind: parts
given: G = 8 | 9 | 10; c = 5 | 7; s = 0.5 | 1.5

## An uncoded scheme sits {G} dB from capacity; coding recovers {c} dB and shaping {s} dB.

::: part
answer: G - c - s
unit: dB
tolerance: 0.5%

### How far from capacity is the result?

::: misses
- [any] Subtract both gains.
:::
:::
:::

::: check
kind: parts
given: M = 8 | 16 | 32

## A constellation is doubled from {M}/2-PSK to {M}-PSK at equal energy to make room for a code bit.

::: part
answer: 10*log(sin(2*pi/M)^2/sin(pi/M)^2)
unit: dB
tolerance: 0.5%

### How much minimum distance does the doubling cost, before any coding?

::: misses
- [any] $10\log_{10}\frac{\sin^2(2\pi/M)}{\sin^2(\pi/M)}$.
:::
:::
:::

::: check
kind: choice

## How does trellis-coded modulation gain several decibels without using more bandwidth?

- [ ] It sends fewer bits
- [x] It doubles the constellation instead of adding symbols, keeping the symbol rate and so the bandwidth fixed; the code then makes sure that only sequences of points that are far apart in signal space can be confused, more than recovering the denser constellation's smaller spacing
- [ ] It uses a wider filter
- [ ] It lowers the noise

::: misses
- [1] It sends the same bits per symbol as the uncoded scheme.
- [3] Pulse shaping is unchanged.
- [4] Noise is the same; distances between sequences grow.
:::
:::

::: check
kind: derivation
vars: E = 0.1..10, M = 4..64, f = 1..10, u = 0.1..5

## An M-PSK constellation has symbol energy E; a code has $d_\text{free}^2$ = f against an uncoded $d_\text{min}^2$ = u.

::: step
answer: 4*E*sin(pi/M)^2

### What is the M-PSK minimum squared distance?
:::

::: step
answer: 10*log(f/u)

### What asymptotic gain does the code give?
:::

::: step
answer: 10*log(pi*exp(1)/6)

### What is the most shaping can add?
:::

::: right
Right. Coding moves the sequences apart; shaping makes the constellation's average energy smaller for the same distances.
:::
:::

::: check
kind: python

## Write `subset_dist(M, level)`: the minimum squared distance between points of one level-`level` subset of unit-energy M-PSK (the points $k \equiv 0 \pmod{2^\text{level}}$), by enumeration.

```python starter
def subset_dist(M, level):
    return 0.0
```

```python solution
import cmath, math

def subset_dist(M, level):
    pts = [cmath.exp(2j * math.pi * k / M) for k in range(0, M, 2 ** level)]
    return min(abs(a - b) ** 2 for i, a in enumerate(pts) for b in pts[i + 1:])
```

```python tests
import math
assert all(abs(subset_dist(8, l) - 4 * math.sin(math.pi * 2 ** l / 8) ** 2) < 1e-12 for l in range(3)), "8-PSK: 0.586, 2, 4."
assert abs(subset_dist(16, 1) - subset_dist(8, 0)) < 1e-12, "Half of 16-PSK is 8-PSK."
assert abs(subset_dist(8, 1) + subset_dist(8, 0) + subset_dist(8, 1) - 4.586) < 1e-3, "The 8-state code's free distance: 2 + 0.586 + 2."
```

::: right
Right. Enumeration confirms the closed form and generalizes to constellations without one.
:::
:::

::: explain
## Why did trellis-coded modulation make high-speed telephone modems possible?

::: model
A telephone channel has a fixed bandwidth of about 3 kHz, so adding redundant bits by sending more symbols wasn't an option, and ordinary codes that expand bandwidth were useless there. Trellis-coded modulation instead adds its redundancy by enlarging the constellation, keeping the symbol rate the same, and arranges through set partitioning that only widely separated sequences of points can be confused. That gains 3 to 6 dB of noise margin for the same rate and bandwidth, which on a phone line translated directly into higher speeds, taking modems from 9.6 to 14.4 kb/s and beyond.
:::
:::

::: practice
::: check
given: l = 1 | 2; E = 1 | 4
answer: 4*E*sin(pi*2^l/8)^2
tolerance: 0.5%

## 8-PSK level-{l} subset squared distance, Es = {E}?

::: misses
- [any] $4E_s\sin^2(\pi2^\ell/8)$.
:::
:::

::: check
given: f = 4 | 4.586 | 5.17 | 5.758 | 6.343 | 6.586 | 7.515; u = 2
answer: 10*log(f/u)
unit: dB
tolerance: 0.5%

## TCM gain for $d_\text{free}^2$ = {f} against {u}?

::: misses
- [any] $10\log_{10}(f/u)$.
:::
:::

::: check
given: d = 1 | 3; l = 2 | 4
answer: 4*d^2*2^l
tolerance: 0.5%

## QAM level-{l} squared distance, d = {d}?

::: misses
- [any] $4d^2 2^\ell$.
:::
:::
:::
