using the matlab communications toolbox

56
USING THE MATLAB COMMUNICATIONS TOOLBOX TO LOOK AT CYCLIC CODING Wm. Hugh Blanton East Tennessee State University http://faculty.etsu.edu/blanton

Upload: mohammed229

Post on 02-Jun-2018

228 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 1/56

USING THE MATLABCOMMUNICATIONS TOOLBOX

TO LOOK AT CYCLIC CODING

Wm. Hugh Blanton

East Tennessee State Universityhttp://faculty.etsu.edu/blanton

Page 2: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 2/56

The Theory

General Concepts

Page 3: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 3/56

Channel Coding

Designed to improve communicationsperformance by enabling the

transmitted signals to better withstandthe effects of various channelimpairments, such as noise,

interference, and fading. 

Page 4: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 4/56

Hamming Distance 

000 100

110

101

001

010

011

111

The number of bit positions in which two binary wordsdiffer.

This figure has a minimumdistance between code words of1. 

Page 5: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 5/56

Hamming Distance of 2 

0000

r = 1  

0011

0110

 A code word that differs bya Hamming distance  of 2

will detect an erroneouscode word.

0001 0111

Page 6: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 6/56

1

1

1

If the minimum distance is 3, the code words are

separated by at least three edges.

Note that if a single error

occurs, the erroneous codeword will be closer to one of thecorrect code words.

The error is corrected by assigning thereceived code word to the nearest (inHamming distance)  valid code word. 

Page 7: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 7/56

The important concepts associated

with Hamming distance are:1. When the Hamming distance  is 1, it is

impossible to detect an error, much less

correct the error.2. When the Hamming distance  is 2, the

error can be detected, but notcorrected.

3. When the Hamming distance  is 3, asingle error can be detected andcorrected.

Page 8: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 8/56

More Theory

Mathematical Concepts

Page 9: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 9/56

LINEAR BLOCK CODES

Definition

 – A systematic (n,k)  linear block codeis a mapping from a k- dimensionalmessage vector to an n- dimensionalcodeword in such a way that part of

the sequence generated coincideswith the k message digits.

Page 10: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 10/56

Information Code

0000 0000000

0001 1010001

0010 1110010

0011 0100011

0100 0110100

0101 1100101

0110 1000110

0111 0010111

1000 1101000

1001 0111001

1010 0011010

1011 1001011

1100 1011100

1101 0001101

1110 0101110

1111 1111111

The linear block

code that everyoneuses is the (7,4)  code.

k -dimensional

information vector,where k = 4 . 

n -dimensionalinformation vector,where n = 7 . 

Page 11: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 11/56

Generator Matrix

How do you generate a (7,4)  code?

 – Of course with a Generator Matrix!

1...00...

......

0...10...0...01...

21

22121

11211

nmnn

m

m

 p p p

 p p p p p p

 I  P G

Note that m = n - k ,

the difference

Page 12: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 12/56

 A (7,4)  code is generated by thematrix

1000101

01001110010110

0001011

G

][Guv ][Guv

Page 13: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 13/56

The (7,4) block code is generatedusing the matrix equation

 – where

1. u is a [1 × k] vector representing theinformation word

2. v is a [1 × n]  vector representing the codeword

3. [G]   is a [k × n]   generating matrix

][Guv    ][Guv 

][Guv 

Page 14: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 14/56

For the information word (0 0 0 1) ,the code word is computed as follows:

1000101

0100111

0010110

0001011

1000][Guv

1000101v

Transformationfrom 4-bit

information word to7-bit code word

Note that the additionsare modulo-2 additions

Page 15: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 15/56

The Hamming distance  for the (7,4)code is 3.

 –Thus, this code can detect double biterrors and correct single bit errors

Page 16: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 16/56

Parity Check Matrix

 Another important matrix associatedwith block codes is the parity check

matrix , [H] .

Page 17: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 17/56

The parity check matrix is formed bystarting with the identity matrix and

appending the transpose of thenonidentity  portion of [G] :

nmmm

n

n

 p p p

 p p p

 p p p

 P  I  H 

...1...00

......

...0...10

...0...01

21

22212

12111

Page 18: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 18/56

For the (7,4)  block code,

1110100

0111010

1101001

 H 

Page 19: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 19/56

The Syndrome

The parity check matrix has the property

v[H] T  = 0

That is, any errorless, received code wordmultiplied by the transpose of the parity

check matrix, [H], yields a zero vector, orsyndrome . – If the received code word contains an error, the

resulting vector will match the corresponding bitthat caused the error.

C d f h l d d d

Page 20: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 20/56

Consider one of the valid code wordsof the (7,4)  block code, v = 1100101  and the transpose of the (7,4)  parity

check matrix.

101

111

110

011

100010

001

1010011T 

 H v

Page 21: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 21/56

  01000001

101

111

110

011

100

010

001

1010011  

Modulo-2 Addition

  00010010

101

111

110

011

100

010

001

1010011  

011

110

101

000

001

Page 22: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 22/56

  01010000

101

111

110

011

100

010

001

1010011  

000

101

111

110

011100

010

001

1010011  

 H v

Syndrome

The null vector

indicates no error. 

Page 23: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 23/56

Suppose the valid code words, v =1100101  gets corrupted to 1000101 .

101

111110

011

100010

001

1010001T  H v

001

Page 24: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 24/56

  01000001

101

111

110

011

100

010

001

1010001  

Modulo-2 Addition

  10010000

101

111

110

011

100

010

001

1010001  

011

110

101

000

001

Page 25: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 25/56

  01010000

101

111

110

011

100

010

001

1010001  

010

101

111

110

011100

010

001

1010001  

 H v

Syndrome

Match syndrome  withcorresponding code in

parity check matrix  

The second rowcorresponds to thesecond bit from left.

Page 26: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 26/56

Each row in the transposed paritycheck matrix corresponds to a bit in

the code word. – By matching the non-zero syndrome with

the contents contained in the rows of thetransposed parity matrix, thecorresponding corrupted bit can bedetected and and subsequently corrected.

Page 27: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 27/56

The process will convert the erroneouscode 1000101  to the correct code

1100101 . 

Page 28: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 28/56

Cyclic Codes

Page 29: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 29/56

CYCLIC CODES

The implementation of linear blockcodes requires circuits capable of

performing matrix multiplication and ofcomparing the result of various binarynumbers.

 – Although integrated circuits have beendeveloped to implement the mostcommon codes, the circuitry can becomequite complex for very long blocks of

code.

Page 30: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 30/56

 A special case of the block code, thecyclic code  can be electronically

implemented relatively easily.

Page 31: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 31/56

 A (7,4)  cyclic code generating

matrix

1011000

0101100

0010110

0001011

G

Page 32: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 32/56

 A (7,4)  cyclic code generating

matrix

1011000

0101100

0010110

0001011

G

Non-systematic —No Identity

matrix.

Page 33: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 33/56

 A nonsystematic (7,4)  cyclic codegenerating matrix is made systematic by

performing row, column operations untilyou obtain the Ik  partition.

1000101

0100111

00101100001011

 sysG

Page 34: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 34/56

MATLAB COMMUNICATIONS

TOOLBOX DERIVATION

Page 35: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 35/56

MATLAB COMMUNICATIONSTOOLBOX DERIVATION

 Although row,column matrixmanipulation is a straightforward

process for students that have taken alinear algebra course, manyengineering technology students are

not familiar with the process. 

Page 36: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 36/56

 Although, the discussion of linearblock codes is not mathematically

complicated, it is mathematicallytortuous with many mathematicalturns.

Page 37: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 37/56

Finally, the discussion for the (7,4)cyclic code is relatively benign with a

manageable number of calculations. 

Page 38: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 38/56

For larger codes, the calculationsbecome overwhelming, especially for

the engineering technology student.

Page 39: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 39/56

In order to

 – better manage larger codes,

 –relieve the mathematical stress onengineering technology students, and

 – focus on the application of block codes

rather than the mathematics; the MATLAB Communications Toolbox

provides a set of cyclic code functions.

Consider the problem with a (15 7)

Page 40: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 40/56

Consider the problem with a (15,7)  cyclic code with the following generatorpolynomial. 

875431   x x x x x x  

110111011

thatcorresponds tothe code word

1  x1 x2 x3 x4 x5 x6 x8x7

Page 41: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 41/56

The nonsystematic cyclic codegenerating matrix, G , is:

110111011000000

011011101100000

001101110110000

000110111011000

000011011101100

000001101110110

000000110111011

G

Page 42: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 42/56

 And the systematic cyclic code

generating matrix is 

100000011011101

010000010110011

001000010000100

000100001000010

000010000100001

000001011001101

000000110111011

 sysG

Page 43: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 43/56

By using the function cyclpoly , MATLAByields a set of all generating polynomials

>> p=cyclpoly(15,7,'all')

p =

1 0 0 0 1 0 1 1 11 1 1 0 1 0 0 0 1

1 1 0 1 1 1 0 1 1

875431   x x x x x x

Page 44: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 44/56

By using the function cyclgen , the nonsystematicgenerating matrix, genmat , is derived as follows:

>> genpoly=[1 1 0 1 1 1 0 1 1];

>>[parmat,genmat]=cyclgen(15,genpoly,'nonsys')

genmat =

Page 45: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 45/56

Columns 1 through 131 1 0 1 1 1 0 1 1 0 0 0 00 1 1 0 1 1 1 0 1 1 0 0 00 0 1 1 0 1 1 1 0 1 1 0 0

0 0 0 1 1 0 1 1 1 0 1 1 00 0 0 0 1 1 0 1 1 1 0 1 10 0 0 0 0 1 1 0 1 1 1 0 10 0 0 0 0 0 1 1 0 1 1 1 0

Columns 14 through 150 00 00 00 0

0 01 0

Page 46: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 46/56

110111011000000

011011101100000

001101110110000

000110111011000

000011011101100

000001101110110

000000110111011

 genmat 

which is

in matrix form.

000000110111011

Page 47: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 47/56

110111011000000

011011101100000

001101110110000

000110111011000

000011011101100

000001101110110

000000110111011

 genmat 

110111011000000

011011101100000

001101110110000

000110111011000

000011011101100

000001101110110

000000110111011

G

Page 48: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 48/56

Likewise, the systematic generating matrix,genmatsys , can be computed using cyclgen  

without the conditional parameter (nonsys):

>> genpoly=[1 1 0 1 1 1 0 1 1];>>[parmat,genmat]=cyclgen(15,genpoly)

genmatsys

Page 49: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 49/56

genmatsys =

Columns 1 through 12

1 1 0 1 1 1 0 1 1 0 0 01 0 1 1 0 0 1 1 0 1 0 01 0 0 0 0 1 0 0 0 0 1 00 1 0 0 0 0 1 0 0 0 0 10 0 1 0 0 0 0 1 0 0 0 0

1 1 0 0 1 1 0 1 0 0 0 01 0 1 1 1 0 1 1 0 0 0 0

Columns 13 through 150 0 0

0 0 00 0 00 0 01 0 00 1 00 0 1

Page 50: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 50/56

which is

in matrix form.

100000011011101

010000010110011

001000010000100

000100001000010

000010000100001

000001011001101

000000110111011

 genmatsys

Page 51: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 51/56

The (15,7)  code produces 32,768(215) possible code words of which

128 (27) are valid code words.

 – Needless to say, picking the right 128

valid codes out of 32,768 possibilities is afrightening task.

Page 52: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 52/56

The Communications Toolbox provides anencode  function that alleviates much of this

mathematical anxiety.

>> data=(0:127);

>> c=de2bi(data,'left-msb');>> valid_code=encode(c,15,7,'cyclic',genpoly) 

Page 53: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 53/56

valid_code =0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

1 0 1 1 1 0 1 1 0 0 0 0 0 0 11 1 0 0 1 1 0 1 0 0 0 0 0 1 00 1 1 1 0 1 1 0 0 0 0 0 0 1 10 0 1 0 0 0 0 1 0 0 0 0 1 0 0

information code

Page 54: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 54/56

Conclusion

Page 55: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 55/56

The MATLAB Communications Toolboxderives the same generating matrices

that are derived by mathematicalmanipulation. – The underlying result is that the

electronic engineering technology student

can apply more effort in understandingthe theory rather than the mathematics,especially when considering morecomplex problems.

Page 56: Using the Matlab Communications Toolbox

8/10/2019 Using the Matlab Communications Toolbox

http://slidepdf.com/reader/full/using-the-matlab-communications-toolbox 56/56

By reducing the mathematical anxiety,students can concentrate more

attentively on the actual nuances ofblock coding, and the instructor canmove from theoretical foundation of

cyclic codes to the circuitimplementation of cyclic codes.