1import numpy as np2u = np.array([1, 0, 1, 1])3c1 = np.convolve(u, [1,1,1]) % 24c2 = np.convolve(u, [1,0,1]) % 2u[0]1u[1]0u[2]1u[3]1u[4]0u[5]0u[n]0u[n−1]0u[n−2]00101c1c2DECODERû[0]–û[1]–û[2]–û[3]–11111
TRELLIS · 4 STATESrxin111100011111in 0in 1000110110123456n02041213212323122322323100:211:010:1001:11100soft: same path · 4.57 V²
0246810-2-1012k (code bit)voltsRECEIVED r[k]sentreceived111100011111decide 1 if r > 0r[3] = +0.26 V: a weak 1TANNER GRAPH · LDPCchecksbits✓✗✓✗✓✗✓✗01x001x110x201x310x410x5
Coloured parts: what the current step is about; everything else rests in whiteBlocks: message bits, shift register, mod-2 adders with bit lamps, channel, decoder, decoded bits, Python cardPanels: the trellis, the received voltages r[k], and the Tanner graph of a small LDPC codeTokens carry bits from the message into the register, to the channel and on to the decoderThe rate-1/2, K = 3 convolutional code (taps 111 and 101) encodes 1011 as 11 10 00 01 01 11; Gaussian noise flips two bits and the Viterbi decoder recovers 1011. Then a toy LDPC code corrects one flipped bit by bit flipping. The LDPC example is a toy: 6 bits are far too few for H to be truly sparse, and real decoders pass soft beliefs (belief propagation) instead of flipping hard bits. The idea (parity checks on few bits, decoded iteratively) is the same.

A code with memory

  1. A Hamming code guards fixed blocks. A convolutional code works on a stream. The encoder keeps a sliding window of the last K = 3 message bits in a shift register: the new bit u[n] and the two before it.

Through a noisy channel

Viterbi decoding

LDPC codes

The working

# step 1/11 · window

message   u = 1 0 1 1
window    [u[n], u[n−1], u[n−2]]
          K = 3 bits (the constraint length)

the register starts at 0 0
each tick: the new bit enters on the left,
the oldest bit falls off the right

block codes (Hamming): see "Parity and Hamming codes"

The code is the rate-1/2, K = 3 convolutional code with generators 111 and 101 (octal 7 and 5), free distance 5, the "(3, (7, 5))" code of MIT 6.02, ch. 8. Practical systems use longer codes, such as K = 7 with rate 1/2, used since the Voyager program. The noise is one repeatable draw of Gaussian noise with σ = 0.7 V from a seeded generator; a different draw flips different bits. Every number in the figure is computed from this model.