Error Detection and Correction: CIT 595 Spring 2008
Error Detection and Correction: CIT 595 Spring 2008
Error Detection and Correction: CIT 595 Spring 2008
Data that is either transmitted over communication channel (e.g. bus) or stored in memory is not completely error free
2. Storage Errors
DRAM memory cell contents can change spuriously due to some electromagnetic interference In magnetic storage devices such as disks, magnetic flux density increases could cause one or more bits to flip (change that value)
CIT 595
Parity
The simplest and oldest error detection method A binary digit called parity is used to indicate whether the number of bits with 1 in a given set of bits is even or odd
The parity bit is then appended to original data
CIT 595
CIT 595
Note that error could be in data or parity Not entirely fool proof
CIT 595 5 CIT 595 6
Limitations of Parity
Cannot determine which bit position has a problem If 001 is encountered, it is not a valid code-word and hence error is detected The correct code-word could either be 101 or 011 but we cannot tell
Data Word 00 01 10 11 000 001 010 011 Parity Code (Even) 0 1 1 0 100 101 110 111 Code Word 000 011 101 110
CIT 595
CIT 595
If distance is d, then d-single bit errors are required to convert any one valid code into another
Implying that this error would not be detected
CIT 595
CIT 595
10
Adopt parity concept, but have more than one parity bit In general hamming code is code word of n bits with m data bits and r parity (or check bits)
i.e. n = m + r
Determining # of Parity bits for single-bit correction Hamming Code for single-bit error correction is the most commonly used Experiments (IBM study) show 98% time there are single-bit errors Need determine r for m-data bits that provides code words of n-bits that has single-bit correction capabilities
Determining # of Parity bits for single-bit correction An error could occur in any of the n bits of the code word, so each code word can be associated with n erroneous words (at a hamming distance of 1)
E.g. Previous Parity Example (slide 7) 000 can become 001 or 010 or 100 due to single bit error
Therefore, we have n + 1 bit patterns for each code word: one valid code word, and n erroneous words This gives us the inequality: (n + 1) 2 m 2 n
2 m is the number of legal code
CIT 595
13
CIT 595
14
Hamming Code: Determining Parity bits for single-bit correction Because n = m + r, we can rewrite the inequality as: (m + r + 1) 2 m 2 m + r or (m + r + 1) 2 r This inequality gives us a lower limit on the number of parity bits that we need in our code words
Example: Suppose we have data words of length m = 4
(4 + r + 1) 2 r
Implies that r must be greater than or equal to 3 To build a code with 4-bit data words that will correct single-bit errors, we must add 3 check bits
CIT 595
15
CIT 595
16
And so on
CIT 595
17
CIT 595
18
The completed code word is shown above: Bit 1 checks the positions 3, 5, 7, 9, and 11, so its value is 1 Bit 2 checks the positions 3, 6, 7, 10, and 11, so its value is 0 Bit 4 checks the positions 5, 6, 7, and 12, so its value is 1 Bit 8 checks the positions 9, 10, 11, and 12, so its value is also 1
19 CIT 595 20
CIT 595
Suppose an error occurs in bit 5, as shown above Our parity bit values are: Bit 1 checks positions, 3, 5, 7, 9, and 11. Its value is 1, but should be 0. Bit 2 checks positions 3, 6, 7, 10, and 11. The zero is correct. Bit 4 checks positions 5, 6, 7, and 12. Its value is 1, but should be 0 Bit 8 checks positions 9, 10, 11, and 12. This bit is correct.
CIT 595 21
Parity bits 1 and 4 both check position 5 and 7 Since parity bit 2 checks bit 7 and indicates no error occurred in the subset of bits it checked that means that error occurred in bit 5 If we change bit 5 to a 1, all parity bits check and our data is restored
CIT 595
22
To determine whether we have 1-bit or 2-bit error we add need to add an extra check bit
The extra check bit is to determine parity across all data and existing parity bits If this extra check bit is calculated to match the received value, then we either have two bit errors, or no errors No errors can be confirmed by further determining whether parity at bit position 1, 2, 4, 8, etc are same as received parity at those positions
23 CIT 595 24
CIT 595
26