Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 325: CS Hardware and Software Organization and Architecture

Similar presentations


Presentation on theme: "CS 325: CS Hardware and Software Organization and Architecture"— Presentation transcript:

1 CS 325: CS Hardware and Software Organization and Architecture
Error Detection and Correction

2 Error Detection and Correction
Bits are occasionally flipped in transmission. For example: is sent, but is received. Adding redundancy can allow us to detect, and possibly correct, some errors of this type.

3 Error Detection and Correction
Simple approach: Repeat each bit Repeat each bit twice. For bit a, transmit aa. If the receiver gets two different bits, it requests a retransmission. This is an error detecting code. Allows for one error to be detected, but is not error correcting since retransmission is necessary Repeat each bit three times. For each bit a, transmit aaa. Now the receiver can correct a single error. Why?

4 Problem with the simple approach
The receiver can detect and correct bit errors if each bit is transmitted three times. How does this affect performance? Bus bandwidth efficiency = 33% Better approach Parity check codes Has the ability to detect odd number of bit flips using a single parity bit.

5 Calculating bit string parity
A bit string has odd parity if the number of 1s in the string is odd. 100011, 1, have odd parity A bit string has even parity if the number if 1s in the string is even. 01100, 000, have even parity Assume 0 is an even number

6 Parity check code Assume we are transmitting blocks of k bits.
A block (w) of length (k) is encoded as (wa), where the value of the parity bit (a) is chosen so that (wa) has even parity. Example: If w = 10110, we send wa = , which has even parity With no bit flips in the transmission, the receiver gets the bit string exactly as it was sent by the sender. Bit string has even parity. If there are an odd number of bit flips in the transmission, the receiver gets a bit string with odd parity. Retransmission is requested. If there are an even number of bit flips in the transmission, the receiver gets a bit string with even parity. The error(s) go undetected. Ex: Another solution?

7 2D parity check code Blocks of bits are organized in rows and columns
m x n matrix The parity bit of each row is calculated, and appended to the row before it is transmitted. The parity of each column is calculated, and appended to the column before it is transmitted. The parity bit of the entire matrix is computed.

8 2D parity check Example (even parity):
Original data: 1100, 1011, 0111, 0101 MN + M + N + 1 bits transferred. 4* = 25 bits 16/25  64% bus bandwidth efficiency Row Parity 1 Column Parity Matrix Parity bit

9 2D parity check code Data bits: mn Parity bits: m + n + 1
Total # of bits sent: mn + m + n + 1 Efficiency becomes greater as block size increases Ex: 2x2 block 2* = 9, 4/9 bits are data: 44% efficient Ex: 6x6 block 6* = 49, 36/49 bits are data: 73.5% efficient Ex: 10x10 block 10 * = 121, 100/121 bits are data: 82.6% efficient Problem with large block size: Higher probability of errors transmitted due to smaller number of parity bits/data bit

10 2D parity check Another Example (even parity):
Original data: 1100, 1011, 0111, 0101 Row Parity 1 Column Parity Matrix Parity bit

11 2D parity check Another Example (even parity):
Original data: 1100, 1011, 0111, 0101 Row Parity 1 Column Parity Matrix Parity bit

12 2D parity check Another Example (even parity):
Received data: 1100, 1011, 0111, 0111 Row Parity 1 Column Parity Matrix Parity bit

13 2D parity check Another Example (even parity):
Received data: 1100, 1011, 0111, 0111 Possible to fix the problem without retransmitting the data Row Parity 1 Column Parity Matrix Parity bit

14 2D parity check Another Example (even parity):
Received data: 1100, 1011, 0111, 0111 Possible to fix the problem without retransmitting the data Row Parity 1 Column Parity Matrix Parity bit

15 2D parity check 2D parity check can detect and correct all 1 bit errors. Error bit 1

16 2D parity check 2D parity check can detect all 2 bit errors.
Can’t correct all 2 bit errors. Data must be resent. Error bits 1

17 2D parity check 2D parity check can detect all 3 bit errors.
Can’t correct all 3 bit errors. Data must be resent. Error bits 1

18 2D parity check 2D parity check can detect most 4 bit errors.
Can’t correct all 4 bit errors. Data must be resent. Example of a 4 bit error that is NOT detected: Error bits 1

19 Non-ECC vs. ECC RAM Non-Error-Correcting Code Memory
Can’t detect errors Most standard DDR SDRAM is Non-ECC Memory Cheaper, but susceptible to errors Error-Correcting Code (ECC) Memory Used where data corruption can’t be tolerated Most RAM used by servers and high end computers are ECC RAM More expensive than Non-ECC memory

20 Hamming Code Error detecting/correcting codes invented by Richard Hamming in 1950. Solution for error-prone punched card readers at Bell Labs Still used today Can correct 1 bit errors Can detect up to 2 bit errors

21 Hamming Code – Parity bits
Hamming code works by placing parity bits throughout a bit string of size (w) (p) parity bits creates a bit string of size 2m – 1, of which 2m – m – 1 bits can be used for data. Common Hamming code sizes: Hamming(3,1), 2 parity bits, 33% efficiency Hamming(7,4), 3 parity bits, 57% efficiency Hamming(15,11), 4 parity bits, 73% efficiency Hamming(31,26), 5 parity bits, 84% efficiency Read as Hamming(total bits, data bits)

22 Hamming Code Example: Using Hamming(7,4), create the Hamming codeword for the following 4 bit string: 0101 Hamming(7,4) 7 total bits 4 data bits 3 parity bits Parity bits are always located in the codeword at positions of 2n. P1 = 20 = 1 P2 = 21 = 2 P3 = 22 = 4

23 Hamming Code Example: Using Hamming(7,4), create the Hamming codeword for the following 4 bit string: 0101 1 2 3 4 5 6 7 P1 P2 P3

24 Hamming Code Example: Using Hamming(7,4), create the Hamming codeword for the following 4 bit string: 0101 Now, calculate the parity bits 1 2 3 4 5 6 7 P1 P2 P3

25 Hamming Code To calculate P1: find parity of substring(1,3,5,7) 1 2 3
4 5 6 7 P1 P2 P3 To calculate P1: find parity of substring(1,3,5,7)

26 Hamming Code To calculate P1: find parity of substring(1,3,5,7)
2 3 4 5 6 7 P1 P2 P3 To calculate P1: find parity of substring(1,3,5,7) 20 = 1, so check 1 bit, skip 1 bit, check 1 bit, skip 1 bit, … P = 0

27 Hamming Code To calculate P1: find parity of substring(1,3,5,7)
2 3 4 5 6 7 P1 P2 P3 To calculate P1: find parity of substring(1,3,5,7) 20 = 1, so check 1 bit, skip 1 bit, check 1 bit, skip 1 bit, … P = 0 To calculate P2: find the parity of substring(2,3,6,7)

28 Hamming Code To calculate P1: find parity of substring(1,3,5,7)
2 3 4 5 6 7 P1 P2 P3 To calculate P1: find parity of substring(1,3,5,7) 20 = 1, so check 1 bit, skip 1 bit, check 1 bit, skip 1 bit, … P = 0 To calculate P2: find the parity of substring(2,3,6,7) 21 = 2, so check 2 bits, skip 2 bits, check 2 bits, skip 2 bits, … P = 1

29 Hamming Code To calculate P1: find parity of substring(1,3,5,7)
2 3 4 5 6 7 P1 P2 P3 To calculate P1: find parity of substring(1,3,5,7) 20 = 1, so check 1 bit, skip 1 bit, check 1 bit, skip 1 bit, … P = 0 To calculate P2: find the parity of substring(2,3,6,7) 21 = 2, so check 2 bits, skip 2 bits, check 2 bits, skip 2 bits, … P = 1 To calculate P3: find the parity of substring(4,5,6,7)

30 Hamming Code To calculate P1: find parity of substring(1,3,5,7)
2 3 4 5 6 7 P1 P2 P3 To calculate P1: find parity of substring(1,3,5,7) 20 = 1, so check 1 bit, skip 1 bit, check 1 bit, skip 1 bit, … P = 0 To calculate P2: find the parity of substring(2,3,6,7) 21 = 2, so check 2 bits, skip 2 bits, check 2 bits, skip 2 bits, … P = 1 To calculate P3: find the parity of substring(4,5,6,7) 22 = 4, so check 4 bits, skip 4 bits, check 4 bits, skip 4 bits, … P = 0

31 Hamming Code To calculate P1: find parity of substring(1,3,5,7)
2 3 4 5 6 7 P1 P2 P3 To calculate P1: find parity of substring(1,3,5,7) 20 = 1, so check 1 bit, skip 1 bit, check 1 bit, skip 1 bit, … P = 0 To calculate P2: find the parity of substring(2,3,6,7) 21 = 2, so check 2 bits, skip 2 bits, check 2 bits, skip 2 bits, … P = 1 To calculate P3: find the parity of substring(4,5,6,7) 22 = 4, so check 4 bits, skip 4 bits, check 4 bits, skip 4 bits, … P = 0 Now we know P1, P2, and P3 and can calculate the codeword:

32 Hamming Code Another Example:
Using Hamming(15,11), create the Hamming codeword for the following 11 bit string: Hamming(15,11) 15 total bits 11 data bits 4 parity bits Parity bits are always located in the codeword at positions of 2n. P1 = 20 = 1 P2 = 21 = 2 P3 = 22 = 4 P4 = 23 = 8

33 Hamming Code Example: Using Hamming(15, 11), create the Hamming codeword for the following 11 bit string: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 P1 P2 P3 P4

34 Hamming Code Example: Using Hamming(15, 11), create the Hamming codeword for the following 11 bit string: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 P1 P2 P3 P4

35 Hamming Code Codeword: 010101110110010
To calculate P1: find parity of substring(1,3,5,7,9,11,13,15) P = 0 To calculate P2: find parity of substring(2,3,6,7,10,11,14,15) P = 1 To calculate P3: find parity of substring(4,5,6,7,12,13,14,15) P = 1 To calculate P4: find parity of substring(8,9,10,11,12,13,14,15) P = 1 Codeword: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 P1 P2 P3 P4

36 Hamming Code Try: Using Hamming(7,4), create the Hamming codeword for the following 4 bit string: 1100 P = 0 P = 1 P = 1 1 2 3 4 5 6 7 P1 P2 P3 1 2 3 4 5 6 7

37 Checking Hamming Code for Correctness
Example: Using Hamming(7,4), check the Hamming codeword for correctness. 1 2 3 4 5 6 7

38 Checking Hamming Code for Correctness
Example: Using Hamming(7,4), check the Hamming codeword for correctness. P = 0 P = 1 P = 1 1 2 3 4 5 6 7

39 Checking Hamming Code for Correctness
Example: Using Hamming(15,11), check the Hamming codeword for correctness. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

40 Checking Hamming Code for Correctness
Example: Using Hamming(15,11), check the Hamming codeword for correctness. P = 1 P = 0 P = 0 P = 1 How to find flipped bit? Just add wrong parity bit offsets: = 14 Flip bit at position 14 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

41 Checking Hamming Code for Correctness
Example: Using Hamming(15,11), check the Hamming codeword for correctness. P = 1 P = 0 P = 0 P = 1 How to find flipped bit? Just add wrong parity bit offsets: = 14 Flip bit at position 14 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

42 Checking Hamming Code for Correctness
Example: Using Hamming(15,11), check the Hamming codeword for correctness. P = 1 P = 0 P = 0 P = 1 How to find flipped bit? Just add wrong parity bit offsets: = 14 Flip bit at position 14 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 P = 1 P = 1 P = 1 P = 0

43 Checking Hamming Code for Correctness
Example: Using Hamming(15,11), check the Hamming codeword for correctness. State whether or not the codeword is correct. If the codeword is not correct, determine the mistake (flipped- bit) and generate the correct codeword Turn in your work for this problem before leaving class Name at the top Graded as a quiz 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15


Download ppt "CS 325: CS Hardware and Software Organization and Architecture"

Similar presentations


Ads by Google