Sie sind auf Seite 1von 4

Hamming Code

ELECTENG 3770 Spring 2015


Professor: Dr. Bill Hudson

ELECTENG 3770
Bit position

Encoded
data bits

P1
Parity bit P2
coverage P4
P8

Hamming Code
2

P1

P2 D1

P4

D2

D3

Logic and Digital Design


9

10

11

12

13

14

15

D4 P8

D5

D6

D7

D8

D9

D10

D11

FIGURE 1 | The paritycheck matrix of a Hamming code.

Hamming Code Introduction


In telecommunication, Hamming codes are a family of linear error-correcting codes that generalize
the Hamming(7,4)code invented by Richard Hamming in 1950. Hamming codes can detect up
to two-bit errors or correct onebit errors without detection of uncorrected errors. By contrast,
the simple parity code cannot correct errors, and can detect only an odd number of bits in error.
Hamming codes are perfect codes, that is, they achieve the highest possible rate for codes with
their block length and minimum distance 3.
In mathematical terms, Hamming codes are a class of binary linear codes. For each integer
2 there is a code with block length = 2 1 and message length = 2 1. Hence the
rate of Hamming codes is = / = 1 /(2 1), which is the highest possible for codes with
minimum distance 3 (i.e., the minimal number of bit changes needed to go from any code word to
any other code word is 3) and block length 2 1. The paritycheck matrix of a Hamming code is
constructed by listing all columns of length that are nonzero, which means that the dual code of
the Hamming code is the punctured Hadamard code. The parity-check matrix has the property
that any two columns are pairwise linearly independent.
Due to the limited redundancy that Hamming codes add to the data, they can only detect and
correct errors when the error rate is low. This is the case in computer memory (ECC memory),
where bit errors are extremely rare and Hamming codes are widely used. In this context, an
extended Hamming code having one extra parity bit is often used. Extended Hamming codes
achieve a Hamming distance of 4, which allows the decoder to distinguish between when at most
one 1bit error occurs and when any 2bit errors occur. In this sense, extended Hamming codes
are singleerror correcting and doubleerror detecting, abbreviated as SECDED.
Source: Hamming code - https://en.wikipedia.org

Hamming Code ParityCheck Example 1


Encode sequence: 11001101101
This corresponds with the data locations, and therefore can be aligned with the appropriate
data columns.
Page 2 of 4

ELECTENG 3770

Hamming Code

Logic and Digital Design

Parity Bit 1 Check


1

P1

P2

D1

P4 D2

D3

D4

P8 D5

10

11

12

13

14

15

D6

D7

D8

D9

D10

D11

=5

5 is odd. For evenparity Hamming Code, parity bit P1 is 1 in order to make the odd number (5) of
ones an even number (6).
P1 = 1.
The same procedure is then repeated for the other parity bits:

Parity Bit 2 Check


1

P1

P2

D1

P4 D2
1

D3

D4

P8 D5
1

10

11

12

13

14

15

D6

D7

D8

D9

D10

D11

=3

3 is odd. For evenparity Hamming Code, parity bit P2 is 1 in order to make the odd number (3) of
ones an even number (4).
P2 = 1.

Parity Bit 4 Check


1

P1

P2

D1
1

P4 D2

D3

D4

P8 D5
1

10

11

12

13

14

15

D6

D7

D8

D9

D10

D11

=4

4 is even. For evenparity Hamming Code, parity bit P4 is 0 and there is no need to add 1 to make
it even.
P4 = 0.

Parity Bit 8 Check


1

P1

P2

D1
1

P4 D2
1

D3

D4

P8 D5

1

10

11

12

13

14

15

D6

D7

D8

D9

D10

D11

=5

5 is odd. For evenparity Hamming Code, parity bit P8 is 1 in order to make the odd number (5) of
ones an even number (6).
P8 = 1.
Sequence transmitted: 1 1 1 0 100 1 1101101
Sequence received: 1 1 1 0 100 0 1101101
Page 3 of 4

ELECTENG 3770

Hamming Code

Logic and Digital Design

Then perform an exclusive or, ,on the data sequence transmitted and the data sequence received:
1

1
1
0

1
1
0

1
1

0
0
0

1
1

0
0

0
0

1
0
1

1
1

10

1
1

11

0
0

12

1
1

13

1
1

14

0
0

15

1
1

The result of the exclusive or, , is 1000 since the order of signicance in terms of the digits in
the sequence is reversed. This corresponds with the 8th bit, which is the anticipated result of this
process.

Page 4 of 4

Das könnte Ihnen auch gefallen