Hamming Code
Hamming Code
Hamming Code
In the late 1940s Richard Hamming recognized that the further evolution of computers required greater reliability, in particular the ability to not only detect errors, but correct them. His search for errorcorrecting codes led to the Hamming Codes, perfect 1-error correcting codes, and the extended Hamming Codes, 1-error correcting and 2-error detecting codes.
Hamming Codes are still widely used in computing, telecommunication, and other applications. Hamming Codes also applied in
Data compression Some solutions to the popular puzzle The Hat Game Block Turbo Codes
Number the bits starting from 1: bit 1, 2, 3, 4, 5, etc. Write the bit numbers in binary. 1, 10, 11, 100, 101, etc. All bit positions that are powers of two (have only one 1 bit in the binary form of their position) are parity bits. All other bit positions, with two or more 1 bits in the binary form of their position, are data bits.
Each data bit is included in a unique set of 2 or more parity bits, as determined by the binary form of its bit position.
Parity bit 1 covers all bit positions which have the least significant bit set: bit 1 (the parity bit itself), 3, 5, 7, 9, etc. Parity bit 2 covers all bit positions which have the second least significant bit set: bit 2 (the parity bit itself), 3, 6, 7, 10, 11, etc. Parity bit 4 covers all bit positions which have the third least significant bit set: bits 47, 1215, 20 23, etc.
Parity bit 8 covers all bit positions which have the fourth least significant bit set: bits 815, 2431, 4047, etc. In general each parity bit covers all bits where the binary AND of the parity position and the bit position is non-zero. This general rule can be shown visually:
Include 4 parity bits and the 8-bit word 12 bits 2k 1 n + k, n = 8 k = 4 Bit position: 12 11 10 9 8 7 6 5 4 3 2 1 1 1 0 0 P8 0 1 0 P4 0 P2 P1 Calculate the parity bits: even parity assumption P1 = XOR of bits (3, 5, 7, 9, 11) = 0 0 0 0 1 = 1 P2 = XOR of bits (3, 6, 7, 10, 11) = 0 1 0 0 1 = 0 P4 = XOR of bits (5, 6, 7, 12) = 0 1 0 1 = 0 P8 = XOR of bits (9, 10, 11, 12) = 0 0 1 1 = 0 Store the 12-bit composite word in memory. Bit position: 12 11 10 9 8 7 6 5 4 3 2 1 1 1 0 0 0 0 1 00 0 01
Bit position: 1 2 3 4 5 6 7 8 9 10 11 12 P1 P2 D7 P4 D6 D5 D4 P8 D3 D2 D1 D0 Check bits (cb) locations: 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) . cb for 2k-1=XOR of bits with 2k-1 set in their bit #
Check bits are calculated C1 = XOR of bits (1, 3, 5, 7, 9, 11)=XOR of bits(1, P1) C2 = XOR of bits (2, 3, 6, 7, 10, 11)=XOR of bits(2, P2) C4 = XOR of bits (4, 5, 6, 7, 12)=XOR of bits(4, P4) C8 = XOR of bits (8, 9, 10, 11, 12)=XOR of bits(8, P8)
C = C8C4C2C1 = 0000
One-bit error
error in bit 1
C1 = XOR of bits (1, C2 = XOR of bits (2, C4 = XOR of bits (4, C8 = XOR of bits (8, C8C4C2C1 = 0001 3, 3, 5, 9, 5, 7, 9, 11) = 1 6, 7, 10, 11) = 0 6, 7, 12) = 0 10, 11, 12) = 0
error in bit 5
Two-bit error
Hamming code
Can detect and correct only a single error Multiple errors may not be detected Can detect double errors and correct a single error. The additional parity bit is the XOR of all the other bits
THANK YOU!!!