ANU ENGN 3226
AUSTRALIAN NATIONAL UNIVERSITY
Department of Engineering
ENGN 3226 Digital Communications
Problem Set #8 Block Codes
Q1
Consider a (6,3) linear block code defined by the generator matrix
1 0 0 1 1 0
→
−
G = 0 1 0 0 1 1
0 0 1 1 0 1
→
−
(a) Determine if the code is a Hamming code. Find the parity check matrix H of the code in systematic form.
(b) Find the encoding table for the linear block code.
(c) What is the minimum distance dmin of the code. How many errors can the code detect. How many errors
can the code correct.
(d) Draw the hardware encoder diagram.
(e) Find the decoding table for the linear block code.
(f) Draw the hardware
syndrome generator diagram. −
(g) Suppose →−c = 1 1 1 0 0 0 is sent and →
r = 1 1 1 0 0 1 is received. Show how
the code can correct this error.
Q2
Consider a (7,4) linear block code defined by the generator matrix
1 0 0 0 1 1 0
→
− 0 1 0 0 0 1 1
G = 0 0 1 0 1 1 1
0 0 0 1 1 0 1
→
−
(a) Determine if the code is a Hamming code. Find the parity check matrix H of the code in systematic form.
(b) Find the encoding table for the linear block code.
(c) What is the minimum distance dmin of the code. How many errors can the code detect. How many errors
can the code correct.
(d) Draw the hardware encoder diagram.
(e) Find the decoding table for the linear block code.
(f) Draw the hardware syndrome generator diagram.
(g) Suppose →−c = 1 0 0 1 0 1 1 is sent and → −r = 1 1 0 1 0 1 1 is received. Show
how the code can correct this error.
Q3
Consider a (5,1) linear block code defined by the generator matrix
→
−
G = 1 1 1 1 1
→
−
(a) Find the parity check matrix H of the code in systematic form.
(b) Find the encoding table for the linear block code.
(c) What is the minimum distance dmin of the code. How many errors can the code detect. How many errors
can the code correct.
(d) Draw the hardware encoder diagram.
(e) Find the decoding table for the linear block code (consider single bit errors only).
(f) Draw the hardware syndrome generator diagram.
(g) Suppose →−c = 1 1 1 1 1 is sent and → −r = 0 1 1 1 1 is received. Show how the code
can correct this error.
Problem Set #8 page 1
ANU ENGN 3226
Q4
Consider the generator polynomial for a (7,3) cyclic code defined by
g(p) = p4 + p3 + p2 + 1
(a) Find the encoding table for the cyclic code.
(b) What is the minimum distance dmin of the code.
Q5
Consider the generator polynomial for a (7,4) cyclic code defined by
g(p) = p3 + p2 + 1
(a) Find the encoding table for the cyclic code.
(b) What is the minimum distance dmin of the code.
(c) Find the systematic output codeword for input →
−
c = 1 1 1 1 .
Problem Set #8 page 2
ANU ENGN 3226
AUSTRALIAN NATIONAL UNIVERSITY
Department of Engineering
ENGN 3226 Digital Communications
Problem Set #8 Solution
Q1: Complete Solution
(a)
Testing for hamming code, we have
m = n−k = 6−3 = 3
k = 2m − m − 1 = 23 − 3 − 1 = 4 6= 3
n = 2m − 1 = 23 − 1 = 7 6= 6
Hence (6, 3) is not a Hamming code.
We have
1 0 0 1 1 0
→
−
G = 0 1 0 0 1 1
0 0 1 1 0 1
1 1 0
→
−
P = 0 1 1
1 0 1
1 0 1
→
−T
P = 1 1 0
0 1 1
1 0 1
→
−
I3 = 1 1 0
0 1 1
→
− − .→
→ −
H = [ P T .. I n−k ]
1 0 1 1 0 0
→
−
H = 1 1 0 0 1 0
0 1 1 0 0 1
(b)
The encoding table for (6, 3) linear block code is
Message Code word Weight of code word
000 000000 0
001 001101 3
010 010011 3
011 011110 4
100 100110 3
101 101011 4
110 110101 4
111 111000 3
Problem Set #8 page 3
ANU ENGN 3226
This is calculated as follows
1 0 0 1 1 0
→
− →
−
c0=→
−
m0 G = 0 0 0 0 1 0 0 1 1
0 0 1 1 0 1
= 0 0 0 0 0 0
→
− →
− 1 0 0 1 1 0
c1=→
−
m1 G = 0 0 1 0 1 0 0 1 1
0 0 1 1 0 1
→
−
= 0 0 1 1 0 1 (3rd row of G )
→
− →
− 1 0 0 1 1 0
c2=→
−
m2 G = 0 1 0 0 1 0 0 1 1
0 0 1 1 0 1
→
−
= 0 1 0 0 1 1 (2nd row of G )
→
− →
− 1 0 0 1 1 0
c3=→
−
m3 G = 0 1 1 0 1 0 0 1 1
0 0 1 1 0 1
→
− →
−
= 0 1 1 1 1 0 (2nd row of G + 3rd row of G )
→
− →
− 1 0 0 1 1 0
c4=→
−
m4 G = 1 0 0 0 1 0 0 1 1
0 0 1 1 0 1
→
−
= 1 0 0 1 1 0 (1st row of G )
→
− →
− 1 0 0 1 1 0
c5=→
−
m5 G = 1 0 1 0 1 0 0 1 1
0 0 1 1 0 1
→
− →
−
= 1 0 1 0 1 1 (1st row of G + 3rd row of G )
→
− →
− 1 0 0 1 1 0
c6=→
−
m6 G = 1 1 0 0 1 0 0 1 1
0 0 1 1 0 1
→
− →
−
= 1 1 0 1 0 1 (1st row of G + 2nd row of G )
→
− →
− 1 0 0 1 1 0
c7=→
−
m7 G = 1 1 1 0 1 0 0 1 1
0 0 1 1 0 1
→
− →
− →
−
= 1 1 1 0 0 0 (1st row of G + 2nd row of G + 3rd row of G )
(c)
From encoding table, we have
dmin = 3
e = dmin − 1 = 2
1
t ≤ (dmin − 1) ≤ 1
2
Hence the (6, 3) linear block code can detect 2 bit errors and correct 1 bit error in 6 bit output codeword.
Problem Set #8 page 4
ANU ENGN 3226
(d)
The output for general code word is
1 0 0 1 1 0
→
− →
−
c =→
−
mG = m1 m2 m3 0 1 0 0 1 1
0 0 1 1 0 1
= m1 m2 m3 m1 + m3 m1 + m2 m2 + m3
The hardware encoder implementation is
m (6,3) Linear block code encoder c
m1 m2 m3 c1 c2 c3 c4 c5 c6
Figure 1: Figure for Question 1 (d).
(e)
We have
1 0 1 1 0 0
→
−
H = 1 1 0 0 1 0
0 1 1 0 0 1
1 1 0
0 1 1
→
−T 1 0 1
H =
1
0 0
0 1 0
0 0 1
The decoding table is
Error Pattern Syndrome Comment
000000 000 all 0’s
→
−
100000 110 1st row of H T
→
−
010000 011 2nd row of H T
→
−T
001000 101 3rd row of H
→
−
000100 100 4th row of H T
→
−
000010 010 5th row of H T
→
−
000001 001 6th row of H T
Problem Set #8 page 5
ANU ENGN 3226
(f)
The syndrome for general received word is
1 1 0
0 1 1
→ −r →
−s = → −T
H =
r1 r2 r3 r4 r5
r6
1 0 1
1 0 0
0 1 0
0 0 1
= r1 + r3 + r4 r1 + r2 + r5 r2 + r3 + r6
The hardware syndrome generator implementation is
r (6,3) Linear block code syndrome generator s
r1 r2 r3 r4 r5 r6 s1 s2 s3
Figure 2: Figure for Question 1 (h).
(g)
Given that →
− is sent and →
−r =
c = 1 1 1 0 0 0 1 1 1 0 0 1 is received.
1 1 0
0 1 1
→
−s −r →
= →
−T
H =
1 1 1 0 0 1
1 0 1
1 0 0
0 1 0
0 0 1
= 0 0 1
From decoding table, this syndrome corresponds to error pattern →
−
e = [000001]. Hence the corrected code
word is
→
−
y = →
−r + →
−
e
= 1 1 1 0 0 1 + 0 0 0 0 0 1
= 1 1 1 0 0 0
Problem Set #8 page 6
ANU ENGN 3226
Q2: Partial Solution
(a)
Testing for hamming code, we have
m = n−k = 7−4 = 3
k = 2m − m − 1 = 23 − 3 − 1 = 4
n = 2m − 1 = 23 − 1 = 7
Hence (7, 4) is a Hamming code.
We have
→
− − .→
→ −
G = [ I k .. P ]
1 0 0 0 1 1 0
→
− 0 1 0 0 0 1 1
G =
0 0 1
0 1 1 1
0 0 0 1 1 0 1
→
− − .→
→ −
H = [ P T .. I n−k ]
1 0 1 1 1 0 0
→
−
H = 1 1 1 0 0 1 0
0 1 1 1 0 0 1
(b)
The encoding table for (7, 4) linear block code is
Message Code word Weight of code word
0000 0000000 0
0001 0001101 3
0010 0010111 4
0011 0011010 3
0100 0100011 3
0101 0101110 4
0110 0110100 3
0111 0111001 4
1000 1000110 3
1001 1001011 4
1010 1010001 3
1011 1011100 4
1100 1100101 4
1101 1101000 3
1110 1110010 4
1111 1111111 7
(c)
From encoding table, we have
dmin = 3
e = dmin − 1 = 2
1
t ≤ (dmin − 1) ≤ 1
2
Hence the (7, 4) linear block code can detect 2 bit errors and correct 1 bit error in 7 bit output codeword.
Problem Set #8 page 7
ANU ENGN 3226
(d)
The output for general code word is
1 0 0 0 1 1 0
→
− →
− 0 1 0 0 0 1 1
c =→
−
mG = m1 m2 m3 m4 0
0 1 0 1 1 1
0 0 0 1 1 0 1
= m1 m2 m3 m4 m1 + m3 + m4 m1 + m2 + m3 m2 + m3 + m4
The hardware encoder implementation is
m (7,4) Hamming code encoder c
m1 m2 m3 m4 c1 c2 c3 c4 c5 c6 c7
Figure 3: Figure for Question 2 (d).
(e)
We have
1 1 0
0 1 1
1 1 1
→
−T
H =
1 0 1
1 0 0
0 1 0
0 0 1
The decoding table is
Error Pattern Syndrome
0000000 000
1000000 110
0100000 011
0010000 111
0001000 101
0000100 100
0000010 010
0000001 001
Problem Set #8 page 8
ANU ENGN 3226
(f)
The syndrome for general received word is
1 1 0
0 1 1
1 1 1
→ −r →
−s = → −T
H =
r1 r2 r3 r4 r5 r6
r7 1 0 1
1 0 0
0 1 0
0 0 1
= r1 + r3 + r4 + r5 r1 + r2 + r3 + r6 r2 + r3 + r4 + r7
The hardware syndrome generator implementation is
r (7,4) Hamming code syndrome generator s
r1 r2 r3 r4 r5 r6 r7 s1 s2 s3
Figure 4: Figure for Question 2 (h).
(g)
Given that →
− is sent and →
−r =
c = 1 0 0 1 0 1 1 1 1 0 1 0 1 1 is received.
1 1 0
0 1 1
1 1 1
→ −r →
−s = → −T
=
1 1 0 1 0 1 1
H 1 0 1
1 0 0
0 1 0
0 0 1
= 0 1 1
From decoding table, this syndrome corresponds to error pattern →
−
e = [0100000]. Hence the corrected code
word is
→
−
y = →
−r + →
−
e
= 1 1 0 1 0 1 1 + 0 1 0 0 0 0 0
= 1 0 0 1 0 1 1
See also Lecture 19, Example 1.
Problem Set #8 page 9
ANU ENGN 3226
Q3: Solution
(a)
→
− − .→
→ −
G = [ I k .. P ]
→
−
G = 1 1 1 1 1
→
− − .→
→ −
H = [ P T .. I n−k ]
1 1 0 0 0
→
− 1 0 1 0 0
H =
1 0 0
1 0
1 0 0 0 1
(b)
The encoding table for (5, 1) linear block code is
Message Code word Weight of code word
0 00000 0
1 11111 5
(c)
From encoding table, we have
dmin = 5
e = dmin − 1 = 4
1
t ≤ (dmin − 1) ≤ 2
2
Hence the (5, 1) linear block code can detect 4 bit errors and correct 2 bit errors in 5 bit output codeword.
(d)
The output for general code word is
→
− →
−
c =→ −
mG = m1 1 1 1 1 1
= m1 m1 m1 m1 m1
The hardware encoder implementation is
m (5,1) Linear block code encoder c
m1 c1 c2 c3 c4 c5
Figure 5: Figure for Question 3 (d).
Problem Set #8 page 10
ANU ENGN 3226
(e)
We have
1 1 1 1
1 0 0 0
→
−T
H =
0 1 0 0
0 0 1 0
0 0 0 1
The decoding table is
Error Pattern Syndrome
00000 0000
10000 1111
01000 1000
00100 0100
00010 0010
00001 0001
(f)
The syndrome for general received word is
1 1 1 1
1 0 0 0
→ −r →
−s = → −T
H =
r1 r2 r3 r4 r5
0 1 0 0
0 0 1 0
0 0 0 1
= r1 + r2 r1 + r3 r1 + r4 r1 + r5
The hardware syndrome generator implementation is
r (5,1) Linear block code syndrome generator s
r1 r2 r3 r4 r5 s1 s2 s3 s4
Figure 6: Figure for Question 3 (h).
Problem Set #8 page 11
ANU ENGN 3226
(g)
Given that →
− is sent and →
−r =
c = 1 1 1 1 1 0 1 1 1 1 is received.
1 1 1 1
1 0 0 0
→ −r →
−s = → −T
=
0 1 1 1 1
H 0 1 0 0
0 0 1 0
0 0 0 1
= 1 1 1 1
From decoding table, this syndrome corresponds to error pattern →
−
e = [1000]. Hence the corrected code word
is
→
−
y = →
−r + →
−
e
= 0 1 1 1 1 + 1 0 0 0 0
= 1 1 1 1 1
Q4: Complete Solution
(a)
Given that the generator polynomial for a (7,3) cyclic code is
g(p) = p4 + p3 + p2 + 1
The output code words are given by
c(p) = M(p)g(p)
Tabulating the results
Input M(p) c(p) = M(p)g(p) Code word Weight of code word
000 0 0 0000000 0
001 1 p4 + p3 + p2 + 1 0011101 4
010 p p5 + p4 + p3 + p 0111010 4
011 p+1 p5 + p2 + p + 1 0100111 4
100 p 2 p6 + p5 + p4 + p3 1111000 4
101 2
p +1 p6 + p5 + p3 + 1 1101001 4
110 2
p +p p6 + p3 + p2 + p 1001110 4
111 2
p + p+1 p6 + p4 + p + 1 1010011 4
Note: XOR addition is used here, e.g.
(p2 + 1)(p4 + p3 + p2 + 1) = p6 + p5 + p4 + p2 + p4 + p3 + p2 + 1
= p6 + p5 + (1 + 1)p4 + p3 + (1 + 1)p2 + 1
= p6 + p5 + (0)p4 + p3 + (0)p2 + 1
= p6 + p5 + p3 + 1
(b)
dmin = 4.
Problem Set #8 page 12
ANU ENGN 3226
Q5: Partial Solution
(a)
See Lecture 19, Slide 18 for solution.
(b)
dmin = 3.
(c)
Given that →
−
c = 1 1 1 1 .
Given that the generator polynomial for a (7,4) cyclic code is
g(p) = p3 + p2 + 1
The systematic output code word is
pn−k = p3
M(p) = p3 + p2 + p + 1
pn−k M(p) = (p3 )(p3 + p2 + p + 1) = p6 + p5 + p4 + p3
pn−k M(p) p6 + p5 + p4 + p3
=
g(p) p3 + p2 + 1
p2 + p + 1
= p3 + p + 1 +
p3 + p2 + 1
b(p) = p2 + p + 1
c(p) = pn−k M(p) + b(p)
= p6 + p5 + p4 + p3 + p2 + p + 1
→
−
c =
1 1 1 1 1 1 1
See Lecture 19, Example 3 for detailed steps.
Problem Set #8 page 13