Convolutional Codes

What Problem Are We Solving?

When you send data over a wireless channel, bits can get corrupted. To fix errors, you add redundancy, extra bits that help the receiver figure out what you actually sent.

Hamming codes do this by working on fixed blocks. Take 11 bits, add 4 check bits, send the 15-bit block. Each block is independent.

Convolutional codes take a different approach. Instead of fixed blocks, they work on a continuous stream of bits. And here’s the key difference:

Each output bit depends not just on the current input, but also on the previous inputs.

The encoder remembers what you sent before.


What is an Encoder?

The encoder is the device that takes your input bits and produces output bits with redundancy added.

Think of it as a machine with a few memory slots. When you feed in a bit:

  1. The new bit enters the first slot
  2. The old bits shift over to make room
  3. The encoder looks at what’s in the slots and produces output

The animation shows bits shifting through memory slots. As each new bit enters, the previous bits move over. The encoder uses all the bits currently in memory to create output.


Why Memory Matters

Because the output depends on multiple bits (current + previous), there’s more redundancy built in.

If one bit gets corrupted during transmission, the receiver can use the surrounding context to figure out what it should have been. More memory = more context = better error correction.


The Generator Polynomial

Now we need to tell the encoder exactly how to combine the bits in memory. That’s what the generator polynomial does.

A generator polynomial is just a pattern that tells the encoder which memory slots to use when creating output.

Example: G0=1101G_0 = 1101

Read it right to left. Each position corresponds to a memory slot:

  • 11 (rightmost) → use the current bit (slot 0)
  • 00 → skip slot 1
  • 11 → use slot 2
  • 11 (leftmost) → use slot 3

So G0=1101G_0 = 1101 means: “combine the bits in slots 0, 2, and 3 to produce one output bit.”


Two Polynomials = Two Outputs

If the encoder has two generator polynomials (G0G_0 and G1G_1), it produces two output bits for every input bit.

  • G0G_0 tells it how to make the first output
  • G1G_1 tells it how to make the second output

This is where the redundancy comes from. You put in 11 bit, you get 22 bits out. The extra bit carries information about the history, which helps correct errors.


How Encoding Works

Let’s see the actual encoding process step by step.

The polynomial tells you which slots to look at!

Each digit in the polynomial corresponds to a slot. A 11 means “use this slot”, a 00 means “skip it”.

G0=1101G_0 = 1101 — read right to left:

DigitPositionSlotUse it?
11rightmostSlot 0Yes
00Slot 1No
11Slot 2Yes
11leftmostSlot 3Yes

So G0=1101G_0 = 1101 means: look at slots 0, 2, and 3. XOR those values together.

G1=1110G_1 = 1110 — same idea:

  • Slots 0, 1, 2 → Yes (the three 11s)
  • Slot 3 → No (the 00)

Now watch the animation. It will highlight which slots each polynomial looks at, then XOR those values to produce output.

Step 1: Input bit 11 arrives

Slot 0Slot 1Slot 2Slot 3
1000

Using G0=1101G_0 = 1101: The 1s are at positions 0, 2, 3 (reading right to left). So we look at slots 0, 2, and 3. They contain: 11, 00, 00. XOR them: 100=11 \oplus 0 \oplus 0 = 1

Using G1=1110G_1 = 1110: The 1s are at positions 0, 1, 2. So we look at slots 0, 1, and 2. They contain: 11, 00, 00. XOR them: 100=11 \oplus 0 \oplus 0 = 1

Output: 1111


Step 2: Input bit 00 arrives (everything shifts right)

Slot 0Slot 1Slot 2Slot 3
0100

Using G0=1101G_0 = 1101: Look at slots 0, 2, and 3. They contain: 00, 00, 00. XOR them: 000=00 \oplus 0 \oplus 0 = 0

Using G1=1110G_1 = 1110: Look at slots 0, 1, and 2. They contain: 00, 11, 00. XOR them: 010=10 \oplus 1 \oplus 0 = 1

Output: 0101


Result: Input 1010 became output 11011101

Two input bits became four output bits. That’s the redundancy. And notice how the second output (0101) depends on both the current bit (00) AND the previous bit (11) that shifted into slot 1.


The Key Numbers

Now we can understand what the formulas actually mean:


Code Rate

How many output bits do you get for each input bit?

If you have 2 polynomials → 2 outputs per input → R=1/2R = 1/2

If you have 3 polynomials → 3 outputs per input → R=1/3R = 1/3

Lower rate = more redundancy = better error correction (but more bandwidth used).


Constraint Length (K)

How many digits are in the polynomial?

PolynomialDigitsK
110111014K=4K = 4
1101011101016K=6K = 6

This tells you the encoder’s memory size. K1K-1 slots hold previous bits.

  • K=4K = 4 → 3 memory slots
  • K=6K = 6 → 5 memory slots

Longer polynomial = more memory = output depends on more history = better error correction.


Number of States

The memory slots hold bits (00 or 11). The state is whatever combination of bits is currently in memory.

States = 2K12^{K-1}

KKMemory slotsPossible combinations
443 slots23=82^3 = 8 states
665 slots25=322^5 = 32 states

Which Code is Better?

If two codes have the same rate but different constraint lengths:

Longer constraint length = lower bit error rate.

More memory means the encoder can create more sophisticated redundancy. The decoder has more context to work with when fixing errors.

K=6K = 6 beats K=4K = 4. Always.


Worked Example

Given:

  • Scheme I: G0=1101G_0 = 1101, G1=1110G_1 = 1110
  • Scheme II: G0=110101G_0 = 110101, G1=111011G_1 = 111011

Find the code rate, constraint length, and number of states. Which has lower BER?

Scheme IScheme II
Polynomials2 (G0G_0, G1G_1)2 (G0G_0, G1G_1)
Code Rate1/21/21/21/2
K4 digits6 digits
States23=82^3 = 825=322^5 = 32
Lower BER?NoYes (longer K)

Summary

ConceptWhat it means
EncoderDevice that adds redundancy using memory
Generator polynomialPattern telling which memory slots to combine
Code RateOutputs per input (1/n1/n for nn polynomials)
Constraint Length KKNumber of digits in polynomial
States2K12^{K-1} possible memory configurations
Lower BERLonger KK wins