80 likes | 98 Views
EEL 3705 / 3705L Digital Logic Design. Fall 2006 Instructor: Dr. Michael Frank Lecture Module #27: Error Control Codes. Parity Codes. Used for error detection. After n bits, b 0 … b n −1 , add one more bit b n defined to be the XOR (or NXOR) of the others:
E N D
EEL 3705 / 3705LDigital Logic Design Fall 2006Instructor: Dr. Michael Frank Lecture Module #27:Error Control Codes M. Frank, EEL3705 Digital Logic, Fall 2006
Parity Codes • Used for error detection. • After n bits, b0…bn−1, add one more bit bn defined to be the XOR (or NXOR) of the others: • With XOR, bn = b0b1…bn−2bn−1. • Using NXOR, bn = ~(b0b1…bn−2bn−1). • The extra bit bn is called a parity bit. • If XOR is used, we say the code is even parity, • because b0+b1+…+bn ≡ 0 (mod 2); the sum of all bits is an even number. • if NXOR is used, the code is called odd parity. • because b0+b1+…+bn ≡ 1 (mod 2); the sum of all bits is an odd number. • When all n bits are received, if bn does not match the remaining bits according to how it was generated, • then we know that at least one of the bits was altered in transmission. • Any single bit error can be detected using this technique. • More sophisticated variants can also be used to locate and correct bit errors. M. Frank, EEL3705 Digital Logic, Fall 2006
Distance Metrics • A common distance metric between two binary words I,J of the same length n is the number of bits that differ between them. • This gives the number of single-bit errors that would have to occur to transform I into J. • The more distant the codewords in a code are from each other, the more resilient the code is to independent errors. M. Frank, EEL3705 Digital Logic, Fall 2006
Distance Example • The distance between any two given 3-bit strings is the same as the number of edges of the 3-cube at right that must be traversed to get from one to the other. • E.g., d(001,110) = 3. 011 111 001 101 010 110 000 100 M. Frank, EEL3705 Digital Logic, Fall 2006
General Requirements for Error Correction and Detection • Let dminbe the minimum distance between the codewords in a code C. • Then the code C can correct any set of up to t bit errors and at least detect up to s additional errors, for any pair (s,t) where 2t + s <dmin . M. Frank, EEL3705 Digital Logic, Fall 2006
Example of Distance Metric and Error Correction/Detection • Consider a 3-bit code with only two codewords w1 and w2 such that d(w1,w2) = 3. (Thus, dmin = 3.) • For example, we could let w1 = 000 and w2 = 111. • With this code, we can correct any 1 error, or detect up to any 2 errors. two errors codescorrectableto w2 codescorrectableto w1 011 100 010 101 001 110 oneerror Valid codewords: 111 000 M. Frank, EEL3705 Digital Logic, Fall 2006
Gray Codes • A binary Gray code for numbers (mod n) has the property that the codes for adjacent numbers differ only in 1 bit position. • d(a, a+1 mod n) = 1. • This property can help improve reliability of communication systems… • Since if a continuous signal coding a word drifts by 1 unit, it changes only 1 bit of the coded value • A 1-bit error can be detected and corrected relatively easily. • It’s also useful if there is a need to ensure that a state “in between” two subsequent codewords is not mistaken for a different codeword. • Disk spindle example • For n=2k, a k-bit Gray code can be generating using the rule that the bits of the gray code word g representing the binary number b are gi = bibi+1 • E.g., For k=2, the map b→g is 0 → 00, 1 → 01, 2 → 11, 3 → 10 • For k=3 the sequence of g’s is: 000, 001, 011, 010, 110, 111, 101, 100 • Later, we will also find that this code is useful in drawing Karnaugh maps for the optimization of digital circuits. M. Frank, EEL3705 Digital Logic, Fall 2006
The Hamming Code: An Error Correction Code based on Parity Bits • Adding n+1 parity bits to a (2n−1)-bit data sequence lets us detect and correct any single error in the data or parity bits. • This is known as a Hamming code, and it is called a “perfect” code • For n=4, the space blowup caused by the parity bits is 33.33% • Overhead gets smaller as n increases. (e.g. n=10 1.07% overhead) • p is the XOR of all data bits • pi includes dj if bit i is 1 inthe binary expansion of j • If dj is altered, p indicates anerror has occurred, and the pitogether give the value of j. • If pi is altered, then p indicatesthis, and pi can be regenerated • If p is altered, the pi show this and p can be regenerated. Codeword for n=4: (d1,…,d15, p, p0, p1, p2, p3) Where p = d1d2…d14d15,p0 = d1d3d5d7d9d11d13d15,p1 = d2d3d6d7d10d11d14d15,p2 = d4d5d6d7d12d13d14d15, p3 = d8d9d10d11d12d13d14d15. M. Frank, EEL3705 Digital Logic, Fall 2006