27
Codes Codes are used for the following purposes: - to detect errors - to correct errors after detection Error Control Coding © Erhan A. Ince Types: - Linear Block Codes - Cyclic Codes - Convolutional Codes - BCH Codes - Reed Solomone (RS) codes

Codes Codes are used for the following purposes: - to detect errors - to correct errors after detection Error Control Coding © Erhan A. Ince Types: -Linear

Embed Size (px)

Citation preview

Page 1: Codes Codes are used for the following purposes: - to detect errors - to correct errors after detection Error Control Coding © Erhan A. Ince Types: -Linear

Codes Codes are used for the following purposes:

- to detect errors

- to correct errors after detection

Error Control Coding © Erhan A. Ince

Types:

- Linear Block Codes

- Cyclic Codes

- Convolutional Codes

- BCH Codes

- Reed Solomone (RS) codes

Page 2: Codes Codes are used for the following purposes: - to detect errors - to correct errors after detection Error Control Coding © Erhan A. Ince Types: -Linear

Block Error Control Codes

A block error control code C consists of a set of M code

words {c0,c1,c2,……,cM-1). Each code word is of the form

c = (c0,c1,…….,cn-1).

If the values are taken from the Galois field GF(q) then the code is said to be q-ary

Error Control Coding © Erhan A. Ince

Page 3: Codes Codes are used for the following purposes: - to detect errors - to correct errors after detection Error Control Coding © Erhan A. Ince Types: -Linear

Uncoded Data Stream

Encoding Process1. Breaking up the data stream into blocks

2. Mapping these blocks onto code words in C

Error Control Coding © Erhan A. Ince

Block Encoder

Coded Data Stream

k-symbol block

n-symbol block

Page 4: Codes Codes are used for the following purposes: - to detect errors - to correct errors after detection Error Control Coding © Erhan A. Ince Types: -Linear

Encoding process…If M = qk then the encoder breaks the data stream into k-

symbol blocks.

If M is not in the above form the encoder must work on messages of varying length.

Message Blocks Code Words

(000) (00000000000)

(001) (10100011101)

(010) (11010001110)

(011)

(100)

(101)

(1100)

(1101)

(11100)

(11101)

(11110) (10001110110)

(11111) (01000111011) Error Control Coding © Erhan A. Ince

Ex:Binary Hadmard Code A12

Consists of 12 code wordsof length 11. The informationBlocks must be of varying length

Page 5: Codes Codes are used for the following purposes: - to detect errors - to correct errors after detection Error Control Coding © Erhan A. Ince Types: -Linear

Error Control Coding © Erhan A. Ince

Since # of valid code words < # of possible n-symbol blocks

redundancy = r = n – logq M

There are (qn-M) n-symbol patterns which are not associated

with data blocks and thus are not valid code words. The code C is said to contain redundancy.

If M = qk , then r simplifies to the difference

r = ( n - k )

Page 6: Codes Codes are used for the following purposes: - to detect errors - to correct errors after detection Error Control Coding © Erhan A. Ince Types: -Linear

Rate of a Block Code If M represents the number of code words each of

length

n in a code C

The rate of C is :

For M =qk then

Error Control Coding © Erhan A. Ince

n

MR 2

log

nkR

Page 7: Codes Codes are used for the following purposes: - to detect errors - to correct errors after detection Error Control Coding © Erhan A. Ince Types: -Linear

If the received word is found to be invalid, then receiver assumes that channel has caused multiple symbol errors.

The determination of whether errors are present is ERROR DETECTION

An error pattern is undetectable if it causes the received word to be a valid code other than the one transmitted.

Given a transmitted code word c there are (M-1) code words other than c hence (M-1) undetectable error patterns.

Error Control Coding © Erhan A. Ince

c =(c0 ,c1,…..cn-1)Transmitted Codeword

e =(e0 ,e1,…..en-1)Error pattern

r =(r0 ,r1,…..rn-1)Received Codeword

Comm Channel

Page 8: Codes Codes are used for the following purposes: - to detect errors - to correct errors after detection Error Control Coding © Erhan A. Ince Types: -Linear

The decoder may react in a number of ways

Error Control Coding © Erhan A. Ince

Request a retransmission of the word (ARQ) (automatic repeat request)

Tag the word as being incorrect and pass it along the datasink (muting )

Attempt to correct the errors in the received word

Final option is referred to as : FORWARD ERROR CORRECTION (FEC)

Page 9: Codes Codes are used for the following purposes: - to detect errors - to correct errors after detection Error Control Coding © Erhan A. Ince Types: -Linear

Code Weight

The weight of a code word or error pattern is the number of

nonzero coordinates in the code word or error pattern.

Weight of a codeword is generally shown as w(c)

Example:

w(1,0,0,1,1,0,1,1,1,1) = 7

w(3,29,0,0,1, 6,0) = 4

Error Control Coding © Erhan A. Ince

Page 10: Codes Codes are used for the following purposes: - to detect errors - to correct errors after detection Error Control Coding © Erhan A. Ince Types: -Linear

Distance between codesAssume we have a pair of n-symbol blocks:

v = (v0,v1,……, vn-1)

w=(w0,w1,……,wn-1)

We can discuss the distance , d(v,w), between these two blocks in a number of ways:

If we talk about Euclidean distance

Euclidean distance is used extensively in the analysis of convolutional and trellis codes

Error Control Coding © Erhan A. Ince

2

11....

2

11

2

00,

n

wn

vwvwvwvEuclidean

d

Page 11: Codes Codes are used for the following purposes: - to detect errors - to correct errors after detection Error Control Coding © Erhan A. Ince Types: -Linear

Distance of codes … With block codes we talk more of the time about

Hamming Distance.

This is the number of coordinates in which the two blocks

differ:

Error Control Coding © Erhan A. Ince

1,.....,2,1,0,|min

niiwividgHam

d wv,wv,

Page 12: Codes Codes are used for the following purposes: - to detect errors - to correct errors after detection Error Control Coding © Erhan A. Ince Types: -Linear

Minimum DistanceThe minimum distance of a block code C is the minimum

Hamming distance between all distinct pairs of code words

in C. This minimum distance is denoted as dmin .

A transmitted codeword is guaranteed to differ in at least dmin coordinates from any other code word.

For an error pattern to be undetectable it must change the symbol values in the transmitted code word in at least dmin coordinates.

A code with minimum distance dmin can detect all error

patterns of weight less than or equal to (dmin –1)

Error Control Coding © Erhan A. Ince

Page 13: Codes Codes are used for the following purposes: - to detect errors - to correct errors after detection Error Control Coding © Erhan A. Ince Types: -Linear

In FEC systems goal is to minimize the probability of decoder

error given a received word r.

The maximum a posteriori decoder identifies the code word ci that maximize :

p(c=ci | r)

p(c| r) is the probability that code word c is transmitted on receipt of code word r.

The maximum likelihood decoder (ML) identifies the code word ci that maximizes: p(r| c=ci ) . p(c|r)

Two expressions can be related by Baye’s ruleError Control Coding © Erhan A. Ince

r

crcrc

Rp

pcpp

||

Page 14: Codes Codes are used for the following purposes: - to detect errors - to correct errors after detection Error Control Coding © Erhan A. Ince Types: -Linear

The conditional probability p(r|c) is equal to the probability of

occurrence of the error pattern e= (r - c) given that c has been

transmitted

since lower-weight error patterns are more likely to occur than the higher weight ones

The codeword ci that maximizes p(r|ci) is the codeword that

minimize the d(r,ci)=w(r-c)

The maximum likelihood transmitted codeword is thus the code word that is closest in Hamming distance to the received word r.

Error Control Coding © Erhan A. Ince

Page 15: Codes Codes are used for the following purposes: - to detect errors - to correct errors after detection Error Control Coding © Erhan A. Ince Types: -Linear

A decoder error occurs when the received word is closer to an

incorrect code word than to the correct code word.

By definition incorrect code words are at least dmin away from

the transmitted code word

Therefore decoder errors are possible only if the weight of the

error pattern induced by the channel is greater than or equal to

dmin /2

A code with minimum distance dmin can correct all error

patterns of weight less than or equal to (dmin –1) /2

Error Control Coding © Erhan A. Ince

Page 16: Codes Codes are used for the following purposes: - to detect errors - to correct errors after detection Error Control Coding © Erhan A. Ince Types: -Linear

Error Control Coding © Erhan A. Ince

Consider a block code U

consisting of n-tuples {V1,V2,……Vn-1}of symbols

from FG(q). U is a q-ary linear code if and only if U forms a vector subspace over GF(q)

FG(q) is a Galois Field

DEFINITION

Page 17: Codes Codes are used for the following purposes: - to detect errors - to correct errors after detection Error Control Coding © Erhan A. Ince Types: -Linear

Linear Block Codes- are a class of parity check codes that can be characterized by the

(n,k) notation

- The encoder transforms a block of k message digits into a longer

block code of n codeword digits (a code vector)

- If the alphabet consists of two elements (0 and 1) the code is a

binary code

- k-bit messages form 2k distinct message sequences referred to as

the k-tuples.

- the n-bit blocks can form as many as 2n distinct sequences known

as n-tuples.

Error Control Coding © Erhan A. Ince

Page 18: Codes Codes are used for the following purposes: - to detect errors - to correct errors after detection Error Control Coding © Erhan A. Ince Types: -Linear

The encoding process assigns to each of the 2k message k-tuples

one of the 2n n-tuples.

The mapping is accomplished by a look-up table.

For linear codes the mapping transformation is of course linear

VECTOR SPACES

The set of all binary n-tuples, Vn, is called a vector space over the binary field of two elements (0 and 1).

A binary field has two operations, addition and multiplication such that the results of all operations are in the same set of two elements.

The arithmetic operations of addition and multiplication are defined by the conventions of the algebraic field.

Error Control Coding © Erhan A. Ince

Page 19: Codes Codes are used for the following purposes: - to detect errors - to correct errors after detection Error Control Coding © Erhan A. Ince Types: -Linear

In a binary field the rules are:

Error Control Coding © Erhan A. Ince

0 1

0

1

0 1

1 0

0 1

0

1

0 0

0 1

VECTOR SUBSPACES

A subset S of the vector space Vn is called the subspace if the following two conditions are satisfied:

1. The all-zero vector is in S

2. The sum of any two vectors in S is also in S

(known as closure property)

Page 20: Codes Codes are used for the following purposes: - to detect errors - to correct errors after detection Error Control Coding © Erhan A. Ince Types: -Linear

Error Control Coding © Erhan A. Ince

2k n-tuplesConstitude subspace of code words

2n n-tuplesEntire space Vn

Page 21: Codes Codes are used for the following purposes: - to detect errors - to correct errors after detection Error Control Coding © Erhan A. Ince Types: -Linear

Linear Code If Vi and Vj are two code words in an (n,k) binary block

code the

code is said to be linear only if (Vi Vj ) is also a code vector.

Vectors outside the subspace can not be created

by the addition of legitimate code vectors (members

of the subspace)

Example: vector space V4 is populated by the following 24 4-tuples

0000 0001 0010 0011 0100 0101 0110 0111

1000 1001 1010 1011 1100 1101 1110 1111

Error Control Coding © Erhan A. Ince

Page 22: Codes Codes are used for the following purposes: - to detect errors - to correct errors after detection Error Control Coding © Erhan A. Ince Types: -Linear

Example ofa subset of V4 is :

0000 0101 1010 1111

0000 1010

0101 1111

0101 0101

A set of 2k n-tuples is called a linear block code if and only if it is a subspace of the vector space Vn of all n-tuples.

Error Control Coding © Erhan A. Ince

Page 23: Codes Codes are used for the following purposes: - to detect errors - to correct errors after detection Error Control Coding © Erhan A. Ince Types: -Linear

Example: Assume that we have a (6,3) code There are 2k = 23 = 8 message vectors there are 2n = 26 = 64 6-tuples in the V6 vector space

message vector code vector

000 000000

100 110100

010 011010

110 101110

001 101001

101 011101

011 110011

111 000111

It is easy to check that the eight code vectors form a subspace of V6 (all-zeros vector is present and the sum of any two code words yields an other one which is a member of the subspace.

Error Control Coding © Erhan A. Ince

Page 24: Codes Codes are used for the following purposes: - to detect errors - to correct errors after detection Error Control Coding © Erhan A. Ince Types: -Linear

Generator Matrix If for an (n,k) code k is large a table look-up implementation is not

feasible.

i.e for (127,92) code there are 292 or approximately 5x2027 code

vectors. Table-lookup brings the need for a large amount of

memory Fortunately it is possible to only generate code vectors as they are required.

Since a set of code vectors that form a linear block code is a

k-dimensional subspace of the n-dimensional binary vector space

(k<n), it is always possible to find a set of n-tuples, fewer than 2k, that

can generate all the 2k vectors in the subspace. The generating set of

vectors is said to span the subspace. Error Control Coding © Erhan A. Ince

Page 25: Codes Codes are used for the following purposes: - to detect errors - to correct errors after detection Error Control Coding © Erhan A. Ince Types: -Linear

Smallest linearly independent set that spans the subspace is called a

basis of the subspace.

number of vectors in this basis set is the dimension of the subspace.

Any basis set of the k linearly independent n-tuples V1, V2, ….., Vk

can be used to generate the required linear block code vectors since

each code word is a linear combination of V1, V2, ….., Vk

That is each of the set of 2k code vectors U can be described as:

U = m1V1 + m2V2 + ………+ mkVk

where mi = ( 0 or 1) and i= 1,……,kError Control Coding © Erhan A. Ince

Page 26: Codes Codes are used for the following purposes: - to detect errors - to correct errors after detection Error Control Coding © Erhan A. Ince Types: -Linear

Generator matrix….In general we can define a generator matrix as a (k n) array:

The message m is shown as a row vector with (1 k) dimensions :

The generation of the code vector U is denoted as:

U=mG

Error Control Coding © Erhan A. Ince

knV

kV

kV

nVVV

nVVV

k

21

22221

11211

2

V

VG

1V

kmmm ,,

2,

1m

Page 27: Codes Codes are used for the following purposes: - to detect errors - to correct errors after detection Error Control Coding © Erhan A. Ince Types: -Linear

Ex: Assume a generator matrix as below:

Where V1,V2 and V3 are the three linearly independent vectors ( a subset of the eight code vectors ) that can generate all code vectors.

Assuming message vector is ( 1 1 0) we can use G to generate the code vector for this message:

= 1 1 0 1 0 0 + 0 1 1 0 1 0 + 0 0 0 0 0 0

= 1 0 1 1 1 0 ( code vector for message 110)

* Linear combination of the rows of G Error Control Coding © Erhan A. Ince

100101

010110

001011

3

2

1

V

V

V

G

3

02

11

1

3

2

1011 VVV

V

V

V

U