Title: Cyclic codes
1332437 Lecture 21 Cyclic and Hamming Codes
- Cyclic codes
- Berger codes
- Hamming codes
- Summary
Material from Design and Analysis of Fault
Tolerant Digital Systems, by Barry Johnson,
Addison Wesley
2Cyclic Codes
- Used on current disk systems
- Designed so that any end-around shift of code
word produces another code word. - Has a Boolean generator polynomial G (x) of
degree n-k or greater - n -- number bits in completed code word
- k -- number bits in original information to be
encoded - G (x) coefficients are 0 or 1
3Cyclic Codes (contd.)
- Called an (n, k) cyclic code
- Able to detect all single errors and all
multiple, adjacent errors - Very important for communications applications -
have burst errors - Transient fault that causes several adjacent
errors in a data item - Represent data as a Boolean polynomial
4Example
- 10112 is
- r2, is modulo 2 addition
- Is decimal multiplication
- Code word is the coefficients of a polynomial
5Cyclic Code
- Represents n-bit code word by polynomial of
degree (n-1) or less - V (x) called the code polynomial of the code word
v - Generate code polynomials by multiplying
polynomial (representing data to be encoded) by
generator polynomial
6Example
- Want to encode binary word
- Code polynomial
- Code is the coefficients (1010001)
7Another Example
8Cyclic Code Words for 4-bit Information Words
9Polynomial Interpretation
10Distance 3 Code
- Any 2-bit errors can be detected
- Find Hamming distance
- Compare all code words
- See that all possible pairs differ in at least 3
bit positions
11Circuit Example for Generating a Cyclic Code Word
12Circuit Example
- For generating
- Performs polynomial multiplication
- Implement in digital logic using storage gates
(flip-flops) and XORs - Storage elements provide a time delay
- Data appears serially on D (x)
- Bits of code word appear serially on V (x)
- Registers initialized to 0
13Circuit Example for Generating a Cyclic Code Word
14Encoding Process for the Circuit
15Decoding Procedure
- Non-separable code
- Determine if code word (r0, r1,
r2, , rn-1) is valid - Represents polynomial r0 r1 x
r2 x2 rn-1 xn-1 - Obtained supposedly as
- R (x) D (x) G (x) S (x)
Should be 0 --If not 0, invalid code
16Decoding Procedure (contd.)
- Divide R (x) by G (x) - see if remainder is 0
- S (x) is syndrome polynomial
17Division Circuit
18Circuit Analysis
- B (x) (x3 x) D (x)
- V (x) -- coded data
- D (x) decoded data
- Modulo 2 arithmetic -- and - same
19Proof that Circuit Divides
20Polynomial Division
- Initialize register to 0
- Circuit implements polynomial division
- After division, registers have value of syndrome
or remainder of division - 0 syndrome - V (x) was a valid code, otherwise,
V (x) is invalid
21Decoding
22Example
- Code word should be 1010001
- Error caused it to be 1011001
23Decoding Circuit With Generator Polynomial G(x)
24Decoding Process With Erroneous Information
25Main Disadvantage of Cyclic Codes
- Not separable
- Possible to create a separable cyclic code
(Nelson Carrole) - n -- bits in complete code
- k -- original data bits
- Generate an (n,k) code
- Multiply D (x) by xn-k, divide result by G (x)
to give R (x)
26Berger Codes
- Append check bits to each information word -
separable - Berger code of length n has
- I information bits
- k check bits
27Berger Code Creation
- Create binary having ones in I bits
- Complement and append to I bits
28Number of Required Check Bits in a Berger Code
29Berger Code Words for 4-bit Information Words
30Horizontal Vertical Parity
- 0001 0
- 1001 1
- 1010 1
- 1111 1
- 0010 0 Extra Vertical Parity
- Extra Horizontal Parity Bit
31Detects Any Single Error
- Can correct it too, because you know the location
of the error - Cannot help for multiple errors - can detect
them but not correct them. If rows (i j) and
columns (k m) have incorrect parity, error
could be in bit positions (i,k), (i,m), (j,k), or
(j,m)
32Hamming Error Correcting Codes (ECCs)
- Most common extension to Parity
- Inexpensive
- Only 10-40 redundancy
- Efficient - correction is fast
- Small time delays for encoding and decoding
- ECC circuit available on cheap chips
- Memory constitutes 60-70 of digital system
faults transient faults more common as memories
get denser
33Overlapping Parity
- Use c parity check bits to protect k bits of
information - 2c gt ck1
- Code word length nck
- Partition information into parity groups - set a
parity bit for each group
34Example
- Information bits (d3,d2,d1,d0)
- Check bits (c1,c2,c3)
- Parity Groups (d3,d1,d0,c1),
- (d3,d2,d0,c2), (d3,d2,d1,c3)
- Each check bit set for parity (even or odd) of
its group
35Check Bits Affected by Single Data Bit Errors
36Check Bits Are Syndrome
- Check bits affected for each possible erroneous
bit - Each bit error effect is unique -
- Erroneous bit can be located
37Process
- Encode original data - generate Cg parity check
bits - Transmit information and Cg bits
- Regenerate encoding Cc of received information
bits - If CcCg, information is correct
38Process (contd.)
- Otherwise
- Obtain syndrome S Cg Cc
- Number bits right to left and place information
/check bits so that syndrome gives erroneous bit
position number - Feed syndrome to controlled complementation unit
- complements erroneous bit to correct word
39Syndromes for Each Possible Single-Bit Error
40Syndrome Generator Hardware
41Controlled Complementer (Corrects Wrong Bits)
- Syndrome determines which bit (if an error
occurs) is complemented
Corrected bits
42Hamming Single-error Correcting Code Memory
43Practical Hamming Code Systems
- Keep a log of correction quantities so that
defective memory chips can be replaced - Hamming code - erroneously corrects double-bit
errors - If both d0 and c2 are wrong, syndrome is 100
which says that c1 should be corrected (not right)
44Modified Hamming Code
- Need to modify code to both correct single-bit
errors and detect double-bit errors - Add another parity bit over the entire Hamming
Code word (including check bits)
45Modified Code Double-error Detection
Correction
46Single-bit and Double-bit Errors
- Single-bit error - syndrome says how to correct
it, overall parity is wrong - Double-bit error - overall parity is correct but
non-zero syndrome occurs. Treat as an error but
avoid erroneous correction
47Commercial ECC IC
48Time Overheads of Hamming Codes
- Extra write time - time to generate check bits
- Extra error detection time - 52 ns
- Correction detection time - 67 ns
49Code Selection Issues
- Must it be separable?
- How much extra time, storage, circuitry can be
tolerated? - How many bit errors can be detected/corrected?
- Can encoding/decoding occur in parallel with
transmission/reception (yes for cyclic codes)
50Code Selection Issues (contd.)
- Do we need error detection, error correction, or
both? - bit errors that need to be detected/corrected?
- Determines Hamming distance Hd
51Summary
- Hamming code error detection/correction now
necessary on present-day semiconductor memory - Memory contributes 60-70 of digital system
faults - Transient faults more common as memories get
denser - Lack of EEC on memory in cheap PCs is a major
source of their unreliability