S8 · Lesson 35 · Convolutional codes and Viterbi decoding
Encoding with shift registers, generators, constraint length and the trellis, free distance and coding gain, the Viterbi algorithm, soft decisions and puncturing
Block codes chop data into independent pieces; convolutional codes run continuously, each output bit a parity of the last few input bits, produced by a shift register a few stages long. They pair naturally with soft decisions, and Andrew Viterbi's 1967 algorithm decodes them optimally with work that grows only linearly in the message length. The constraint-length-7 code that Voyager used still appears in Wi-Fi, satellite links and deep-space missions, gaining about 5 dB at a 10⁻⁵ error rate, roughly a factor of three in transmitter power.
- Bit error probability against Eb/N0 for uncoded BPSK and for rate-1/2 convolutional codes with soft-decision Viterbi decoding, from the leading term of the union bound .
- The K = 3 code (generators 7, 5 octal, = 5) reaches 10⁻⁵ near 5.6 dB; the K = 7 code (171, 133 octal, = 10) near 4.0 dB by this estimate, and about 4.2 to 4.4 dB in measurements.
- Against uncoded BPSK's 9.6 dB, that's a coding gain of about 5 dB.
Predict
How many states does the Viterbi decoder for a constraint-length-7 convolutional code track?
The encoder's state is the contents of its memory, K − 1 = 6 bits, so there are = 64 states. At each step the decoder extends 2 branches into each state, 128 branch metrics, and keeps the better path into each state. The work per decoded bit is constant, which made Viterbi decoding practical in 1970s hardware.
Name it
The encoder
A rate-1/n convolutional code shifts each input bit into a register of length K (the constraint length) and outputs n bits, each the modulo-2 sum of register taps given by a generator polynomial, written in octal. The (7, 5) code: = 111, = 101. The encoder is a finite-state machine with states; unrolling it in time gives the trellis.
Free distance and coding gain
The free distance is the least Hamming weight of any coded sequence that leaves the all-zero path and returns. Best rate-1/2 codes: K = 3, 5; K = 5, 7; K = 7, 10; K = 9, 12. With soft decisions,
where counts the information-bit errors on those paths (1 for the (7,5) code, 36 for the K = 7 code). Hard decisions lose about 2 dB.
The Viterbi algorithm
At each time step, for every state, add each incoming branch's metric (squared Euclidean distance for soft decisions, Hamming distance for hard) to the survivor metric of the state it came from, and keep only the best. After a traceback depth of about 5K, all survivors agree on old decisions, which are output. Complexity: branch metrics per bit.
Puncturing
Deleting some coded bits in a fixed pattern raises the rate with one decoder: keeping 4 of every 6 coded bits from a rate-1/2 code gives rate 3/4, as in Wi-Fi's 54 Mb/s mode.
Worked example
Encode 1, 0, 1, 1 with the (7, 5) code starting from the zero state.
Show the solution
- First input, 1. The register (newest first) becomes 100, so the outputs are giving 11.
- Second input, 0. The register is 010, giving 1 and 0: 10.
- Third input, 1. The register is 101, giving 0 and 0: 00.
- Fourth input, 1. The register is 110, giving 0 and 1: 01.
- Flush. Two flushing zeros would follow to return to state 0.
Answer the coded stream is 11 10 00 01.
Worked example
What asymptotic gains do the K = 3 and K = 7 codes promise, and what do they deliver at 10⁻⁵?
Show the solution
- K = 3, asymptotically.
- K = 3 at 10⁻⁵. The estimate needs 5.6 dB against 9.6, a gain of
- K = 7, asymptotically.
- K = 7 at 10⁻⁵. The many error paths ( = 36) make the real gain at 10⁻⁵ about 5 to 5.6 dB.
- When the asymptote arrives. The asymptotic figure is reached only at very low error rates.
Answer K = 3 promises 4.0 dB and delivers 4.0 dB at 10⁻⁵; K = 7 promises 7.0 dB and delivers about 5 to 5.6 dB.
Worked example
The K = 7 rate-½ code ( = 10) is punctured to rate ⅔ ( = 6) and rate ¾ ( = 5). What asymptotic coding gains do the three versions promise?
Show the solution
- The asymptotic gain.
- Rate ½.
- Rate ⅔.
- Rate ¾.
- The trade. Puncturing gives up about a decibel of gain for half again the throughput, with the same Viterbi decoder.
Answer 7.0 dB at rate ½, 6.0 dB at rate ⅔ and 5.7 dB at rate ¾.
Check
A convolutional code has constraint length 5. How many states does its trellis have?
Check
A rate-0.5 convolutional code has = 7. What asymptotic soft-decision coding gain does it promise?
Check
A rate-1/2 code with = 5 and = 4 is decoded with soft decisions at Eb/N0 = 5 dB. Roughly what bit error probability results?
Check
How many branch metrics does a Viterbi decoder for constraint length 7 compute per decoded bit (rate 1/n)?
Check
A rate-1/2 code is punctured so that, for every 3 data bits, only 4 coded bits are sent. What's the new code rate?
Check
About how deep should a Viterbi decoder's traceback be for constraint length 7?
Check
A rate-0.5 convolutional code with constraint length 5 has = 10.
(a)
How many trellis states does it have?
(b)
What asymptotic soft-decision gain does it promise?
Check
A code of rate R and free distance d has = B and runs at Eb/N0 = E (linear) with soft decisions.
Step 1
What is its asymptotic gain in dB?
Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.
Step 2
What bit error probability does the dominant term give?
Explain why
Why does the Viterbi algorithm only need to keep one path into each state?
The encoder's future behavior depends only on its current state, not on how it got there, and the total path metric is a sum of independent branch metrics. If two candidate paths arrive at the same state at the same time, whatever continuation lies ahead adds exactly the same future metric to both. The one that's already worse can therefore never overtake the other, so it can be discarded immediately without losing the optimal path. Keeping only the best survivor into each of the states at each step finds the maximum-likelihood sequence exactly, with work that grows linearly in the message length instead of exponentially in the number of possible sequences.
Practice
Keep practicing
10 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.