Aula 12 - Correção de erros - CCT · The Hamming encoding-decoding procedure is illustrated in...

13
Aula 12 - Correção de erros Prof. Renan Sebem Disciplina de Eletrônica Digital Graduação em Engenharia Elétrica Universidade do Estado de Santa Catarina Joinville-SC – Brasil 5 de abril de 2016 ELD0001 Prof. Renan Sebem Aula 12 1 / 13

Transcript of Aula 12 - Correção de erros - CCT · The Hamming encoding-decoding procedure is illustrated in...

Aula 12 - Correção de erros

Prof. Renan Sebem

Disciplina de Eletrônica DigitalGraduação em Engenharia Elétrica

Universidade do Estado de Santa CatarinaJoinville-SC – Brasil

5 de abril de 2016

ELD0001 ‡ Prof. Renan Sebem ‡ Aula 12 1 / 13

Conteúdo da Aula

Avisos

Resolução da Prova

Código para correção de erros

Bibliografia

ELD0001 ‡ Prof. Renan Sebem ‡ Aula 12 2 / 13

Avisos

Avisos

I Capítulos do livro estão disponíveis para cópia (bloco F)(total R$6,50);

I Conteúdo da segunda prova (17/05):I Códigos de detecção/correção de erro;I Latches;I Flip-flops;I Registradores de deslocamento;I Projeto através de máquinas de estado;I Análise através de máquinas de estado.

ELD0001 ‡ Prof. Renan Sebem ‡ Aula 12 3 / 13

Resolução da Prova

Sobre a provaAntes:

I Identifiquem os conteúdos mais importantes;I Identifiquem suas dificuldades;I Preparem-se, leiam a teoria e resolvam exercícios;I Procurem o professor, tirem dúvidas;

Durante:I Leiam a prova inteira;I Identifiquem as questões mais fáceis;I Sempre resolvam as questões mais fáceis primeiro!I Insistam, revisem a prova até o último minuto.

ELD0001 ‡ Prof. Renan Sebem ‡ Aula 12 4 / 13

Resolução da Prova

Avaliação

I Quem é a única pessoa que pode avaliar o conhecimento do aluno?

ELD0001 ‡ Prof. Renan Sebem ‡ Aula 12 5 / 13

Código para correção de erros

Considerações sobre correção de erro

I Deseja-se transmitir informação através de uma palavra (A) de 7bits;

I Deseja-se gerar um código que aplicado nesta palavra informeatravés de outra palavra (B), se a palavra está correta, e se nãoestiver correta em qual bit encontra-se o erro;

I Considera-se que somente um bit apresentará erro por vez;I Qual o número mínimo de bits para a palavra B?

ELD0001 ‡ Prof. Renan Sebem ‡ Aula 12 6 / 13

Código para correção de erros

Código de Hamming

I Permite a correção de erros;I Códigos para correção de erros são mais complexos que os para

detecção de erros;I O código de Hamming está entre os códigos para correção de erros

mais simples;

ELD0001 ‡ Prof. Renan Sebem ‡ Aula 12 7 / 13

Código para correção de erros

RepresentaçãoI Códigos de correção de erros são representado pelo par (n, k):

I onde k é o número de bits da informação original;I e n é o número de bits da informação codificada;

I Assim, m = n − k , é o número de bits de paridade;I O código de Hamming existe para qualquer m > 1, sendo que:

I n = 2m − 1;I k = 2m −m − 1;I r = k/n, é a razão (rate) do código;I M = 2k é o número total de palavras codificadas.

Exemplos:I Para m = 3: n = 7, k = 4, r = 4/7, M = 16 → Cód. de Hamming

(7, 4);I Para m = 4: n = 15, k = 11, r = 11/15, M = 2048 → Cód. de

Hamming (15, 11);I Para m = 5: n = 31, k = 26, r = 26/31, M = 67.108.864 → Cód.

de Hamming (31, 26).OBS: o cód. de Hamming mais utilizado é o (7,4).

ELD0001 ‡ Prof. Renan Sebem ‡ Aula 12 8 / 13

Código para correção de erros

Nomenclatura - exemplo (7,4)

I u = u1u2u3u4 é o vetor de bits da informação original;I c = c1c2c3c4c5c6c7 é o vetor da informação codificada;I G é a matriz de geração do código de Hamming;I H é a matriz de decodificação do cód. de Hamming.

Então:I c = uG

I e HcT =

000

ELD0001 ‡ Prof. Renan Sebem ‡ Aula 12 9 / 13

Código para correção de erros

Cálculo

Hamming distance dmin = 3. Consequently, if during the transmission of a codeword the communication channel introduces one error (that is, fl ips the value of one bit), the receiver will be able to unequivocally correct it.

Error-correcting codes are normally represented using the pair (n, k), where k is the number of informa-tion bits (that is, the size of the original information word, u = u1u2 . . . uk, that enters the encoder) and n is the number of encoded bits (that is, the size of the codeword c = c1c2 . . . cn that leaves the encoder). There-fore, m = n − k is the number of redundancy (or parity) bits. The ratio r = k/n is called the rate of the code.

For any integer m > 1, a Hamming code exists, with n = 2m − 1, k = 2m − m − 1, r = k/n, and a total of M = 2k codewords. Some examples are listed below (all with dmin = 3).

For m = 3: n = 7, k = 4, r = 4/7, M = 16 → (7, 4) Hamming codeFor m = 4: n = 15, k = 11, r = 11/15, M = 2048 → (15, 11) Hamming codeFor m = 5: n = 31, k = 26, r = 26/31, M = 67,108,864 → (31, 26) Hamming code

The actual implementation will fall in one of the following two categories: nonsystematic (the parity bits are mixed with the information bits) or systematic (the parity bits are separated from the informa-tion bits). An example of the latter is shown in the table of Figure 7.5(a), with the original words (called u, with k = 4 bits) shown on the left and the encoded words (called c, with n = 7 bits) on the right. Note that this code is systematic, because c1c2c3c4 = u1u2u3u4. Note also that d ! 3 between any two Hamming codewords, and that the original words include the whole set of k-bit sequences.

Because the code of Figure 7.5 must add m = 3 parity bits to each k-bit input word, three parity-check equations are needed, which, in the present example, are:

c5 = c1 ! c2 ! c3 (7.6a)

c6 = c2 ! c3 ! c4 (7.6b)

c7 = c1 ! c2 ! c4 (7.6c)

FIGURE 7.5. (a) Input and output codewords of a cyclic-systematic (7, 4) Hamming encoder; Corresponding (b) parity check and (c) generator matrices.

7.4 Hamming Codes 157

158 CHAPTER 7 Error-Detecting/Correcting Codes

Above, ! represents again modulo-2 addition (or XOR operation, which produces output = '0' when the number of ones at the input is even, or '1' when it is odd).

The parity-check equations above can be rewritten as:

c1 ! c2 ! c3 ! c5 = 0 (7.7a)

c2 ! c3 ! c4 ! c6 = 0 (7.7b)

c1 ! c2 ! c4 ! c7 = 0 (7.7c)

From these equations, an equivalent representation, using a matrix, results. It is called parity-check matrix (H), and it contains m = 3 lines (one for each parity-check equation) and n = 7 columns. Figure 7.5(b) shows H for the code described by the equations above (whose codewords are those in Figure 7.5(a)). Note, for example, that row 1 of H has ones in positions 1, 2, 3, and 5, because those are the nonzero coef-fi cients in the fi rst of the parity-check equations above.

Because the code in Figure 7.5 is systematic, H can be divided into two portions: the left portion, called A, corresponds to the original (information) bits and shows how those bits participate in the parity-check equations; the right portion, called Im, corresponds to the redundancy bits and is simply an identity matrix of size m. Therefore, H can be written as H = [AIm]. (Note: Any given matrix H can be converted into the format shown in Figure 7.5(b) by applying Gauss-Jordan transformation; however, this normally includes column combinations/permutations, so an equivalent but different set of codewords will be generated.)

The major use of H is for decoding because it contains the parity-check equations. Because each row of H is one of these equations, if c is a valid codeword then the following results (where cT is the transpose of vector c):

HcT = 0 (7.8)

Still another representation for a linear code is by means of a generator matrix (G). As illustrated in Figure 7.5(c), in the case of systematic codes it is constructed from H using AT (the transpose of A) and an identity matrix of size k (Ik), that is, G = [IkA

T].While H is used for decoding the codewords, G is used for generating them. As in any linear code, the

codewords are obtained by linear combinations among the rows of G (that is, row1, row2, . . . , row1 + row2, . . . , row1 + row2 + row3 + . . .). Because there are k rows in G, and the original words (u) are k bits long and include all k-bit sequences, the direct multiplication of u by G produces a valid codeword (thus the name for G), that is:

c = uG (7.9)

In summary, G is used for generating the codewords (because c = uG), while H is used for decoding them (because HcT = 0). Moreover, if the code is systematic, then G = [IkA

T] and H = [AIm], where A is the m-by-k matrix containing the coeffi cients of the parity-check equations and Ik and Im are identity matrices of sizes k and m, respectively.

The Hamming encoding-decoding procedure is illustrated in Figure 7.6, which shows the encoder on the left and the decoder on the right, interconnected by some type of (noisy) communications channel. The encoder receives the information word, u, and converts it into a Hamming codeword, c, using G (that is, c = uG). The decoder receives c*, which is a possibly corrupted version of c. It fi rst computes the syndrome, s, using H (that is, s = Hc*T). If s = "00 . . . 0," then no error has occurred, and c** = c* is sent out, from which u is retrieved. Otherwise, if exactly one error has occurred, s will be equal to one of the columns of H. Suppose that it is the ith column, then the error is in the ith bit of c*, which must then be reversed.

Hamming distance dmin = 3. Consequently, if during the transmission of a codeword the communication channel introduces one error (that is, fl ips the value of one bit), the receiver will be able to unequivocally correct it.

Error-correcting codes are normally represented using the pair (n, k), where k is the number of informa-tion bits (that is, the size of the original information word, u = u1u2 . . . uk, that enters the encoder) and n is the number of encoded bits (that is, the size of the codeword c = c1c2 . . . cn that leaves the encoder). There-fore, m = n − k is the number of redundancy (or parity) bits. The ratio r = k/n is called the rate of the code.

For any integer m > 1, a Hamming code exists, with n = 2m − 1, k = 2m − m − 1, r = k/n, and a total of M = 2k codewords. Some examples are listed below (all with dmin = 3).

For m = 3: n = 7, k = 4, r = 4/7, M = 16 → (7, 4) Hamming codeFor m = 4: n = 15, k = 11, r = 11/15, M = 2048 → (15, 11) Hamming codeFor m = 5: n = 31, k = 26, r = 26/31, M = 67,108,864 → (31, 26) Hamming code

The actual implementation will fall in one of the following two categories: nonsystematic (the parity bits are mixed with the information bits) or systematic (the parity bits are separated from the informa-tion bits). An example of the latter is shown in the table of Figure 7.5(a), with the original words (called u, with k = 4 bits) shown on the left and the encoded words (called c, with n = 7 bits) on the right. Note that this code is systematic, because c1c2c3c4 = u1u2u3u4. Note also that d ! 3 between any two Hamming codewords, and that the original words include the whole set of k-bit sequences.

Because the code of Figure 7.5 must add m = 3 parity bits to each k-bit input word, three parity-check equations are needed, which, in the present example, are:

c5 = c1 ! c2 ! c3 (7.6a)

c6 = c2 ! c3 ! c4 (7.6b)

c7 = c1 ! c2 ! c4 (7.6c)

FIGURE 7.5. (a) Input and output codewords of a cyclic-systematic (7, 4) Hamming encoder; Corresponding (b) parity check and (c) generator matrices.

7.4 Hamming Codes 157

ELD0001 ‡ Prof. Renan Sebem ‡ Aula 12 10 / 13

Código para correção de erros

ExemplosDados os seguintes resultados para as matrizes H · · · cT , identifique qualé o bit que contém erro (considerando que apenas um bit está errado):

I H · cT =

110

I H · cT =

011

I H · cT =

101

I H · cT =

100

ELD0001 ‡ Prof. Renan Sebem ‡ Aula 12 11 / 13

Bibliografia

[1] Anil K. Maini. Digital Electronics Principles: Devices andApplications. Wiley, 2007.

[2] Volnei A. Pedroni. Eletrônica digital moderna e VHDL: Princípiosdigitais, Eletrônica Digital, Projeto Digital, Microeletrônica e VHDL.Elsevier, 2010.

ELD0001 ‡ Prof. Renan Sebem ‡ Aula 12 12 / 13

Aula 12 - Correção de erros

Prof. Renan Sebem

Disciplina de Eletrônica DigitalGraduação em Engenharia Elétrica

Universidade do Estado de Santa CatarinaJoinville-SC – Brasil

5 de abril de 2016

Obrigado.

ELD0001 ‡ Prof. Renan Sebem ‡ Aula 12 13 / 13