Module 3 Information Redundancy
Module 3 Information Redundancy
NETWORKS
Sy-Yen Kuo
郭斯彥
NTUEE 1 KUO
Introduction - Information Redundancy
Add information to data to tolerate faults
‒ Error detecting codes
‒ Error correcting codes
Applications
‒ communication
‒ memory
Coding: Representation of information
‒ Sequence of code words or symbols
Redundancy of Information
‒ Shannon’s theorem of 1948
NTUEE 2 KUO
Richard Hamming
“Why do so few scientists make
significant contributions and so
many are forgotten in the long
run?”
NTUEE 4 KUO
Motivation and Background (contd.)
NTUEE 5 KUO
Motivation and Background (contd.)
Theoretical Foundation
‒ Linear and modern algebra
» Concept of groups, fields, and vector spaces
» We will focus on binary codes but will have to include
polynomial algebra
Theory – Informal definitions and results
‒ Vector: A collection of bits represented as a string
‒ Information bits - collection of k-bits
‒ Code word: encoded information bit string
» k information bits encoded to n bits. Encoded information
word is a code word.
‒ Check bits: r (= n-k) extra bits used to encode
information bits
NTUEE 6 KUO
Motivation and Background (contd.)
A field Z2 is the set { 0,1} together with two operations
of addition and multiplication (modulo 2) satisfying a
given set of properties
A vector space Vn over a field Z2 is a subset of {0, 1}n,
with two operations of addition and multiplication
(modulo 2) satisfying a given set of properties
A subspace is a subset of a vector space which is
itself a vector space
A set of vectors {v0,…,vk-1 } is linearly independent if
a0v0 + a1v1 + …+ ak-1vk-1 = 0 implies a0 = a1= …= ak-1 =
0
NTUEE 7 KUO
Code
Code of length n is a set of n-tuples
satisfying some well-defined set rules
binary code uses only 0 and 1 symbols
‒ binary coded decimal (BCD) code
» uses 4 bits for each decimal digit
NTUEE 8 KUO
Codeword
Codeword is an element of the code
satisfying the rules of the code
Word is an n-tuple not satisfying the rules of
the code
n
Codewords should be a subset of all 2
possible binary tuples to make error
detection/correction possible
‒ BCD: 0110 valid; 1110 invalid
‒ any binary code: 2015 invalid
The number of codewords in a code C is
called the size of C
NTUEE 9 KUO
Encoding/decoding
NTUEE 10 KUO
Error detection
We can define a code so that errors
introduced in a codeword force it to lie
outside the range of codewords
‒ basic principle of error detection
NTUEE 11 KUO
Error correction
We can define a code so that it is possible
to determine the correct codeword from
the erroneous codeword
‒ basic principle of error correction
NTUEE 12 KUO
Error-detecting Codes
A fault is a physical malfunction
An error is an incorrect output caused by fault
Output of circuit may be encoded so that output takes a
subset of possible values during normal (fault-free)
operation
Formally, a code is a subset S of an universes U of
vectors chosen
A noncode word is a vector in set U-S
If X is a code word and X’ is a different vector produced
by a fault, then X’ is a detectable error if X’ ∈ U-S and
undetectable error if X’ ∈ S
NTUEE 13 KUO
Error-detecting Codes (Cont.)
Example
Assume a code word has 8 bits, so U = 28 vectors
X 1 → X 3 Undetectable error
X 2 → X 4 Detectable error
U
S X1
failure X3
failure X2
X4
code words : X 1 , X 2 , X 3 detectable error : X 2 → X 4
noncode word : X 4 undetectable error : X 1 → X 3
NTUEE 14 KUO
Fault Detection through Encoding
At logic level, codes provide means of masking
or detection of errors
Example
X1 is a code word
<10010011>
Due to multiple bit errors,
becomes X3=<10011100> U = 28 vectors
⇒ not detectable
X2 is a code word S=even parity
X2 X1
becomes X4 noncode
word X3
⇒ detectable X4
NTUEE 15 KUO
Basic Code Operations
NTUEE 16 KUO
Parity Codes - Example
Odd and even parity codes for BCD data
Decimal BCD BCD
Digit BCD odd parity even parity
0 0000 00001 00000 Parity Parity Parity Error
1 0001 00100 00011 Generator Bit Checking Signal
2 0010 00100 00101
3 0011 00111 00110 Data Parity Data
4 0100 01000 01001
5 0101 01011 01010 Memory
6 0110 01101 01100 ~ ~ Data In ~ ~ Data Out
7 0111 01110 01111
8 1000 10000 10001 Organization of a memory that uses single-
bit parity.
9 1001 10011 10010
The parity bit is generated when data is
parity bit written to memory and checked when data is
ready.
NTUEE 17 KUO
XOR Tree for Parity Generation
Data Bits
d0
d1
d2
Generated Parity Bit
d3
P Error Signal
NTUEE 18 KUO
Block Codes
Block code: each code word contains the same number
of bits.
Code words are represented by n-tuples or n-vectors
‒ Information is only k bits
‒ Redundancy normalization (n-k)/n or r/n
‒ It is called (n, k) code
Binary Code
‒ By far most important
‒ lend itself to mathematical treatment
Encoding: converting source codes into block codes
Decoding: Inverse operation of encoding
Error detection (EDC) and Error correction (ECC) codes
NTUEE 19 KUO
Functional Classes of Codes
Single error correcting codes
‒ any one bit can be detected and corrected
Burst error correcting codes
‒ Any set of consecutive b bits can be corrected
Independent error correcting codes
‒ Up to t errors can be detected and corrected
Multiple character correcting codes
‒ n-characters, t of them are wrong, can be recovered
Coding complexity goes up with number of errors
Sometimes partial correction is sufficient
NTUEE 20 KUO
Information Redundancy - Coding
A data word with k bits is encoded into a codeword with
n bits – n > k
‒ Not all 2n combinations are valid codewords
‒ To extract original data - n bits must be decoded
‒ If the n bits do not constitute a valid codeword, an error is
detected
‒ For certain encoding schemes, some types of errors can also be
corrected
Key parameters of code:
‒ number of erroneous bits that can be detected
‒ number of erroneous bits that can be corrected
Overhead of code:
‒ additional bits required
‒ time to encode and decode
NTUEE 21 KUO
Error detecting/correcting code
NTUEE 22 KUO
Hamming distance
Hamming distance is the number of bit
positions in which two n-tuples differ
NTUEE 23 KUO
Hamming Distance
NTUEE 24 KUO
Hamming Distance - Examples
NTUEE 25 KUO
Hamming Distance
Theory – Informal definitions and results
‒ Hamming weight of a vector v: Number of 1’s in v
‒ Hamming distance (HD) between a pair of vectors v1
and v2: number of places two vectors differ from each
other.
HD(v1, v2) = HW(v1⊕v2)
‒ Code: Collection of code words.
‒ Block code: each code word contains same number of
bits.
‒ Minimum Hamming distance of a code: Minimum of all
HDs between all pairs of code words in a code.
‒ Error detection: Erroneous word (a code word with one
or more bit errors) is not a code word
NTUEE 26 KUO
Distance Property of Codes
Weight of an n-tuple: # of 1s in the tuple
‒ W(1011) = 3
‒ Computing Weight W ( X ⊕ Y ) = W ( X ) + W (Y ) − 2W ( X • Y )
Hamming Distance
‒ Number of places two words differ
‒ For X, Y, d ( X , Y ) = W ( X ⊕ Y )
‒ d(X,Y)=0 for X=Y and d(X,Y) <= d(X,Z)+d(Z,Y)
# of words at distance d from a word = nCd
# of words at distance up to d , W = ∑ (in )
d
i =0
Min distance d of a code = minimum over all pairs
NTUEE 27 KUO
Distance of a Code
The Distance of a code -
the minimum Hamming distance
between any two valid codewords
Example - Code with four codewords -
{001,010,100,111}
‒ has a distance of 2
‒ can detect any single bit error
Example - Code with two codewords - {000,111}
‒ has a distance of 3
‒ can detect any single or double bit error
‒ if double bit errors are not likely to happen - code
can correct any single bit error
NTUEE 28 KUO
Distance Properties of Parity Codes
Definition: The minimum distance of a code S is the
minimum of Hamming distances between all pairs of
code words e.g., Fragment of distance 5(double
error correcting code)
Correctable
double error 0100100 0110100
0000100
0110110
Improperly
0000000 Correctable corrected
triple error 0110111
single error
NTUEE 29 KUO
Distance Property of Codes
Basic results 1: A code is capable of t error detection if
and only if min HD of the code is at least t+1.
‒ Example: Use of parity – we know that we can detect single error.
What is the minimum HD for such a code?
Basic results 2: A code is capable of correcting t errors if
and only if min HD of the code is at least 2t+1.
Combine the two results:
1. Thus a code with minimum Hamming distance d between its
codewords can detect at most d-1 errors or can correct ⌊(d-1)/2⌋
errors
2. Or to correct all patterns of Hamming distance c and detect up
to d additional errors
» code distance must be ≥ 2c + d + 1
» E.g., code with distance 4 can correct 1 single-bit error and detect 1
additional error or detect at most 3 errors
NTUEE 30 KUO
Coding vs. Redundancy
NTUEE 31 KUO
Separability of a Code
A code is separable if it has separate fields for
the data and the code bits
‒ codeword = data + check bits
‒ e.g. parity: 11011 = 1101 + 1
Decoding is easy by disregarding the code bits
The code bits can be processed separately to
verify the correctness of the data
A non-separable code has the data and code
bits integrated together - extracting the data
from the encoded word requires some
processing
NTUEE 32 KUO
Parity Codes
Thesimplest separable codes are the parity
codes
A parity-coded word includes d data bits and
an extra bit which holds the parity
In
even (odd) parity code - the extra bit is set
so that the total number of 1's in the (d+1)-bit
word (including the parity bit) is even (odd)
The overhead fraction of this parity code is
1/d
Use: bus, memory, transmission, …
NTUEE 33 KUO
Organization of memory with single-bit
parity code
NTUEE 34 KUO
Properties of Parity Codes
NTUEE 35 KUO
Encoding and Decoding Circuitry for
Parity Codes
The encoder: a
modulo-2 adder - encoder
generating a 0 if the
number of 1's is even
The output is the parity
signal
decoder
NTUEE 36 KUO
Parity Codes - Decoder
The decoder generates the parity from the
received data bits and compares it with the
received parity bit
If they match, the output of the exclusive-or gate
is a 0 - indicating no error has been detected
If they do not match - the output is 1, indicating
an error
Double-bit errors can not be detected by a parity
check
All three-bit errors will be detected
NTUEE 37 KUO
Even or Odd Parity?
The decision depends on which type of all-bits
error is more probable
For even parity - the parity bit for the all 0's
data word will be 0 and an all-0’s failure will
go undetected - it is a valid codeword
Selecting the odd parity code will allow the
detection of the all-0's failure
If all-1's failure is more likely - the odd parity
code must be selected if the total number of
bits (d+1) is even, and the even parity if d+1 is
odd
NTUEE 38 KUO
Codes for RAMs
Thepurpose is to provide additional error
capability
NTUEE 39 KUO
Parity Bit Per Byte
NTUEE 40 KUO
Byte-Interlaced Parity Code
Example: d=64, data bits - a63,a62,…,a0
Eight parity bits:
‒ First - parity bit of a63,a55,a47,a39,a31,a23,a15,a7 -
the most significant bits in the eight bytes
‒ Remaining seven parity bits - assigned so that the
corresponding groups of bits are interlaced
Scheme is beneficial when shorting of adjacent
bits is a common failure mode (example - a bus)
If parity type (odd or even) is alternated between
groups - unidirectional errors (all-0's or all-1's)
will also be detected
NTUEE 41 KUO
Parity Codes for Memory - Comparison
NTUEE 42 KUO
Overlapping Error-Correcting Parity Codes
Simplest scheme - data is organized
in a 2-dimensional array
NTUEE 44 KUO
Error Correction with Overlapped Parity
3 2 1 0 P2 P1 P0
1 3 0 2 0 3 1 2 3
Parity Generator Parity Generator Parity Generator
C0
Pr 1 Bit 0
Corrected Bits
Pr 0 P r2
Bit 0
C3 Correct Bit 3 C1
Pr 0 C2 Correct Bit 2 Bit 1
3-8 Bit 1
P0 C1 Correct Bit 1 C2
Pr1 Decode CP2 Correct Bit P2 Bit 2
C0 Correct Bit 0 Bit 2
P1
CP1 Correct Bit P1 ...
Pr 2 CP0 Correct Bit P0 CP 2
P2 E No Error Bit P2
Bit P2
NTUEE 45 KUO
Overlapping parity code (Hamming code)
Purpose - identify every single erroneous bit
k data bits and c parity bits - total of k+c bits
Assuming single-bit errors - k+c error states + one no-
error state - total of k+c+1 states
We need k+c+1 distinct parity ‘’signatures” (bit
configurations) to distinguish among the states
c parity checks generate parity signatures
Hence, c is the smallest integer that satisfies
2c ≥ k+c+1
Question - how are the parity
bits assigned?
NTUEE 46 KUO
Single Error Correction and Double Error
Detection Hamming Code (SEC-DED)
1 2 3 4 5 6 7 8
Consider a data word consisting of four
p1 p2 d0 p3 d1 d2 d3 p4
information bits
1 1 1 1 1 1 1 1
Three parity bits are needed to provide
single error correction
1 0 1 0 1 0 1 0 Adding an extra parity bit, the Hamming
code can be used to correct single bit
0 1 1 0 0 1 1 0
errors and to detect double errors
0 0 0 1 1 1 1 0
Check bits computation
P1 = XOR (3, 5, 7)
c1 c2 c3 c4
P2 = XOR (3, 6, 7)
P3 = XOR (5, 6, 7)
0 0 0 0 No errors P4 = even parity over the
first 7 bits of the code word
x3 x2 x1 1 Single error in a position
(x1x2x3) Syndromes computation
y3 y2 y1 0 C1 = XOR (1, 3, 5, 7)
Double error C2 = XOR (2, 3, 6, 7)
0 0 0 1 C3 = XOR (4, 5, 6, 7)
Error in bit p4
C4 = parity over all 8 bits of
the code word
NTUEE 47 KUO
Single Error Correction and Double Error
Detection Hamming Code (SEC-DED) Example
1 2 3 4 5 6 7 8
p1 p2 d0 p3 d1 d2 d3 p4
Initial daa
1 1 1 0 0 1 1 0 0
d0 d1 d2 d3
0 1 1 0
2 1 1 1 0 1 1 0 0
Failure
3 1 1 0 0 1 0 0 0
scenarios
4 0 1 0 0 0 1 0 0
5 1 1 0 0 1 1 0 1
c1 c2 c3 c4
1 0 0 0 0 No errors
Corresponding 2 1 1 0 1 Single error in position 3
Syndromes
3 0 1 1 1 Single error in position 6
4 0 0 1 0 Double error
5 0 0 0 1
Error in bit p4
NTUEE 48 KUO
Linear code: Definition
NTUEE 49 KUO
Example: (4,2) linear code
Data to be encoded are 2-bit words
[00], [01], [10], [11]
Suppose we select for a basis the vectors
v0 = [1000], v1 = [0110]
To find the codeword c = [c0c1c2c3]
corresponding to the data d = [d0d1], we
compute the linear combination of the basic
vectors as
c = d0 v 0 + d 1 v 1
For example, data d = [11] is encoded to
c = 1 · [1000] + 1 · [0110] = [1110]
NTUEE 50 KUO
Example (cont.)
d = [00] is encoded to
‒ c = 0 · [1000] + 0 · [0110] = [0000]
d = [01] is encoded to
‒ c = 0 · [1000] + 1 · [0110] = [0110]
d = [10] is encoded to
‒ c = 1 · [1000] + 0 · [0110] = [1000]
NTUEE 51 KUO
Generator matrix
The rows of the generator matrix are the basis
vectors v0,…,vk-1
For example, generator matrix for the previous
example is
1000
G=
0110
NTUEE 52 KUO
Example: (6,3) linear code
100011
G= 010110
001101
NTUEE 53 KUO
Parity check matrix
• If G is of the form
100 011
G= 010 110
001 101
• Then H is of the form
011100
H= 110010
101001
NTUEE 55 KUO
Assigning Parity Bits - Example
k=4 data bits
c=3 - minimum number of parity bits
k+c+1=8 – number of states the word can be in
A possible assignment of parity values to states
In (a3 a2 a1 a0 p2 p1 p0), bit 0, 1 and 2 are parity bits,
the rest are data bits
NTUEE 56 KUO
(7,4) Hamming Single Error
Correcting (SEC) Code
NTUEE 57 KUO
Definition - Syndrome p 0 = a 0⊕ a 1⊕ a 3
p 1 = a 0⊕ a 2⊕ a 3
p 2 = a 1⊕ a 2⊕ a 3
Example: a3a2a1a0 = 1100 and p2p1p0 = 001
Suppose 1100001 becomes 1000001
Recalculate p2p1p0 = 111
Difference (bit-wise XOR) is 110
This difference is called syndrome - indicates the
bit in error
It is clear that a2 is in error and the correct data is
a3a2a1a0=1100
NTUEE 58 KUO
Calculating the Syndrome - (7,4)
Hamming Code
The syndrome can be calculated directly in one step
from the bits a3 a2 a1 a0 p2 p1 p0
This is best represented by the following matrix
operation where all the additions are mod 2
p 0 = a 0⊕ a 1⊕ a 3
p 1 = a 0⊕ a 2⊕ a 3
Parity check
matrix p 2 = a 1⊕ a 2⊕ a 3
NTUEE 59 KUO
Syndrome
NTUEE 60 KUO
Constructing linear codes
To be able to correct e errors, a code should
have a distance of at least 2e+1
It is proved that a code has distance of at
least d if and only if every subset of d-1
columns of its parity check matrix H are
linearly independent.
So, to have a code distance two, we must
ensure that every column of the parity check
matrix is linearly independent
– To have a code with code distance 2 (single- error
detecting), every column of H should be linearly
independent, i.e. H shouldn’t have a zero column
NTUEE 61 KUO
Example: (4,2) linear code
0110
H=
0001
NTUEE 62 KUO
Example: (4,2) linear code, Cd=2
NTUEE 63 KUO
Example: (4,2) linear code, Cd=2
NTUEE 64 KUO
Hamming codes
Hamming codes are a family of linear codes
An (n, k) linear code is a Hamming code if
its parity check matrix contains 2n−k −1
columns representing all possible nonzero
binary vectors of length n − k.
Example: (7,4) Hamming code
NTUEE 65 KUO
Parity check matrix
If the columns of H are permuted, the resulting
code remains a Hamming code
Example: different (7,4) Hamming code
0001111
H= 0110011
1010101
NTUEE 66 KUO
Decoding
NTUEE 67 KUO
Example: (7,4) Hamming code
Construct Hamming code corresponding to parity
check matrix
The corresponding G is
NTUEE 68 KUO
Example (cont.)
Suppose the data to be encoded is d = [1110]
We multiply d by G to get c = [1110001]
Suppose an error has occurred in the last bit of c
‒ c is transformed to [1110000]
By multiplying [1110000] by H, we s = [001]
‒ s matches the last column of H
‒ the error has occurred in the last bit of the codeword
We correct [1110000] to [1110001] and decode it
to d = [1110] by taking the first 4 bits of data
NTUEE 69 KUO
Extended Hamming code
The code distance of a Hamming code is
3, so it can correct single-bit error
Often extended Hamming code is used,
which can correct single-bit error and
detect double-bit errors
–obtained by adding a parity check bit to
every codeword of a Hamming code
– if c = [c1c2…cn] is a codeword of a Hamming
code, c’ = [c0c1c2…cn] is the corresponding
extended codeword, where c0 is the parity bit
NTUEE 70 KUO
Improving Detection
NTUEE 74 KUO
Versions of Checksums
Data words - d bits long
d
Single-precision version - checksum is a modulo 2
addition
Double-precision version - modulo 2 2 d addition
In general - single-precision checksum catches fewer
errors than double-precision
‒ only keeps the rightmost d bits of the sum
Residue checksum takes into account the carry out of the
d-th bit as an end-around carry
‒ somewhat more reliable
The Honeywell checksum concatenates words into pairs
for the checksum calculation (done modulo 2 2 d ) - guards
against errors in the same position
NTUEE 75 KUO
Checksum Codes - Basic Concepts
The checksum is appended to block data when such blocks are
transferred
dn rn
d5 r5
d4 Transfer r4
d3 r3
d2 r2
d1 r1
Checksum on Checksum on
Original Data Received Data
Compare
di = original word of data
ri = received word of data Received Version
of Checksum
NTUEE 76 KUO
Single Precision Checksums
0111
(Addition) +
0001
0110
1000
} Original Data
1 ( 0110 ) Checksum
Carry is Ignored
A single-precision checksum is formed by adding the data words and ignoring any overflow
d3 d2 d1 d0 d3 d2 d1 d0
0111 1111
d0
0001 d1 1001
Transmit d2 Receive
0110 1110
d3
0000 Faulty Line 1000
Always “1”
Checksum Checksum of Received Data
1110 1110
Received Checksum
1110
The single-precision checksum is unable to detect certain types of errors.
The received checksum and the checksum of the received data are equal,
so no error is detected.
NTUEE 77 KUO
Double Precision Checksums
Compute 2n-bit checksum for a block of n-bit words
Overflow is still a concern, but it is now overflow from a 2n-bits
d3 d2 d1 d0 d3 d2 d1 d0
0111 1111
d0
d1
0001 Transmit Receive 1001
d2
0110 d3 1110
NTUEE 78 KUO
Honeywell Checksums
Concatenate consecutive words to form double words to
create k/2 words of 2n bits; checksum formed over newly
structured data Transmit Receive
d0
Word n d1
Received Data
Original Data d3 d2 d1 d0
d3 d2 d1 d0 d2
1111
Word 3 0111
d3
Word 2 1001
0001
Word 1 1110
0110 Faulty Line
1000
Always “1”
0000
Word n - 1 Word n
1001 1111
Word 9 Word 10 0001 0111
1000 1110
0000 0110
Word 7 Word 8
Word 5 Word 6
Checksum of Received Data
Word 3 Word 4 Checksum of Original Data
0010 1101
Word 1 Word 2 0001 1101
Received Checksum
10 0 1 1101
Checksum
NTUEE 79 KUO
Residue Checksums
The same concept as the single-precision checksum except that the
carry bit is not ignored and is added to checksum in an end-around
carry fashion
Transmit Receive
Original Data d0
d3 d2 d1 d0
d1
Word n 0111
0001 d2
0110 d3
Word 4 Received Data
Word 3 0000 d3 d2 d1 d0
Word 2 Faulty Line 1111
Word 1 Checksum of Original Data Always “1”
1001
Carry 1110
from 1110
Addition 1000
c Sum of Data
End-Around 1110
Carry Three Carries
c
Addition Generated During 1
End-Around 1
1
Carry Addition
Checksum of Received Data
Checksum
0001
Received Checksum
1110
NTUEE 80 KUO
Comparing the Versions
NTUEE 81 KUO
Comparison - Example
NTUEE 83 KUO
Unidirectional error detection
Theorem: A code C detects all unidirectional
errors if and only if every pair of codewords
in C is unordered
two binary n-tuples x and y are ordered if
either xi ≤ yi or xi ≥ yi for all i ∈ {1,2,...,n}
NTUEE 84 KUO
Unidirectional error detection
A unidirectional error always changes a
word x to a word y which is either smaller
or greater than x
Aunidirectional error cannot change x to a
word which is not ordered with x
Therefore,if any pair of codewords are
unordered, a unidirectional error will never
transform a codeword to another
codeword
NTUEE 85 KUO
Unidirectional Error Model
Given a bit string= ( X 1 X 2 X 3 ... X n ), X i = {0, 1}
Under error, either some 0->1 or 1->0, but not both at the
same time
E.g., if you know that s-a-0 faults are the only faults that
can occur:
0
1
Transmission
1 s-a-0
lines
1
1 s-a-0
NTUEE 86 KUO
Berger Codes
NTUEE 87 KUO
Berger Code Error Detection
NTUEE 89 KUO
Overhead of Berger Code
2
d data bits - at most d 0s - up to log ( d + 1)
bits to describe
Overhead = log 2 (d + 1) d
r - number of check bits
If d = 2 − 1 (integer k)
k
‒ r=k
‒ maximum-length Berger
code
Smallest number of check bits
out of all separable codes (for
unidirectional error detection)
NTUEE 90 KUO
Cyclic codes
NTUEE 91 KUO
Cyclic Codes
Cyclic codes are parity check codes with additional
property that cyclic shift of a codeword also a codeword
If (Cn -1 , Cn−1...C1 , C0 ) is a codeword, (Cn -2 , Cn −3 ,...C0 , Cn −1 ) is also
a codeword
Parity check codes require complex encoding, decoding
circuit using arrays of EX-OR gates, AND gates, etc.
Cyclic codes require far less hardware, in form of linear
feedback shift registers
Cyclic codes are used in sequential storage devices, e.g.
tapes, disks, and data links
An (n,k) cyclic code can detect single bit errors, and
multiple adjacent bit error affecting fewer than (n-k) bits,
burst transient errors (typical for communication
applications)
NTUEE 92 KUO
Cyclic code and Polynomials
NTUEE 93 KUO
Cyclic And Polynomial Algebra
Definition: A cyclic code is a parity check code,
where every cyclic shift of a code word is a
codeword E.g. if (Cn −1 , Cn −2 ,..., C0 ) is a code word,
then (Cn −2 , Cn −3 ,..., C0 , Cn −1 ) is also a code word
Cyclic
codes are conveniently described as
polynomials
Cn −1 x n −1 + Cn −2 x n −2 + ...C1 x + C0
Use key concept of polynomial division using
Euclidean division algorithm: f(X)=q(X)p(X)+r(X),
degree(r(X))<degree(P(X)) q=quotient and
r=remainder
NTUEE 94 KUO
Cyclic And Polynomial Algebra(Cont.)
Most important modulo base polynomial
for cyclic codes is X n − 1 since
1 = X n [mod( X n − 1)]
Now we have
XC ( X ) = Cn −1 X n + Cn − 2 X n −1 + ... + C1 X 2 + C0 X
XC ( X ) mod ( X n − 1) = Cn − 2 X n −1 + ... + C0 X + Cn −1
NTUEE 95 KUO
Basic Operations on Polynomials
Can multiply or divide one polynomial by another, follow
modulo 2 arithmetic, coefficients are 1 or 0, and addition
and subtraction are same
x7 + x6 + x5 + x3
Multiplication ( x 4 + x3 + x 2 + 1)( x3 + x) + x5 + x 4 + x3 + x
= x7 + x6 + x4 + x
Division
x Quotient
( x + x + x + 1)
4 3 2 x5 + x 4
x5 + x 4 + x3 + x
x3 + x Remainder
NTUEE 96 KUO
Properties of Generator Polynomials
g(x)is unique lowest degree nonzero
polynomial with degree n-k
Every code polynomial is some multiple of g(x)
g(x)is a factor of x n-1, I.e., it divides it with
zero remainder
If polynomial with degree n-k divides
n
x -1, then g(x) generated cyclic code
NTUEE 97 KUO
Cyclic Code - Example
3
x
Consider generator polynomial g(x)= + x+1 for (7,4)
code
Can verify g(x) divides x7 −1
Given data word (1111), generate codeword
d(x)= x 3 + x 2 + x + 1
Then c( x) = g ( x)d ( x) = ( x 3 + x 2 + x + 1)( x 3 + x + 1) = x 6 + x 5 + x + 1
Hence code word is (1101001)
NTUEE 98 KUO
Properties of Cyclic Codes:(n,k) Codes(Cont.)
as polynomials as 7-tuples
g(X)= X + X + 1
3
0001011
Xg(X)= X + X + X
4 2
0010110
X 2g( X ) = X 5 + X 3 + X 2 0101100
X 3g( X ) = X 6 + X 4 + X 3 1011000
NTUEE 99 KUO
Encoding/decoding
d(x) = (1101) = x3 + x2 + 1
g(x) = x3 + x + 1
c(x) = d(x).g(x) = x6 + x5 + x4 + x3 + x2 + x + 1
‒ Codeword 01100
‒ Same codewords generated but different correspondence
NTUEE 103 KUO
Example of Separable Cyclic Code
Generator polynomial g(x) = x4 + x3 + x2 + 1 of (7,3) code
Data is 3 bits, n-k = 4 bits
s0 =s2+c(x)
s1 =s0+ s2
s2 =s1
d(x)=s2
c(x) s0 s1 s2 d(x)
t0 0 0 0
t1 1 1 0 0 0
t2 0 0 1 0 0
t3 0 0 0 1 0
t4 1 0 1 0 1
t5 1 1 0 1 0
t6 0 1 0 0 1 The syndrome [110] matches
t7 1 1 1 0 0 the 4th column of the check
matrix H.
AX
A(X + MY)
+M
AY
Residue
Mod A
Adder
X
+ X+Y
residue residue [(X + Y) mod A]
(X mod A) Residue
Generator
(mod-A)
Y
residue +A Equality Error
(Y mod A) Modulo-A checker
Adder