Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 11

Digital Systems

Department of Computer Science and Information Engineering,


Chaoyang University of Technology

Speaker: Fuw-Yi Yang


,
(Chapter 58)
(Chapter 14) ,
Fuw-Yi Yang
1

Text Book: Digital Design 4th Ed.


Chapter 7 Hamming Code

One of the most common error-correcting codes used in RAMs was


devised by R. W. Hamming. In the Hamming code, k parity bits are
added to an n-bit data word, forming a new word of n + k bits.
Richard Wesley Hamming (Chicago, February 11, 1915 Monterey,
California, January 7, 1998) was an
American mathematician whose work had many implications for
computer science and telecommunications. His contributions include
the Hamming code (which makes use of a Hamming matrix), the
Hamming window (described in Section 5.8 of his book Digital
Filters), Hamming numbers, Sphere-packing (or hamming bound) and
the Hamming distance.
Fuw-Yi Yang
2

Text Book: Digital Design 4th Ed.


Chapter 7 Hamming Code
Bit Position: 1
12

10

11

Notation
B12

: P1 P2 B3 P4 B5 B6 B7 P8 B9

B10 B11

Data
0

Transmitted data
P1
P2
P4
P8

=
=
=
=

Xor
Xor
Xor
Xor

of
of
of
of

bits
bits
bits
bits

(3,
(3,
(5,
(9,

5, 7, 9, 11)
6, 7, 10, 11)
6, 7, 12)
10, 11, 12)

Fuw-Yi Yang

Text Book: Digital Design 4th Ed.


Chapter 7 Hamming Code
Bit Position: 1
12

10

11

Notation
B12

: P1 P2 B3 P4 B5 B6 B7 P8 B9

B10 B11

Data
0

Received data
C1
C2
C4
C8

=
=
=
=

Xor
Xor
Xor
Xor

of
of
of
of

bits
bits
bits
bits

(1,
(2,
(4,
(8,

3,
3,
5,
9,

5, 7, 9, 11)
6, 7, 10, 11)
6, 7, 12)
10, 11, 12)

Fuw-Yi Yang

Text Book: Digital Design 4th Ed.


Chapter 7 Hamming Code
Bit Position: 1
13

10

11

12

Notation
P

: P1 P2 B3 P4 B5 B6 B7 P8 B9

B10 B11 B12

Data

Transmitted data
P1 = Xor of bits (3, 5, 7, 9, 11)
P2 = Xor of bits (3, 6, 7, 10, 11)
P4 = Xor of bits (5, 6, 7, 12)
P8 = Xor of bits (9, 10, 11, 12)
P = Even or Odd parity on bit 1~12

Fuw-Yi Yang

Text Book: Digital Design 4th Ed.


Chapter 7 Hamming Code
Bit Position: 1
13

10

11

12

Notation
P

: P1 P2 B3 P4 B5 B6 B7 P8 B9

B10 B11 B12

Data

Received data
C1 = Xor of bits (1, 3, 5, 7, 9, 11)
C2 = Xor of bits (2, 3, 6, 7, 10, 11)
C4 = Xor of bits (4, 5, 6, 7, 12)
C8 = Xor of bits (8, 9, 10, 11, 12)
P = Even or Odd parity on bit 1~12
C = 0, P = 0
C != 0, P = 1
C != 0, P = 0

no error occurred
single error occurred,
Fuw-Yi Yangcan be corrected
double error occurred, cannot be corrected

Text Book: Digital Design 4th Ed.


Chapter 7 Hamming Code
7-10 Given the 8-bit data word 0101 1011, generate the 13-bit
composite word for the Hamming code that corrects single errors
and detect double errors.
Bit Position: 1 2 3 4 5 6 7 8 9 10 11 12 13
Notation : P1 P2 B3 P4 B5 B6 B7 P8 B9 B10 B11 B12 PE
Data
:
0
1 0 1
1 0
1 1
Parity
: 0 0
1
1
1
Parity data
P1 = Xor of bits (3, 5, 7, 9, 11)
0
P2 = Xor of bits (3, 6, 7, 10, 11)
0
P4 = Xor of bits (5, 6, 7, 12)
1
P8 = Xor of bits (9, 10, 11, 12)
1
PE = Even or Odd parity on bit 1~12 1
Fuw-Yi Yang

Text Book: Digital Design 4th Ed.


Chapter 7 Hamming Code
7-11 Obtain the 15-bit Hamming code word for the 11-bit data word
1100 1001 010.
Position: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Notation: P1 P2 B3 P4 B5 B6 B7 P8 B9 B10 B11 B12 B13 B14 B15
Data
:
1
1 0 0
1 0 0 1 0 1 0
Parity
:
Parity data
P1 = Xor of bits (3, 5, 7, 9, 11, 13, 15)
1
P2 = Xor of bits (3, 6, 7, 10, 11, 14, 15)
0
P4 = Xor of bits (5, 6, 7, 12, 13, 14, 15)
1
P8 = Xor of bits (9, 10, 11, 12, 13, 14, 15)
1
Fuw-Yi Yang

Text Book: Digital Design 4th Ed.


Chapter 7 Hamming Code
7-12 A 12-bit Hamming code word containing 8 bits of data and 4
parity bits is read from memory. What was the original 8-bit data
word that was written into memory if the 12-bit word read out is as
follows:
(a) 0000 1110 1010
(b) 1011 1000 0110
(c) 1011 1111 0100

Fuw-Yi Yang

Text Book: Digital Design 4th Ed.


Chapter 7 Hamming Code
7-13 How many parity check bits must be included with the data
word to achieve single-error correction and double-error detection
when the data word contains
(a) 16 bits
(b) 32 bits
(c) 48 bits

Fuw-Yi Yang

10

Text Book: Digital Design 4th Ed.


Chapter 7 Hamming Code
7-14 It is necessary to formulate the Hamming code for four data bits
D3, D5, D6, and D7, together with three parity bits, P1, P2, and P4.
(a) Evaluate the 7-bit composite code word for the data word 0010.
(b) Evaluate the three check bits, C1, C2, and C4, assuming no error.
(c) Assume an error in bit D5during writing into memory. Show
how the error in the bit is detected and corrected.
(d) Add parity bit P8 to include double-error detection in the code.
Assume that errors occurred in bits P2 and D5. Show how the
double error is detected.

Fuw-Yi Yang

11

You might also like