using the matlab communications toolbox to look at cyclic coding wm. hugh blanton east tennessee...

Post on 11-Jan-2016

216 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

USING THE MATLAB USING THE MATLAB COMMUNICATIONS TOOLBOXCOMMUNICATIONS TOOLBOXTO LOOK AT CYCLIC CODINGTO LOOK AT CYCLIC CODING

Wm. Hugh BlantonWm. Hugh Blanton

East Tennessee State East Tennessee State UniversityUniversity

http://faculty.etsu.edu/blantonhttp://faculty.etsu.edu/blanton

The TheoryThe Theory

General ConceptsGeneral Concepts

Channel CodingChannel Coding

Designed to improve Designed to improve communications performance by communications performance by enabling the transmitted signals enabling the transmitted signals to better withstand the effects of to better withstand the effects of various channel impairments, various channel impairments, such as noise, interference, and such as noise, interference, and fading.fading.

Hamming DistanceHamming Distance

000 100

110

101

001

010

011

111

The number of bit positions in which two binary words differ.

This figure has a minimum distance between code words of 1.

Hamming Distance of 2Hamming Distance of 2

0000

r = 1

0011

0110

A code word that differs by a Hamming distance of 2 will detect an erroneous code word.

0001 0111

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 code word will be closer to one of the correct code words.

The error is corrected by assigning the received code word to the nearest (in Hamming distance) valid code word.

The important concepts The important concepts associated with associated with Hamming Hamming distance are:distance are:

1.1. When the When the Hamming distanceHamming distance is 1, it is 1, it is impossible to detect an error, is impossible to detect an error, much less correct the error. much less correct the error.

2.2. When the When the Hamming distanceHamming distance is 2, is 2, the error can be detected, but not the error can be detected, but not corrected.corrected.

3.3. When the When the Hamming distanceHamming distance is 3, a is 3, a single error can be detected and single error can be detected and corrected.corrected.

More TheoryMore Theory

Mathematical ConceptsMathematical Concepts

LINEAR BLOCK CODESLINEAR BLOCK CODES

DefinitionDefinition– A systematic A systematic (n,k)(n,k) linear block linear block

code is a mapping from a code is a mapping from a k-k-dimensional message vector to dimensional message vector to an an n-n-dimensional codeword in dimensional codeword in such a way that part of the such a way that part of the sequence generated coincides sequence generated coincides with the with the k k message digits. message digits.

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 everyone uses is the (7,4) code.

k-dimensional information vector, where k = 4.

n-dimensional information vector, where n = 7.

Generator MatrixGenerator Matrix

How do you generate a How do you generate a (7,4)(7,4) code?code?– Of course with a Generator Matrix!Of course with a Generator Matrix!

1...00...

......

0...10...

0...01...

21

22121

11211

nmnn

m

m

k

ppp

ppp

ppp

IPG

Note that m = n - k, the difference

A A (7,4)(7,4) code is generated by the code is generated by the matrixmatrix

1000101

0100111

0010110

0001011

G

The The (7,4) (7,4) block code is generated block code is generated using the matrix equationusing the matrix equation

– wherewhere1.1. u u is a is a [1 × k] [1 × k] vector representing the vector representing the

information wordinformation word

2.2. v v is ais a [1 × n] [1 × n] vector representing the vector representing the code wordcode word

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

][Guv ][Guv

][Guv

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

1000101

0100111

0010110

0001011

1000][Guv

1000101v

Transformation from 4-bit

information word to 7-bit code

word Note that the additions are modulo-2 additions

The The Hamming distanceHamming distance for the for the (7,4) (7,4) code is 3. code is 3. – Thus, this code can detect double bit Thus, this code can detect double bit

errors and correct single bit errors errors and correct single bit errors

Parity Check MatrixParity Check Matrix

Another important matrix Another important matrix associated with block codes is the associated with block codes is the parity check matrixparity check matrix, , [H][H]. .

The parity check matrix is formed The parity check matrix is formed by starting with the identity by starting with the identity matrix and appending the matrix and appending the transpose of the transpose of the nonidentitynonidentity portion of portion of [G][G]::

nmmm

n

n

Tk

ppp

ppp

ppp

PIH

...1...00

......

...0...10

...0...01

21

22212

12111

For the For the (7,4)(7,4) block code, block code,

1110100

0111010

1101001

H

The SyndromeThe Syndrome

The parity check matrix has the The parity check matrix has the propertyproperty

v[H] v[H] TT = 0 = 0

That is, any errorless, received code That is, any errorless, received code word multiplied by the transpose of the word multiplied by the transpose of the parity check matrix, [H], yields a zero parity check matrix, [H], yields a zero vector, or vector, or syndromesyndrome. . – If the received code word contains an error, If the received code word contains an error,

the resulting vector will match the the resulting vector will match the corresponding bit that caused the error. corresponding bit that caused the error.

Consider one of the valid code Consider one of the valid code words of the words of the (7,4)(7,4) block code, block code, v = v = 11001011100101 and the transpose of the and the transpose of the (7,4)(7,4) parity check matrix. parity check matrix.

101

111

110

011

100

010

001

1010011THv

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

01010000

101

111

110

011

100

010

001

1010011

000

101

111

110

011

100

010

001

1010011

THv

Syndrome

The null vector indicates no error.

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

101

111

110

011

100

010

001

1010001THv

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

01010000

101

111

110

011

100

010

001

1010001

010

101

111

110

011

100

010

001

1010001

THv

Syndrome

Match syndrome with corresponding code in parity check matrix

The second row corresponds to the second bit from left.

Each row in the transposed parity Each row in the transposed parity check matrix corresponds to a bit check matrix corresponds to a bit in the code word. in the code word. – By matching the non-zero syndrome By matching the non-zero syndrome

with the contents contained in the with the contents contained in the rows of the transposed parity rows of the transposed parity matrix, the corresponding corrupted matrix, the corresponding corrupted bit can be detected and and bit can be detected and and subsequently corrected. subsequently corrected.

The process will convert the The process will convert the erroneous code erroneous code 11000010100101 to the to the correct code correct code 11110010100101..

Cyclic CodesCyclic Codes

CYCLIC CODESCYCLIC CODES

The implementation of linear block The implementation of linear block codes requires circuits capable of codes requires circuits capable of performing matrix multiplication performing matrix multiplication and of comparing the result of and of comparing the result of various binary numbers. various binary numbers. – Although integrated circuits have Although integrated circuits have

been developed to implement the been developed to implement the most common codes, the circuitry can most common codes, the circuitry can become quite complex for very long become quite complex for very long blocks of code. blocks of code.

A special case of the block code, A special case of the block code, the cthe cyclic codeyclic code can be can be electronically implemented electronically implemented relatively easilyrelatively easily. .

A A (7,4)(7,4) cyclic code cyclic code generating matrixgenerating matrix

1011000

0101100

0010110

0001011

G

A A (7,4)(7,4) cyclic code cyclic code generating matrixgenerating matrix

1011000

0101100

0010110

0001011

G

Non-systematic—No Identity matrix.

A nonsystematic A nonsystematic (7,4)(7,4) cyclic code cyclic code generating matrix is made generating matrix is made systematic by performing row, systematic by performing row, column operations until you obtain column operations until you obtain the Ithe Ikk partition. partition.

1000101

0100111

0010110

0001011

sysG

MATLAB MATLAB COMMUNICATIONS COMMUNICATIONS TOOLBOX DERIVATIONTOOLBOX DERIVATION

MATLAB MATLAB COMMUNICATIONS COMMUNICATIONS TOOLBOX DERIVATION TOOLBOX DERIVATION Although row,column matrix Although row,column matrix

manipulation is a straightforward manipulation is a straightforward process for students that have process for students that have taken a linear algebra course, taken a linear algebra course, many engineering technology many engineering technology students are not familiar with the students are not familiar with the process.process.

Although, the discussion of linear Although, the discussion of linear block codes is not mathematically block codes is not mathematically complicated, it is mathematically complicated, it is mathematically tortuous with many mathematical tortuous with many mathematical turns. turns.

Finally, the discussion for the Finally, the discussion for the (7,4) (7,4) cyclic code is relatively cyclic code is relatively benign with a manageable benign with a manageable number of calculations.number of calculations.

For larger codes, the calculations For larger codes, the calculations become overwhelming, especially become overwhelming, especially for the engineering technology for the engineering technology student. student.

In order to In order to – better manage larger codes, better manage larger codes, – relieve the mathematical stress on relieve the mathematical stress on

engineering technology students, and engineering technology students, and – focus on the application of block codes focus on the application of block codes

rather than the mathematics; rather than the mathematics; the MATLAB Communications Toolbox the MATLAB Communications Toolbox

provides a set of cyclic code provides a set of cyclic code functions.functions.

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

875431 xxxxxx

110111011

that corresponds to the code

word

1 x1 x2 x3 x4 x5 x6 x8x7

The nonsystematic cyclic code The nonsystematic cyclic code generating matrix, generating matrix, GG, is:, is:

110111011000000

011011101100000

001101110110000

000110111011000

000011011101100

000001101110110

000000110111011

G

And the systematic cyclic code And the systematic cyclic code

generating matrix isgenerating matrix is

100000011011101

010000010110011

001000010000100

000100001000010

000010000100001

000001011001101

000000110111011

sysG

By using the function By using the function cyclpolycyclpoly, MATLAB , MATLAB yields a set of all generating polynomialsyields a set of all generating polynomials

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

p =p =

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

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

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

875431 xxxxxx

By using the function By using the function cyclgencyclgen, the , the nonsystematic generating matrix, nonsystematic generating matrix, genmatgenmat, , is derived as follows:is derived as follows:

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

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

genmat =genmat = Columns 1 through 13 Columns 1 through 13 1 1 0 1 1 1 0 1 1 0 0 0 01 1 0 1 1 1 0 1 1 0 0 0 0 0 1 1 0 1 1 1 0 1 1 0 0 00 1 1 0 1 1 1 0 1 1 0 0 0 0 0 1 1 0 1 1 1 0 1 1 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 1 1 0 1 1 1 0 1 1 0 0 0 0 0 1 1 0 1 1 1 0 1 10 0 0 0 1 1 0 1 1 1 0 1 1 0 0 0 0 0 1 1 0 1 1 1 0 10 0 0 0 0 1 1 0 1 1 1 0 1 0 0 0 0 0 0 1 1 0 1 1 1 00 0 0 0 0 0 1 1 0 1 1 1 0

Columns 14 through 15 Columns 14 through 15 0 00 0 0 00 0 0 00 0 0 00 0 0 00 0 1 01 0

110111011000000

011011101100000

001101110110000

000110111011000

000011011101100

000001101110110

000000110111011

genmat

which iswhich is

in matrix form.in matrix form.

110111011000000

011011101100000

001101110110000

000110111011000

000011011101100

000001101110110

000000110111011

genmat

110111011000000

011011101100000

001101110110000

000110111011000

000011011101100

000001101110110

000000110111011

G

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];>> genpoly=[1 1 0 1 1 1 0 1 1];>>[parmat,genmat]=cyclgen(15,genpoly)>>[parmat,genmat]=cyclgen(15,genpoly)

genmatsys =

Columns 1 through 12 1 1 0 1 1 1 0 1 1 0 0 0 1 0 1 1 0 0 1 1 0 1 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 1 0 0 0 0 1 0 0 0 0 1 1 0 0 1 1 0 1 0 0 0 0 1 0 1 1 1 0 1 1 0 0 0 0 Columns 13 through 15 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1

which iswhich is

in matrix form.in matrix form.

100000011011101

010000010110011

001000010000100

000100001000010

000010000100001

000001011001101

000000110111011

genmatsys

The The (15,7)(15,7) code produces 32,768 code produces 32,768 (215) possible code words of (215) possible code words of which 128 (27) are valid code which 128 (27) are valid code words. words.

– Needless to say, picking the right Needless to say, picking the right

128 valid codes out of 32,768 128 valid codes out of 32,768 possibilities is a frightening task. possibilities is a frightening task.

The Communications Toolbox provides The Communications Toolbox provides an an encodeencode function that alleviates much function that alleviates much of this mathematical anxiety.of this mathematical anxiety.

>> data=(0:127);>> data=(0:127);

>> c=de2bi(data,'left-msb');>> c=de2bi(data,'left-msb');

>> >> valid_code=encode(c,15,7,'cyclic',genpovalid_code=encode(c,15,7,'cyclic',genpoly)ly)

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 1 1 1 0 0 1 1 0 1 0 0 0 0 0 1 0 0 1 1 1 0 1 1 0 0 0 0 0 0 1 1 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0

information code

ConclusionConclusion

The MATLAB Communications The MATLAB Communications Toolbox derives the same Toolbox derives the same generating matrices that are generating matrices that are derived by mathematical derived by mathematical manipulation. manipulation. – The underlying result is that the The underlying result is that the

electronic engineering technology electronic engineering technology student can apply more effort in student can apply more effort in understanding the theory rather than understanding the theory rather than the mathematics, especially when the mathematics, especially when considering more complex problems.considering more complex problems.

By reducing the mathematical By reducing the mathematical anxiety, students can concentrate anxiety, students can concentrate more attentively on the actual more attentively on the actual nuances of block coding, and the nuances of block coding, and the instructor can move from instructor can move from theoretical foundation of cyclic theoretical foundation of cyclic codes to the circuit codes to the circuit implementation of cyclic codes. implementation of cyclic codes.

top related