You are on page 1of 23

Vietnam National University – University of Engineering and

Technology

Unit 10: Block Codes


Khoa Điện tử - Viễn thông Digital Communications and Coding


Trường Đại học Công nghệ, ĐHQGHN Hanoi, 2017
Truyền thông số và mã hóa
Content

1. Linear Parity – Check codes


2. Cyclic codes
được tiến hành trên từng khối k bit thông tin một, mỗi khối thêm vào n - k bit dư được được từ mã n bit. ký hiệu code (n, k)

Việc thêm bit vào thì làm số lượng tổ hợp bit tăng lên, các sao cách xa nhau ra, làm giảm lỗi

Khoa Điện tử - Viễn thông Digital Communications and Coding


Trường Đại học Công nghệ, ĐHQGHN 2 Truyền thông số và mã hóa
Some definitions
 Linear If 𝐦1 → 𝐜1 and 𝐦2 → 𝐜2 then 𝐦1 ⊕ 𝐦2 → 𝐜1 ⊕ 𝐜2
 m is a k-bits information sequence
 c is an n-bits codeword
 ⊕ is a bit-by-bit mod-2 addition without carry
 Linear code:
The sum of any two codewords is a codeword.

 Systematic codes
 Note:
 The all-zero sequence is a codeword in every block code
 Any linear block code can be put in a systematic form

Khoa Điện tử - Viễn thông Digital Communications and Coding


Trường Đại học Công nghệ, ĐHQGHN 3 Truyền thông số và mã hóa
Linear Parity-Check Codes
 The parity bits are linear combination of the message
 In an (𝑛, 𝑘) block codes
𝐜 = 𝑐1 𝑐2 ⋯ 𝑐𝑛 ; 𝐝 = 𝑑1 𝑑2 ⋯ 𝑑𝑘
0 ⊕ 0 = 1 ⊕ 1 = 0; 0⊕1=1 ⊕0=1
𝑐1 = 𝑑1
𝑐2 = 𝑑2

𝑐𝑘+1 = 𝑝11 𝑑1 ⊕ 𝑝12 𝑑2 ⊕ ⋯ ⊕ 𝑝1𝑘 𝑑𝑘
𝑐𝑘+2 = 𝑝21 𝑑1 ⊕ 𝑝22 𝑑2 ⊕ ⋯ ⊕ 𝑝2𝑘 𝑑𝑘

𝑐𝑘+𝑚 = 𝑝𝑚1 𝑑1 ⊕ 𝑝𝑚2 𝑑2 ⊕ ⋯ ⊕ 𝑝𝑚𝑘 𝑑𝑘
Here: m=n-k
1 0 … 0 𝑝11 … 𝑝𝑚1
𝐜 = 𝐝𝐺 = 𝑑1 𝑑2 ⋯ 𝑑𝑘 0 1 … 0 𝑝12 … 𝑝𝑚2
… … … … … … …
0 0 … 1 𝑝1𝑘 … 𝑝𝑚𝑘
where 𝐺 = 𝐼𝑘 𝑃𝑇

Khoa Điện tử - Viễn thông Digital Communications and Coding


Trường Đại học Công nghệ, ĐHQGHN 4 Truyền thông số và mã hóa
Syndrome decoding
𝑃𝑇
 Parity-Check Matrix 𝐻= 𝑃 𝐼𝑚 → 𝐻𝑇 = ,
𝐼𝑚
𝑝11 𝑝12 … 𝑝1𝑘
𝑝22 …
𝑃 = 𝑝…
21
… …
𝑝2𝑘

𝑝𝑚1 𝑝𝑚2 … 𝑝𝑚𝑘
𝑃𝑇
𝐺𝐻𝑇 = 𝐼𝑘 𝑃𝑇 = 𝑃𝑇 ⊕ 𝑃𝑇 = 0; 𝐜𝐻𝑇 = 𝐝𝐺𝐻 𝑇 = 0
𝐼𝑚
 Syndrome decoding
𝐫𝐻𝑇 = 𝐜⨁𝐞 𝐻𝑇 = 𝟎⨁𝐞𝐻𝑇 = 𝐬 𝐫 = 𝐜⨁𝐞
 S is called the syndrome of r.
 Note that eHT is i-row of HT we can
identify the error position by comparing
s to the rows of HT

Khoa Điện tử - Viễn thông Digital Communications and Coding


Trường Đại học Công nghệ, ĐHQGHN 5 Truyền thông số và mã hóa
Example: Hamming code (7,4)
 Equations:
𝑐5 = 𝑑1 + +𝑑3 +𝑑4
𝑐6 = 𝑑1 + 𝑑2 +𝑑3
𝑐7 = 𝑑2 +𝑑3 +𝑑4
c=mG

Có bn tổ hợp 7 bit, 2^7 = 128. chỉ có 16 từ mã. => ý nghĩa là đẩy các sao ra xa nhau làm cho lỗi giảm đi
Khoa Điện tử - Viễn thông Digital Communications and Coding
Trường Đại học Công nghệ, ĐHQGHN 6 Truyền thông số và mã hóa
Encoding circuit

Input u
Message register

u11 u22 u33 u44


To Channel

+ + +
v0 v1 v2

Parity resister

Khoa Điện tử - Viễn thông Digital Communications and Coding


Trường Đại học Công nghệ, ĐHQGHN 7 Truyền thông số và mã hóa
Decoding by syndrome
 𝑑𝑚𝑖𝑛 = 3, can correct one bit (𝑑𝑚𝑖𝑛 − 1)/2 = 1
 Assume code 𝐜 = [0010111] is sent
 Received 𝐜 = [0110111] with an error at the second bit.
Calculate: 𝐬 = 𝐜𝐻𝑇 = (𝐜 + 𝐞)𝐻𝑇 = 𝐞𝐻𝑇

1 0 0
0 1 0
0 0 1
𝐬 = 1100010 1 1 0 = 0 0 1
0 1 1
1 1 1
1 0 1
Syndrome like as the second row of HT,
That mean error at the second bit

Khoa Điện tử - Viễn thông Digital Communications and Coding


Trường Đại học Công nghệ, ĐHQGHN 8 Truyền thông số và mã hóa
Decoding by syndrome

 𝐬 is called Syndrome

 From table the coset leader is found to be [0100000].


This indicates that the second bit of the receiver is
erroneous. Thus, adding this error to the received
vector yielding the correct code

 Note: Received vector have 2𝑛 possible values.


Partitioning into 2𝑘 subset. Each subset corresponds to
a codeword.

Khoa Điện tử - Viễn thông Digital Communications and Coding


Trường Đại học Công nghệ, ĐHQGHN 9 Truyền thông số và mã hóa
Decoding Circuit
Received
r0 r1 r2 r3 r4 r5 r6
vector

+ + +

e0 e1 e2 e3 e4 e5 e6

r0 r1 r2 r3 r4 r5 r6
+ + + + + + +

Correcte
doutput

Khoa Điện tử - Viễn thông Digital Communications and Coding


Trường Đại học Công nghệ, ĐHQGHN 10 Truyền thông số và mã hóa
Error probability Khi dùng mã lặp lại lỗi giảm đến 10^-6

khi dùng khã khối có pt kt như trên lỗi giảm đến mức nào

 Block code with 𝑑𝑚𝑖𝑛 possible detect and correct


𝑡 = (𝑑𝑚𝑖𝑛 − 1)/2 error bit XS của m bit lỗi trong khối n bit. với XS 1 bit lỗi sẽ như bên
dưới theo công thức bernouli

 The probability of 𝑚 error in a block of n bits is


𝑃(𝑚, 𝑛) = 𝐶𝑛𝑚 𝑝𝑚 1 − 𝑝 𝑛−𝑚 n
p e   p ( m, n )
GS kỹ thuật phát hiện và hiệu chỉnh được t lỗi
còn nếu có t + 1 đến n lỗi thì ko phát hiện được

Error probability:
thì XS xảy ra là: 1 - P(m,n)
m  t 1
𝑛 p e  C nt 1 p t 1 (1  p )n  t  1

𝑝𝑒 ≤ 𝑃 𝑚, 𝑛
p e  C 72 p 2 (1  p ) 5
𝑚=𝑡+1
 For high signal to noise ratio, i.e small values of 𝑝
𝑝𝑒 ≈ 𝐶𝑛𝑡+1 𝑝𝑡+1 1 − 𝑝 𝑛−𝑡−1
 If p=10-2 in BSC
𝑝𝑒 ≈ 𝐶72 𝑝2 1 − 𝑝 5

Khoa Điện tử - Viễn thông Digital Communications and Coding


Trường Đại học Công nghệ, ĐHQGHN 11 Truyền thông số và mã hóa
Dual code

 Due to 𝐆𝐇𝑇 = 0

 This equation suggests that every (𝑛, 𝑘) linear block


code with generator matrix 𝐆 and parity-check matrix 𝐇
has a dual code with parameters (𝑛, 𝑛 − 𝑘), generator
matrix 𝐇 and parity-check matrix 𝐆.

Khoa Điện tử - Viễn thông Digital Communications and Coding


Trường Đại học Công nghệ, ĐHQGHN 12 Truyền thông số và mã hóa
Revision

 What is the block coding and the meaning of


generator matrix, checking matrix?

 What is Hamming distance and capability of error


correction?

 What is syndrome decoding?

Khoa Điện tử - Viễn thông Digital Communications and Coding


Trường Đại học Công nghệ, ĐHQGHN 13 Truyền thông số và mã hóa
Cyclic Codes
Cyclic code is a subclass of linear block code: It is easy to
implement and efficient to decode.
 Properties: any shift of a cyclic codeword is also a codeword.
From 𝑐𝑛−1 , 𝑐0 , … , 𝑐𝑛−2 can have
𝑐𝑛−1 , 𝑐0 , … , 𝑐𝑛−2 ,
𝑐𝑛−2 , 𝑐𝑛−1 , … , 𝑐𝑛−3 ,

𝑐1 , 𝑐2 , … , 𝑐𝑛−1 , 𝑐0
 To develop the algebraic properties of cyclic codes Codeword,
𝑐0 , 𝑐1 , … , 𝑐𝑛−1 is mapped to code polynomial.

𝑐 𝑋 = 𝑐0 + 𝑐1 𝑋 + ⋯ + 𝑐𝑛−1 𝑋 𝑛−1

(𝑏0 , 𝑏1 , … , 𝑏𝑛−𝑘−1 , 𝑚0 , 𝑚1 , … , 𝑚𝑘−1 )


𝑐 𝑋 = 𝑏 𝑋 + 𝑋 𝑛−𝑘 𝑚 𝑋
𝑛−𝑘 parity bits 𝑘 message bits

Khoa Điện tử - Viễn thông Digital Communications and Coding


Trường Đại học Công nghệ, ĐHQGHN
14 Truyền thông số và mã hóa
More detail
 From
𝑋 𝑖 𝑐 𝑋 = 𝑋 𝑖 𝑐0 + 𝑐1 𝑋 + ⋯ + 𝑐𝑛−𝑖−1 𝑋 𝑛−𝑖−1 + 𝑐𝑛−𝑖 𝑋 𝑛−𝑖 + ⋯ + 𝑐𝑛−1 𝑋 𝑛−1
= 𝑐0 𝑋 𝑖 + 𝑐1 𝑋 𝑖+1 + ⋯ + 𝑐𝑛−𝑖−1 𝑋 𝑛−1 + 𝑐𝑛−𝑖 𝑋 𝑛 + ⋯ + 𝑐𝑛−1 𝑋 𝑛+𝑖−1
= 𝑐𝑛−𝑖 𝑋 𝑛 + ⋯ + 𝑐𝑛−1 𝑋 𝑛+𝑖−1 + 𝑐0 𝑋 𝑖 + 𝑐1 𝑋 𝑖+1 + ⋯ + 𝑐𝑛−𝑖−1 𝑋 𝑛−1
 Due to 𝑐𝑛−𝑖 + 𝑐𝑛−𝑖 = 0
𝑋 𝑖 𝑐 𝑋 = 𝑐𝑛−𝑖 + ⋯ + 𝑐𝑛−1 𝑋 𝑖−1 + 𝑐0 𝑋 𝑖 + 𝑐1 𝑋 𝑖+1 + ⋯ + 𝑐𝑛−𝑖−1 𝑋 𝑛−1
+𝑐𝑛−𝑖 𝑋 𝑛 + 1 + ⋯ + 𝑐𝑛−1 𝑋 𝑖−1 𝑋 𝑛 + 1
 Let: 𝑐 𝑖 𝑋 = 𝑐𝑛−𝑖 + ⋯ + 𝑐𝑛−1 𝑋 𝑖−1 + 𝑐0 𝑋 𝑖 + 𝑐1 𝑋 𝑖+1 + ⋯ +
𝑐𝑛−𝑖−1 𝑋 𝑛−1
𝑞 𝑋 = 𝑐𝑛−𝑖 + 𝑐𝑛−𝑖+1 𝑋 + ⋯ + 𝑐𝑛−1 𝑋 𝑖−1
 We have 𝑋 𝑖 𝑐 𝑋 = 𝑞 𝑋 𝑋 𝑛 + 1 + 𝑐 𝑖 𝑋
 Or 𝑐 𝑖 𝑋 = 𝑋 𝑖 𝑐 𝑋 mod 𝑋 𝑛 + 1
 The multiplication is subject to the constraint 𝑋 𝑛 = 1.

Khoa Điện tử - Viễn thông Digital Communications and Coding


Trường Đại học Công nghệ, ĐHQGHN 15 Truyền thông số và mã hóa
The encoding procedure
 The polynomial 𝑋 𝑛 + 1 and its factors play a major role in the
generation of cyclic codes.
 Let 𝑔(𝑋) is called the generator polynomial of a cyclic code.
𝑐 𝑋 = 𝑎 𝑋 𝑔(𝑋)
If 𝑔(𝑋) is factor of 𝑋 𝑛 + 1 then make 𝑐(𝑋) satisfies
𝑐 𝑖 𝑋 = 𝑋 𝑖 𝑐 𝑋 mod 𝑋 𝑛 + 1
It is reason to choose the generator polynomial of a cyclic code
as factor of 𝑋 𝑛 + 1
(𝑏0 , 𝑏1 , … , 𝑏𝑛−𝑘−1 , 𝑚0 , 𝑚1 , … , 𝑚𝑘−1 )
𝑛−𝑘 parity bits 𝑘 message bits
𝑐 𝑋 =𝑎 𝑋 𝑔 𝑋 =𝑏 𝑋 + 𝑋 𝑛−𝑘 𝑚 𝑋

𝑋 𝑛−𝑘 𝑚(𝑋) 𝑏 𝑋
⇒ =𝑎 𝑋 +
𝑔 𝑋 𝑔 𝑋
 𝑏 𝑋 is the remainder left over after dividing 𝑋 𝑛−𝑘 𝑚 𝑋 by 𝑔(𝑋).

Khoa Điện tử - Viễn thông Digital Communications and Coding


Trường Đại học Công nghệ, ĐHQGHN 16 Truyền thông số và mã hóa
The rule of encoding

1. Multiply the message polynomial 𝑚(𝑋) with 𝑋 𝑛−𝑘 .

2. Divide 𝑋 𝑛−𝑘 𝑚(𝑋) by the generator polynomial 𝑔(𝑋),


obtaining the remainder 𝑏 𝑋 .

3. Add 𝑏(𝑋) to 𝑋 𝑛−𝑘 𝑚(𝑋), obtaining the code polynomial


that is codeword.

Khoa Điện tử - Viễn thông Digital Communications and Coding


Trường Đại học Công nghệ, ĐHQGHN 17 Truyền thông số và mã hóa
Kiểm tra lại kết quả, chú

Hamming code revisited (7,4)


ý: x + x = x(1 + 1) = x . 0
= 0 ( phép cộng module
2)

 Chosen 𝑋 7 + 1 = 1 + 𝑋 1 + 𝑋 2 + 𝑋 3 1 + 𝑋 + 𝑋 3 biểu diễn bản tin thành


đa thức. m = 1001 => m
(x) = 1 + 0.x^1 + 0.x^2 +
 For example message 1001 𝑚 𝑋 = 1 + 𝑋 3 1.x^3 = 1 + x^3

 Encode: Multiplying 𝑚(𝑋) by 𝑋 𝑛−𝑘 = 𝑋 3


 Divide by 𝑔 𝑋 = 1 + 𝑋 + 𝑋 3 ; ℎ 𝑋 = 1 + 𝑋 1 + 𝑋 2 + 𝑋 3 = 1 + 𝑋 +
𝑋2 + 𝑋4 chuyển lại thành bit =
0111001
Tạo thành đa thức chia
hết cho đa thức sinh

𝑋 𝑛−𝑘 𝑚 𝑋 = 𝑋 3 + 𝑋 6
𝑎 𝑋 = 𝑋 + 𝑋3
𝑏 𝑋 = 𝑋 + 𝑋2 1. Biểu diễn bản tin thành đa thức

𝑐 𝑋 = 𝑏 𝑋 + 𝑋 𝑛−𝑘 𝑚 𝑋 2. Chọn thừa số trong phân tích x^


(n-1) là đa thức sinh

= 𝑋 + 𝑋2 + 𝑋3 + 𝑋6 3. lấy x^(n-k).m(x) chia cho đa thức


sinh tìm đa thức dư
𝑋 3 +𝑋 6 𝑋+𝑋 2
 Or 1+𝑋+𝑋 3
= 𝑋 + 𝑋 3 + 1+𝑋+𝑋3 4. lấy x^(n-k)m(x) trừ đa thức dư, sau
đổi lại về bit ta được từ mã

 That Codeword is 0111001. Here 001 are the parity check. The
code word is exactly the same as the Hamming code shown in
Table.

Khoa Điện tử - Viễn thông Digital Communications and Coding


Trường Đại học Công nghệ, ĐHQGHN 18 Truyền thông số và mã hóa
Implementing
1. The gate is switched on, the 𝑘 message bits are shifted into the
channel. The resulting (𝑛 − 𝑘) bit in the register form the parity
bit.
2. The gate is switched off. Thereby breaking the feedback
connections.
3. The contents of the shift register are read out into the channel.
Contents of the shift register in the
Gate
encoder
Shift Input Register Contents

000 (initial state)

1 1 110
Flip-flop Mudulo-2
adder Parity
bits Code
word
Message bits 2 0 011

Figure: Encoder for the (7,4) cyclic code generated by 3 0 111


𝑔 𝑋 = 1 + 𝑋 + 𝑋3.
4 1 011

Khoa Điện tử - Viễn thông Digital Communications and Coding


Trường Đại học Công nghệ, ĐHQGHN 19 Truyền thông số và mã hóa
Parity-Check Polynomial
 The generator pol. 𝑔(𝑋) is equivalent to the generator
mat. G. Corresponding ly ℎ(𝑋) or 𝐻 so 𝐻𝐺𝑇 = 0 we
have
𝑔 𝑋 ℎ 𝑋 mod 𝑋 𝑛 + 1 = 0

 Or 𝑔(𝑋) and ℎ(𝑋) are factors of 𝑋 𝑛 + 1


𝑔 𝑋 ℎ 𝑋 = 𝑋𝑛 + 1

 So in Cyclic code can use 𝑔(𝑋) as check polynomial

Khoa Điện tử - Viễn thông Digital Communications and Coding


Trường Đại học Công nghệ, ĐHQGHN 20 Truyền thông số và mã hóa
Syndrome decoding

 Received word
𝑟 𝑋 = 𝑟0 + 𝑟1 𝑋 + ⋯ + 𝑟𝑛−1 𝑋 𝑛−1

 Divide 𝑟(𝑋) by generator pol. 𝑔 𝑋


𝑟 𝑋 = 𝑞 𝑋 𝑔(𝑋) + 𝑠(𝑋)

 𝑠(𝑋) is a polynomial of degree 𝑛 − 𝑘 − 1 or less.

 The syndrome 𝑠(𝑋) is identical to error 𝑒(𝑋).

 The error correction can be accomplished simply by


adding the syndrome 𝑠(𝑋) to 𝑟(𝑋).

Khoa Điện tử - Viễn thông Digital Communications and Coding


Trường Đại học Công nghệ, ĐHQGHN 21 Truyền thông số và mã hóa
Syndrome Calculator
 The received bits are fed into (𝑛 − 𝑘) stages of the
feedback shift register from the left.
 After all the received bits have been shifted into the
shift register, its contents the syndrome 𝐬.
Gate

Received bits

Modulo-2 Flip-flop
added

Figure: Syndrome calculator for the (7,4) cyclic code generated by


the polynomial 𝑔 𝑋 = 1 + 𝑋 + 𝑋 3 .

 Recovery the code word by adding syndrome 𝐬 with


received word
Khoa Điện tử - Viễn thông Digital Communications and Coding
Trường Đại học Công nghệ, ĐHQGHN 22 Truyền thông số và mã hóa
Revision
 What is the block code and how can it possibility
correct the error bit in a code word?
 How to encode and decode the block code?
 What is the error probability of block coding (𝑛, 𝑘) in
the AWGN channel?

Khoa Điện tử - Viễn thông Digital Communications and Coding


Trường Đại học Công nghệ, ĐHQGHN 23 Truyền thông số và mã hóa

You might also like