Channel Coding(3)
(convolutional codes)
Prof H. Xu
April 24, 2023
Introduction
→During each unit of time, the input to a convolutional code
encoder is a k-bit message block and the corresponding output is
an n-bit coded block with k n .
→Each coded n-bit output block depends not only on the
corresponding k-bit input message block at the same time unit
but also on the m previous message blocks.
→Thus the encoder has k input lines, n output lines and a
memory of order m.
An ( 2,1,3) convolutional code encoder.
Introduction
→ Each message (or information) sequence is encoded into a
code sequence.
→The set of all possible code sequences produced by the
encoder is called an ( n, k , m ) convolutional code.
→The ratio R = k n is called the code rate.
→ The parameter m is called the memory order of the
code.
→ The constraint length of a convolutional code, K , is
defined as the number of shifts over which a single message
bit can influence the encoder output. K = m + 1 .
Representation of Convolutional Codes
→Encoder block diagram (shown above)
→Generator representation
→Code tree
→Trellis representation
→State diagram representation
Convolutional code generators
→One generator vector for each of the outputs bits.
→ The length of the generator vector for a rate r = k n code
with constraint length is K .
→The bits in the generator from left to right represent the
connections in the encoder circuit. A “1” represents a link
from the shift register. A “0” represents no link.
→Encoder vectors are often given in octal representation
→Each encoder vector can be associated with a generator
polynomial.
Convolutional code generators
.
Example:
g1 = (1011) = (13 )8 ; g1 = 1 + D 2 + D 3
g2 = (1111) = (17 )8 ; g2 = 1 + D + D 2 + D 3
Code tree representation
→Each branch of the tree represents an input symbol, with the
corresponding pair of output binary symbol indicated on the
branch.
→The convention is to distinguish the input binary symbols “0”
and “1” as follows. An input “0” specifies the upper branch,
whereas input “1” specifies the lower branch.
→A specific path in the tree is traced from left to right in
accordance with the input (message) sequence.
Code tree representation
Example:
State diagram representation
→In a Convolutional encoder, the state is represented by the
content of the shift registers which form the memory. Hence,
there are 2 m = 2 K −1 states. At any time instant, the encoder must
be in one of these states.
→The encoder undergoes a state transition when a message bit is
shifted into the encoder register.
→ At each time unit, the output block depends on the input and
the state.
→ In the state diagram, each state is represented by a vertex (or
point) on a plane.
→ The transition from one state to another state is represented
by a directed line (arc).
→ Each directed line is labeled with I/O (input/output) pair.
State diagram representation
Example : Consider a rate 1/2 ( 2,1, 2 ) convolutional
code, which is specified by the following two generators
sequences: g (1) = (101)
g (2) = (111)
There are four states: 00 ,01 ,10 , and 11 .
State diagram representation
Trellis diagram
→The state diagram can be expanded in time to display the
state transition of a convolutional encoder in time. This
expansion in time results in a trellis diagram.
→Normally the encoder starts from the all-zero state.
→Termination of a Trellis: Suppose the message sequence
is L bits long, m = ( m0 , m1 , , mL −1 ) . When the entire
sequence has been encoded, the encoder must return to
the starting state. This can be done by appending m zeros
to the message sequence m .
1/10
S3 M = (1011100 )
0/01
1/01
S1
0/10
S2
1/11
0/00
S0
i=0 i =1 i=2 i=3 i=4 i=5 i=6 i=7
Trellis diagram for the example convolutional code
Decoding of Convolutional Codes
Maximum Likelihood Decoding
→For a convolutional code, each code sequence is a path in
the trellis diagram of the code.
→Suppose each message sequence m consists of L message
blocks of k bits each, m = ( m0 , m1 , , ml , , m L−1 ) .
→Then each code sequence c is a path of L + m branches
long in the trellis diagram, c = ( c0 , c1 , , cl , cL+m−1 ) , where the
l -th branch (or code block) cl = ( cl , cl , , cl ) .
(1) (2) (n)
→Suppose a code sequence c is transmitted.
Decoding of Convolutional Codes
Maximum Likelihood Decoding
→Let r = ( r0 , r1 , , rl , , rL + m−1 ) be the received sequence, where
the l-th received block rl = ( rl(0) , rl(1) , , rl( n ) ) .
→MLD: Find the path through the trellis diagram such that
the conditional probability, P ( c r ) , is the largest.
Decoding of Convolutional Codes
Viterbi Decoding of Convolutional Codes
→The Viterbi algorithm performs the maximum likelihood
decoding and it also reduces the computational complexity by
taking advantage of the special structure of the code trellis.
Basic Concepts:
→Generate the code trellis at the decoder.
→The decoder penetrates through the code trellis level
by level (time index) in search for the transmitted code
sequence.
→At each level of the trellis, the decoder computes and
compares the metrics of all the partial paths entering a
node.
Viterbi Decoding of Convolutional Codes
Basic Concepts:
→The decoder stores the partial path with the largest metric
and eliminates all the other partial paths. The stored partial
path is called the survivor.
→ For m l L , there are 2km nodes at the l-th level of the
code trellis. Hence there are 2km survivors.
→When the code trellis begins to terminate, the number of
survivors reduces.
→At the end, the ( L + m )-th level, there is only one node (the
all-zero state) and hence only one survivor stays.
→ This last survivor is the maximum likelihood path (or code
sequence).
Viterbi Decoding of Convolutional Codes
The Viterbi Algorithm
Step 1: Starting at the level l = m in the trellis, compute the partial metric
for the single path (starting from level 1) entering each m-th order node.
Store the path (the survivor) and its metric for each node.
Step 2: Increasing l by 1. Compute the partial metric for all the paths
entering a (l+1)-th order node by adding the branch metric entering that
node to the metric of the connecting survivor at a previous l-th order node.
For each (l+1)-th node, store the path with the largest metric (the survivor),
together with its metric, and eliminate all the other paths.
Step 3: If l L + m , repeat Step 2. Otherwise, stop.
The Viterbi Decoding
Example 1: Consider the (2,1,2) convolutional code shown in
below.
Suppose c = ( 00,11,10,10, 00, 01,11) is transmitted and
r = ( 01,11,10,10, 00,11,10 ) is received.
Decode the received sequence.
Note:
→The message length L = 5.
→There are 7 levels in the trellis.
we will calculate metric which is the difference between
received symbols and standard symbol. The survive path
will have smallest weight metric.
r = ( 01,11,10,10, 00,11,10 )
r1 = 01 d 0 = d (00, r1 ) = 1
d 2 = d (11, r1 ) = 1
r2 = 11
d3 = d 2 + d (10, r2 ) = 2
S3
S1 d1 = d 2 + d (01, r2 ) = 2
S2 d 2 = d (11, r2 ) + d 0 = 1
S0 d 0 = d (00, r2 ) + d 0 = 3
i=0 i =1 i=2
r = ( 01,11,10,10, 00,11,10 )
r3 = 10 d 0 − 0 = d (00, r3 ) + d 0 = 4
d0 = 3
d1− 0 = d (11, r3 ) + d1 = 3
d 0 − 2 = d (11, r3 ) + d 0 = 4
d2 = 3
d1− 2 = d (00, r3 ) + d1 = 3
S 3 d3 = 2 d3 = 1
S 1 d1 = 2 d1 = 2
d 2 − 1 = d (01, r3 ) + d 2 = 3 S 2 d2 = 1 d2 = 3
d 3− 1 = d (10, r3 ) + d 3 = 2
S 0 d0 = 3 d0 = 3
d 2 − 3 = d (10, r3 ) + d 2 = 1 i=2 i=3
d 3− 3 = d (01, r3 ) + d 3 = 4
r = ( 01,11,10,10, 00,11,10 )
r4 = 10 d 0 − 0 = d (00, r4 ) + d 0 = 5
d0 = 3
d1− 0 = d (11, r4 ) + d1 = 3
d 0 − 2 = d (11, r4 ) + d 0 = 4
d2 = 3
d1− 2 = d (00, r4 ) + d1 = 3
S 3 d3 = 1 d3 = 3
S 1 d1 = 2 d1 = 1
d 2 − 1 = d (01, r4 ) + d 2 = 5 S 2 d2 = 3 d2 = 3
d 3− 1 = d (10, r4 ) + d 3 = 1
S 0 d0 = 3 d0 = 3
d 2 − 3 = d (10, r4 ) + d 2 = 3 i=3 i=4
d 3− 3 = d (01, r4 ) + d 3 = 3
r = ( 01,11,10,10, 00,11,10 )
r5 = 00 d 0 − 0 = d (00, r5 ) + d 0 = 3
d0 = 3
d1− 0 = d (11, r5 ) + d1 = 3
d 0 − 2 = d (11, r5 ) + d 0 = 5
d2 = 1
d1− 2 = d (00, r5 ) + d1 = 1
S 3 d3 = 3 d3 = 4
S 1 d1 = 1 d1 = 4
d 2 − 1 = d (01, r5 ) + d 2 = 4 S 2 d2 = 3 d2 = 1
d 3− 1 = d (10, r5 ) + d 3 = 4
S 0 d0 = 3 d0 = 3
d 2 − 3 = d (10, r5 ) + d 2 = 4 i=4 i=5
d 3− 3 = d (01, r5 ) + d 3 = 4
r = ( 01,11,10,10, 00,11,10 )
r6 = 11 d 0 − 0 = d (00, r6 ) + d 0 = 5
d0 = 4
d1− 0 = d (11, r6 ) + d1 = 4
S 3 d3 = 4
S 1 d1 = 4 d1 = 2
d 2 − 1 = d (01, r6 ) + d 2 = 2 S 2 d2 = 1
d 3− 1 = d (10, r6 ) + d 3 = 4
S 0 d0 = 3 d0 = 4
i=5 i=6
r = ( 01,11,10,10, 00,11,10 )
r7 = 10 d 0 − 0 = d (00, r7 ) + d 0 = 5
d0 = 3
d1− 0 = d (11, r7 ) + d1 = 3
S3
S 1 d1 = 2
S2
S 0 d0 = 4 d0 = 3
i=6 i=7
i : 6− 7 path : S1 − S 0 i : 3− 4 path : S3 − S1
i : 5− 6 path : S 2 − S1 i : 2− 3 path : S 2 − S3
i : 4− 5 path : S1 − S 2 i : 1− 2 path : S 0 − S 2
S3
S1
S2
0/000
S0
i=0 i =1 i=2 i=3 i=4 i=5 i=6 i=7
d3 = 1 d3 = 4 d3 = 6 d3 = 5
S3
d1 = 4
d1 = 1 d1 = 6 d1 = 2
S1 d1 = 5
d2 = 3 d2 = 4 d2 = 1
S2 d2 = 1
d2 = 6
d0 = 2 d0 = 4 d0 = 1 d0 = 2
d0 = 5 d0 = 3 d0 = 5
S0
i=0 i =1 i=2 i=3 i=4 i=5 i=6 i=7
1/001
Example 2 0/110 1/010
0/101 Input/output1 output2 output 3
1/100
D D
0/011 1/111
0/000
(3,1,2) Encoder Diagram of state transition
r =( 1 1 0, 1 1 0, 1 1 0, 1 1 1, 0 1 0, 1 0 1, 1 0 1)
Decode the received sequence
d 3 (3) = d 2 (2) + 2 d 3 (5) = d 2 (4) + 3
d 3 (4) = d 3 (3) + 1
d 3 ( 2) = 2 + 2 = 5 = 11
= d 2 (3) + 1 = 6
S3 S3
S3 S3
d 2 (5) = 10
S2 S2 S2 S2 S2
d 2 (1) = 2 d 2 ( 2) = 1 + 2 d 2 (3) = 5 d 2 (4) = 8
S1 S1 S1 S1 S1
d1 (2) = 2 + 1 d1 (3) = 7 d1 (4) = 7 d1 (5) = 8 d1 (6) = 13
S0 S0 S0 S0 S0 S0 S0 S0
d 0 (1) = 1 d 0 (2) = 1 + 1 d 0 (3) = d1 (2) + 1 d 0 (4) = d1 (3) + 2 d 0 (5) = 11 d 0 (6) = 11 + 1 d 0 (7) = 13 + 1
=4 =9
Figure 5.3 Viterbi Algorithm
r =( 1 1 0, 1 1 0, 1 1 0, 1 1 1, 0 1 0, 1 0 1, 1 0 1)
Performance of convolutional codes ??