EE6309 Week#1-2 Data Coding Wide
EE6309 Week#1-2 Data Coding Wide
http://sites.google.com/view/tonykim
thkim@ntu.edu.sg
1
Instructor
• Name: KIM, Tae Hyoung (Tony)
• Email: thkim@ntu.edu.sg
2
Moore’s Law
3
History of the Transistor
First IC:
Jack Kilby
(1958, TI)
4
Transistor Scaling
Source: www.intel.com
5
Constant Field Scaling
• To mitigate aggravated short-channel effects
6
Constant Voltage Scaling
• To achieve higher clock speed
7
Constant Voltage Scaling
• More aggressive scaling than constant field
• Limitations
– Reliability problems due to high field
– Power density increases too fast
8
History of CPU: 4004
• First microprocessor (1971)
- For Busicom calculator
• Characteristics
- 10 m process
- 2300 transistors
- 400 – 800 kHz
- 4-bit word size
- 16-pin DIP package
• Masks hand cut from Rubylith
- Drawn with color pencils
- 1 metal, 1 poly (jumpers)
- Diagonal lines (!)
Source: www.intel.com
9
History of CPU: Pentium 4
• Deep pipeline (2001)
– Very fast clock
– 256-1024 KB L2$
• Characteristics
– 180 – 65 nm process
– 42-125M transistors
– 1.4-3.4 GHz
– Up to 160 W
– 32/64-bit word size
– 478-pin PGA
• Units start to become
invisible on this scale
Source: www.intel.com
10
History of CPU: Pentium M
• Pentium III derivative
– Better power efficiency
– 1-2 MB L2$
• Characteristics
– 130 – 90 nm process
– 140M transistors
– 0.9-2.3 GHz
– 6-25 W
– 32-bit word size
– 478-pin PGA
• Cache dominates chip area
Source: www.intel.com
11
History of CPU: Core i7
• Quad core (& more)
– Pentium-style architecture
– 2 MB L3$ / core
• Characteristics
– 45-32 nm process
– 731M transistors
– 2.66-3.33+ GHz
– Up to 130 W
– 32/64 bit word size
– 1366-pin LGA
– Multithreading
• On-die memory controller
Source: www.intel.com
12
Course Topics
PART #1
1. DATA CODING
2. NOISE IN DIGITAL SYSTEMS
3. FAULT MODELS
4. FAULT SIMULATION
PART #2
5. SYNCHRONIZATION
6. PARALLEL PROCESSING
7. MEMORY MANAGEMENT
13
EE 4340: Topic #1
DATA CODING
http://sites.google.com/view/tonykim
thkim@ntu.edu.sg
14
Data Coding
Objective: To avoid errors during digital signal
transmission from a source to a destination
•Sources of Transmission Error
– Noisy channel
– Component failure
– Power interruption
•Types of Error
– Single-bit error
– Multi-bit error (or Burst error)
•Reference
– ‘Understanding Data Communication and Networks, PWS,
William A. Shay
15
Data Coding
• Data Coding
– Error Detection Coding
– Error Correction Coding
– Data Encryption and Decryption (will not be covered.)
16
Data Coding
• Description
– Adding extra check bit(s) to the original data bits
– Forming a set of valid code-word for the purpose of error
detection and correction
– An invalid code-word received indicates the existence of
error bit(s)
• Error Detection
– The process of detecting an invalid code-word
– Parity checking, Cyclic redundancy checking
• Error Correction
– The process of restoring the corrupted bit(s) of an invalid
code-word
– Hamming codes
17
Self-Checking
• Self-checking: the capability to verify automatically
whether there is any fault without the need of externally
applied test stimuli
• Self-checking design can be achieved by using error-
detecting codes
– During normal fault-free operation, the logic network receives only
a subset of input code & produces a subset of output code – valid
code word
– A non-code word indicates the presence of a fault
– A fault may also result in an (incorrect) code word, rather than a
non-code word – undetectable fault
18
Totally Self-Checking Circuit
• Fault-Secure circuit: For any fault from a given set of faults,
the circuit never produces an incorrect code word
• Self-Testing circuit: For every fault from a given set of faults,
the circuit produces a non-code word at the output for at
least one input code word
• A circuit is totally self-checking if it is both fault-secure &
self-testing: during normal operation all faults from a given
set would cause a detectable, erroneous output
19
Totally Self-Checking Circuit
• Temporary faults and permanent faults are
detected
• Faults are immediately detected upon occurrence
Checker checks
the validity of the output
code words
20
Example
• Totally self-checking checker has 2 outputs and
hence, 4 output combinations. Two of these output
combinations are considered as valid (01,10). A
non-valid output, 00 or 11 indicates either a non-
code word at the input or a fault in the checker
itself.
21
Two-Rail Checker
• Two groups of inputs: (x1,x2,…,xn) & (y1,y2,…,yn)
• Two outputs: f & g
• The signals observed at f & g should always be
complementary if and only if every pair xi, yi is
complementary for all i (1≤i ≤n)
f = x0y0 + x1y0
g = x0x1 + y0y1
22
Two-Rail Checker
23
Multi-Level Tree Checker
• A two-rail checker for an arbitrary number of input
pairs may be designed using two-level AND-OR
logic
• A tree checker realized by interconnecting the
checker modules with two input pairs is more
efficient
• A general multi-level tree checker with m input
pairs formed by interconnecting two-rail checker
modules, requires (m-1) modules and log2m
module levels
24
Example
• A tree checker with m=6, formed by
interconnecting two-rail checker modules
• No. of checker modules required m-1=6-1=5
• No. of Levels required log2m= log26≈3
25
Parity Checking
• Most common technique for single-bit error
detection
26
Parity Checking
• Calculation
– For an n-bit data string ( bn-1 bn-2 ..... b2 b1 b0 ), the parity
bits for the Even and Odd Parity Checks are defined as:
PEVEN = bn-1 bn-2 ..... b2 b1 b0
• Example
Data Bits Parity Bit
11010100 0 Even Parity
11010100 1 Odd Parity
27
BCD Codes with Parity Bits
Decimal No. BCD BCD with EP BCD with OP
0 0000 0000 0 0000 1
1 0001 0001 1 0001 0
2 0010 0010 1 0010 0
3 0011 0011 0 0011 1
4 0100 0100 1 0100 0
5 0101 0101 0 0101 1
6 0110 0110 0 0110 1
7 0111 0111 1 0111 0
8 1000 1000 1 1000 0
9 1001 1001 0 1001 1
28
Error Detection
• Transmitter
– The parity bit is sent together with the data bits (forming
the code-word)
• Receiver
– An error signal (E) is generated from the code-word
received, which is defined as:
EEVEN = bn-1 bn-2 ..... b2 b1 b0 PEVEN
if E = 0: No error
E = 1: Error
29
Hardware Implementation
• Even Parity + 4-bit Data
1 0 0 0 1 0 0 1 1
1 0 1 1
0
1
- Generator -
1
• Exercise: Odd Parity? - Detector-
30
Hardware Implementation
• Serial Data Transmission
– Calculate parity bit using the transmitted bits
– Minimum delay for parity bit generation
31
Pros and Cons of Parity Checking
• Wide Usage in Computer Systems
– Each bit travels through different paths
– One faulty path will be detected
• Ability to Detect Any Single-bit Error
– In fact, able to detect all odd number of bit errors
32
2-D Parity Checks
• Block Check Codes
– Form data in 2-D code-words
– Generate both row and column parity bits (Transmitter)
– Execute both row and column parity checks (Receiver)
– Position of a single-bit error can be identified
– Single-bit error can be corrected
– Position of multi-bit errors cannot be identified
– Multi-bit errors can be detected
– Assembling and disassembling of data block is required
33
2-D Parity Checks: Example
• Transmitter Row Parity Bits
1st 0 1 1 0 0
2nd 1 1 0 0 0
3rd 1 1 1 0 1
4th 0 0 0 0 0
0 1 0 0 X
34
2-D Parity Checks: Example
• Receiver Row Error Bits
1st 0 1 1 0 0 0
2nd 1 1 0 0 0 0
3rd 1 1 0 0 1 1
4th 0 0 0 0 0 0
0 1 0 0 X
0 0 1 0
1st 0 1 1 0 0 ?
2nd 1 1 1 0 0 ?
3rd 1 1 0 0 1 ?
4th 0 0 0 0 0 ?
0 1 0 0 X
? ? ? ?
1st 0 1 1 0 0 0
2nd 1 1 1 0 0 1
3rd 1 1 0 0 1 1
4th 0 0 0 0 0 0
0 1 0 0 X
0 0 0 0
• Hamming Distance
– The smallest number of bit(s) in which any two words differ
in a code
38
Hamming Distance: Example
Min. Distance Error Detect
BCD code 1 No
BCD code w/
2 Single-bit
one parity bit
• Example
– Consider a simple 3-bit code with the minimum distance of
3, where only two valid code-words exist:
1 1 1 (a)
0 0 0 (b)
– After a single error, (a) becomes:
1 1 0 (a)
– Minimum difference is still 2, which can correct the error.
39
Hamming Distance: Practice
• 8-bit Code-word
Hamming Detect
a b c d e f g h
Distance /Correct
A 1 1 1 1 1 1 1 1 X X
B 1 1 1 1 1 0 1 1
BERR 1 1 1 1 1 1 1 1
C 1 1 1 0 1 0 1 1
CERR 1 1 1 1 1 0 1 1
D 1 0 1 0 1 0 1 1
DERR 1 1 1 0 1 0 1 1
E 1 0 1 0 1 0 1 0
EERR 1 1 1 0 1 0 1 1
40
Hamming Distance: Practice
• 8-bit Code-word
Hamming Detect
a b c d e f g h
Distance /Correct
A 1 1 1 1 1 1 1 1 X X
B 1 1 1 1 1 0 1 1 1 X
BERR 1 1 1 1 1 1 1 1
C 1 1 1 0 1 0 1 1 2 1-bit detect
CERR 1 1 1 1 1 0 1 1 d or f?
D 1 0 1 0 1 0 1 1 3 1-bit correct
DERR 1 1 1 0 1 0 1 1 b
E 1 0 1 0 1 0 1 0 4 2-bit detect
EERR 1 1 1 0 1 0 1 1 (b,h) or (d,f)?
41
Hamming Codes
• For an error correction, desirable to detect and
locate error(s)
• HAMMING CODES: one of the commonly used error
correction code
• Creation of special code-words from data string
• Insertion of multiple parity bits in code-word
• Each parity bit checks parity in strategic location
• Overlapping of bits checked
• Combination of parity check failures indicates bit(s)
for correction
42
Hamming Codes: 1-bit Correction
1. To each group of m message bits, k parity bits P1 P2 ... Pk are
added to form an ( m + k ) code
2. Each bit of the code-word is assigned a decimal location
number from 1 to ( m + k ), starting from LSB
3. k parity checks are performed on specific bits of each code-
word
4. The parity checks allow the development of a position binary
number ( bk-1 ... b1 b0 ) , whose value (when an error occurs)
will identify the location of the error
5. The number of k parity bits must be large enough to identify
any one of the possible ( m + k ) single error, and identify “ no
error ” with decimal value zero.
2k m+k+1
6. The parity bits are placed in positions 1, 2, 4 ... 2 k-1 of the
code-word
43
1-bit Correction: Example
• BCD code ( m = 4 ) using Even parity checks
k = 3 since 2 3 4 + 3 + 1
• Parity bit positions = 1, 2, 4
Hamming Code
Position 7 6 5 4 3 2 1
Code-word M4 M3 M2 P3 M1 P2 P1
44
1-bit Correction: Example
• Definition of 3 Parity Bits
– P1: even parity in bits 1, 3, 5, and 7 (P1=M1M2M4)
– P2: even parity in bits 2, 3, 6, and 7 (P1=M1M3M4)
– P3: even parity in bits 4, 5, 6, and 7 (P1=M2M3M4)
• Example: BCD code ‘0110’
Position 7 6 5 4 3 2 1
Code-word M4 M3 M2 P3 M1 P2 P1
BCD Code 0 1 1 0
Parity (1,3,5,7) √ √ √ 1
Parity (1,3,5,7) √ √ √ 1
Parity (1,3,5,7) √ √ √ 0
Hamming Code 0 1 1 0 0 1 1
45
Hamming Code-words: BCD
• 1-bit Error Correction Using Even Parity Checks
Position 7 6 5 4 3 2 1
Decimal Value M4 M3 M2 P3 M1 P2 P1
0 0 0 0 0
1 0 0 0 1
2 0 0 1 0
3 0 0 1 1
4 0 1 0 0
5 0 1 0 1
6 0 1 1 0
7 0 1 1 1
8 1 0 0 0
9 1 0 0 1
46
Hamming Code-words: BCD
• 1-bit Error Correction Using Even Parity Checks
Position 7 6 5 4 3 2 1
Decimal Value M4 M3 M2 P3 M1 P2 P1
0 0 0 0 0 0 0 0
1 0 0 0 0 1 1 1
2 0 0 1 1 0 0 1
3 0 0 1 1 1 1 0
4 0 1 0 1 0 1 0
5 0 1 0 1 1 0 1
6 0 1 1 0 0 1 1
7 0 1 1 0 1 0 0
8 1 0 0 1 0 1 1
9 1 0 0 1 1 0 0
47
Hardware Implementation
• M = 4, k = 3
M4 M3 M2 M1 Y7 Y6 Y5 Y4 Y3 Y2 Y1
M4 M3 M2 P3 M1 P2 P1 M4 M3 M2 M1
48
Hardware Implementation
• Hamming Code Generation (m=4, k=3)
49
Hardware Implementation
• M = 4, k = 3
M4 M3 M2 M1 Y7 Y6 Y5 Y4 Y3 Y2 Y1
M4 M3 M2 P3 M1 P2 P1 M4 M3 M2 M1
50
1-bit Correction: Example
• Position Binary Number (Receiver)
Error Position B2 B1 B0
0 0 0 0
1 0 0 1
2 0 1 0
3 0 1 1
4 1 0 0
5 1 0 1
6 1 1 0
7 1 1 1
– B0 = 1: an error in either of positions 1, 3, 5, and 7
– B1 = 1: an error in either of positions 2, 3, 6, and 7
– B2 = 1: an error in either of positions 4, 5, 6, and 7
51
Error Detection
• To Detect and Locate Single-bit Error
– Perform parity checks on the incoming code-word
– Generate the position binary number ( bk-1 ... b1 b0 )
– With m = 4 and k = 3, the position binary number is ( b2b1b0 )
• Error Detection and Location Flow
Transmitted Data Received Data Parity check for bits 1, 3, 5, 7
(0110011) (0110111) B0 = 1
52
Hardware Implementation
• Position Binary Number Generator (M = 4, k = 3)
b2=Y7Y6 Y5 Y4
b1=Y7Y6 Y3 Y2
b0=Y7Y5 Y3 Y1
53
Error Correction
• To Correct Error
– Using position binary number ( bk-1 ... b1 b0 )
– Error correction is done by simply inverting the error bit
– Only data bits (M4, M3, M2, M1) need to be corrected
• Error Correction Flow
Transmitted Data Received Data Parity check for bits 1, 3, 5, 7
(0110011) (0110111) B0 = 1
54
Hardware Implementation
• Error Correction (M = 4, k = 3)
55
Hardware Implementation
• Hamming Code Error Correction (m=4, k=3)
56
Hamming Codes: Double-bit Error
• Hamming code with m=4 and k=3 can detect and
correct any single-bit error.
• If double-bit error?
Position 7 6 5 4 3 2 1 position
Code-word M4 M3 M2 P3 M1 P2 P1
BCD Code 0 1 1 0
Hamming Code 0 1 1 0 0 1 1
Code at Rcv. 0 1 0 0 1 1 1
b0 0 0 1 1 0
b1 0 1 1 1 1
b2 0 1 0 0 1
(b2, b1, b0) = (1,1,0) pointing a wrong position.
57
Hamming Codes: Double-bit Error
• To identify double-bit errors, the minimum distance
should be 4 (k = 4)
• Additional parity check bit (P4) at the position of 8.
Position 8 7 6 5 4 3 2 1 b2,b1,b0
Code-word P4 M4 M3 M2 P3 M1 P2 P1
BCD Code 0 1 1 0
Hamming Code 0 0 1 1 0 0 1 1
No Error 0 0 1 1 0 0 1 1 0, 0, 0
Single-bit Error 0 0 1 1 0 1 1 1 0, 1, 1
Single-bit Error 1 0 1 1 0 0 1 1 0, 0, 0
If P4 parity check fails
If (b2,b1,b0) = (0,0,0), error in P4
Else, error in the position of (b2,b1,b0)
58
Hamming Codes: Double-bit Error
• Double-bit Error Detect
P4 parity check OK and (b2,b1,b0) (0,0,0)
Position 8 7 6 5 4 3 2 1 b2,b1,b0
Code-word P4 M4 M3 M2 P3 M1 P2 P1
BCD Code 0 1 1 0
Hamming Code 0 0 1 1 0 0 1 1
Double-bit Error
0 1 1 1 0 1 1 1 1, 0, 0
Case #1
Double-bit Error
1 0 1 1 1 0 1 1 1, 0, 0
Case #2
Note: if error in P4, (b2, b1, b0) indicates the location of the
second error bit
• Exercise: Circuit design of single-bit error correction
and double-bit error detection for m=4
59
Hamming Code Capability
Minimum Distance Capability
1 No Error Detection
61
Code Efficiency & Redundancy
• For a code-word with (m, k) bits,
Code Efficiency = m / (m + k)
Code Redundancy = k / (m + k)
62
Hamming Code: Practice
• A digital communication link has the
following specifications:
– 7-bit message string denoted as (M7, … , M1)
– Error detection and error correction capability
– One or more check bits
– Even parity for check bits
63
Cyclic Redundancy Check
• Principles
– Polynomial Representation: treat all binary bit
string as a polynomial function of variable (x)
– Polynomial Division: error checking via
“Polynomial Division” using Modulo-2 arithmetic
operation
– Extremely reliable in detecting both single and
multiple bit errors
– Can be implemented efficiently using simple
feedback shift registers and XOR gates
64
Polynomial Representation
• Given a binary bit string:
B = bn-1 bn-2 … b1 b0
We can represent the bit string as a polynomial
function of a dummy variable (x) which is binary
weighted as follows:
B(x) = bn-1 xn-1 + bn-2 xn-2 + … b1 x + b0
Subtraction: 1011010 x6 x4 x3 x
− 0101110 − x5 x3 x2 x
1110100 x6 + x5 + x4 x2
In fact (A + B ) = (A − B) = ( A B )
66
Modulo-2 Arithmetic
• Modulo-2 Polynomial Division
– In general, division of a polynomial B(x) by another
polynomial G(x) produces a quotient polynomial Q(x) and a
remainder polynomial R(x):
B(x) R(x)
= Q(x) +
G(x) G(x)
67
Modulo-2 Arithmetic
• Example
B(x) = x10 + x9 + x7 + x5 + x4
G(x) = x4 + x3 + 1
x6 + x3 + x
x4 + x3 + 1 ) x10 + x9 + x7 + x5 + x4
x10 + x9 + x6
x7 + x6 + x5 + x4
x7 + x6 + x3
x5 + x4 + x3
x5 + x4 + x
Remainder → x3+ x
We get : Q(x) = x6 + x3 + x
R(x) = x3 + x
Verify : B(x) + R(x) = Q(x)G(x) (Modulo-2 addition)
68
Modulo-2 Arithmetic
• Synthetic Division Using Bit String
B(x) = x10 + x9 + x7 + x5 + x4 (B = 11010110000)
G(x) = x4 + x3 + 1 (G = 11001)
1 001010
11001 ) 1101 0 110000
1100 1
1 11 1 0
1 10 0 1
1 1 100
1 1 001
Remainder → 1010
69
Principles of CRC Code
• At the transmitter end,
T(x) = B(x) + R(x) = Q(x) G(x)
• At the receiver end
T' (x)
= Q(x) + R ' (x)
G(x)
E(x)
where T' (x) = T(x) + E(x) and R' (x) =
G(x)
If the remainder polynomial R’(x) = 0, it implies that there is no
error. Otherwise, error(s) had occurred during transmission
and re-transmission is needed.
70
Principles of CRC Code
Transmitter
Receiver
T’(x)
¸ G(x) Q(x) = Q(x) + R’(x)
=T(x) + E(x)
71
Generation of CRC Code
• Step 1: For a generator polynomial G(x) = gr xr + gn-1
xn-1 + … g1 x + g0 with degree of r, append r number
of ‘0’s to the end of the original data string, forming
new data polynomial B’(x)
• Generator Polynomial:
G(x) = gr xr + gr-1 xr-1 + … g1 x + g0
73
CRC Encoding in Systematic Form
• Divide xr B(x) by G(x):
xr B(x) = Q(x)G(x) + R(x)
Where R(x) = rr-1 xr-1 + rr-2 xr-2 + … r1 x + r0
75
CRC Encoding: Verification
• With no error, received code-word T’ = 11010111010
T’(x) = x10 + x9 + x7 + x5 + x4 + x3 + x
G(x) = x4 + x3 + 1
1 0 0 1 0 1 0
1 1 0 0 1 ) 1 1 0 1 0 1 1 1 0 1 0
step 1 1 1 0 0 1
0 0 1 1 1
step 2 0 0 0 0 0
0 1 1 1 1
step 3 0 0 0 0 0
1 1 1 1 1
step 4 1 1 0 0 1
0 1 1 0 0
step 5 0 0 0 0 0
1 1 0 0 1
step 6 1 1 0 0 1
0 0 0 0 0
step 7 0 0 0 0 0
0 0 0 0 Remainder
Remainder R(x) = 0 No Error
76
CRC Encoding: Verification
• With errors, received code-word T’ = 11000001010
T’(x) = x10 + x9 + x3 + x
G(x) = x4 + x3 + 1
1 0 0 0 1 1 1
1 1 0 0 1 ) 1 1 0 0 0 0 0 1 0 1 0
step 1 1 1 0 0 1
0 0 0 1 0
step 2 0 0 0 0 0
0 0 1 0 0
step 3 0 0 0 0 0
0 1 0 0 1
step 4 0 0 0 0 0
1 0 0 1 0
step 5 1 1 0 0 1
1 0 1 1 1
step 6 1 1 0 0 1
1 1 1 0 0
step 7 1 1 0 0 1
0 1 0 1 Remainder
Remainder R(x) = x2 + 1 Errors in Transmission
77
Analysis of CRC
• We relied on the proposition that a damaged frame
or bit string means that division by generator
polynomial G(x) yields a non-zero remainder.
• Is it possible to change the transmitted bit string T
such that dividing the received polynomial T’(x) by
G(x) does give a zero remainder?
• Yes, but a complete proof requires knowledge of
factorization properties of polynomial rings (a field in
abstract mathematics), which is beyond the scope of
this course.
78
Selection of G(x)
• Consider a given generator polynomial:
G(x) = gr xr + gr-1 xr-1 + … g1 x + g0
79
Selection of G(x)
• In general, CRC is very effective in performing error
detection if G(x) is chosen properly
• For a generator polynomial G(x) of degree r where x
is not a factor but (x + 1) is a factor, it is able to
detect the following errors :
– All burst errors of length r
– All burst errors affecting an odd number of bits
– All burst errors of length = r + 1, with probability
( 2r-1 - 1 ) / 2r-1
– All burst errors of length > r + 1, with probability
( 2 r - 1 ) / 2r
80
Standard G(X) Polynomials
• Some of the widely used generator polynomials for
G(x) in local area networks (LANs):
81
Cyclic Code Generation
• The term ‘cyclic’ is derived from the ring shift
register structure.
82
Cyclic Code Generation
• Example: The 4-bit shift register configuration below
will cycles through 4 different bit patterns if initially
loaded with 0001, but not all possible 4-bit patterns.
0001
D Q D Q D Q D Q
0001 1000
Clock 0100
83
Cyclic Code Generation
• A feedback shift register of n-bit which produces 2n –
1 bit patterns as it is clocked is defined as a
maximum length shift register.
84
Cyclic Code Generation
• Example (Maximum Sequence Generation): Consider
the following 3-bit shift register and XOR gate
structure, assuming an initial bit pattern of 001.
Clock Cycle R1 R2 R3
0 0 0 1
1 1 0 1
2 1 1 1
R1 R2 R3
3 1 1 0
4 0 1 1
5 1 0 0
6 0 1 0
7 0 0 1
85
Cyclic Code Generation
• Example (Divider Circuit with Shift Register and XOR
gate): Consider the same maximum sequence shift
register structure, assuming initial register content
reset to all 0’s and a 4-bit input string 1110 with MSB
checked first: G(x) = x3 + x2 + 1
Clock Input R1 R2 R3
Cycle
0 0 0 0 0
1 1 1 0 0
0111 R1 R2 R3
2 1 1 1 0
3 1 1 1 1
4 0 1 1 0
86
Cyclic Code Generation
• The bit pattern in registers R3 R2 R1 after 4-shifts
corresponds to the remainder polynomial R(x).
87
Polynomial Divisor Circuit
• Let V(x) = vn-1 xn-1 + vn-2 xn-2 + … v1 x + v0
G(x) = gr xr + gr-1 xr-1 + … g1 x + g0
We want to perform:
V(x) R(x)
= Q(x) +
G(x) G(x)
Use shift register and XOR circuit:
Output
g0 g1 g2 Gr-1 Gr
V(x)
88
Polynomial Divisor Circuit
• Example #1: G(x) = x3 + x2 + 1
g3 = 1, g2 = 1, g1 = 0, g0 = 1
x0 x2 x3 Out
In
In
89
Illustration of Division Process
• Using Polynomial Divisor Circuit for Error Detection
– Consider a polynomial divisor circuit for generator
polynomial for the purpose of error detection :
G(x) = x4 + x3 + 1
90
Illustration of Division Process
Out
Initial
Input
0 0 0 0
01010000011(M)
xi 0 1 2 3 Out
Step 0:
Input
0 0 1 1
0101000(M)
xi 0 1 2 3 Out
Step 1:
Input
1 0 0 0
010100(M)
xi 0 1 2 3 Out
Step 2:
Input
0 1 0 0
01010(M)
xi 0 1 2 3
Out
Step 3:
Input
0 0 1 0
0101(M)
xi 0 1 2 3
91
Illustration of Division Process
Out
Step 4:
Input
1 0 0 1
010(M)
xi 0 1 2 3 Out
Step 5:
Input
1 1 0 1
01(M)
xi 0 1 2 3 Out
Step 6:
Input
0 1 1 1
0(M)
xi 0 1 2 3 Out
Step 7:
Input
1 0 1 0
(M)
xi 0 1 2 3
– First 4 (or r) cycles just shift 4 (or r) MSBs of input string.
– After n-shifts (in this example, n = 11), register bit pattern
corresponds to remainder polynomial, R(x)
92
Reducing the Number of
Shifting Cycles
• The process of shifting the incoming bit string can be reduced
by re-arranging the polynomial divisor circuit, as illustrated
below for the case of
G(x) = x3 + x2 + 1
x0 x2 x3 Out Out
In
93
CRC Encoding:
Using (n-k) Stage Shift Register
• From previous discussion, we want to generate the
CRC code in the following format:
k message bits (n-k) check bits
• This means that the message data are intact, thus no
further assembling of message bits is required.
g1 g2 gn-k-1
r0 r1 rn-k-1 +
• For the first k shifts, the Gate and Switch are at the ON
position. The k information bits are shifted into the register
and to the output simultaneously.
• For the remaining n - k shifts, the Gate and Switch are turned to
OFF position. The (n-k) check bits (remainder bits) in the
registers are shifted to the output.
95
Encoding Circuit
• Example: Encoding a (7,4) code
Let G(x) = x3 + x + 1
B(x) = x3 + x2 + 1 (B = 1101)
Gate Clock
Input Register Out
Cycle
0 0 0 0 0
0 1 2 1 1 1 1 0 1
x x x +
2 1 1 0 1 1
Out 3 0 1 0 0 0
Input (1001011)
(1011(M)) 4 1 1 0 0 1
5 0 1 0 0
6 0 0 1 0
7 0 0 0 1
96
Alternative Encoding Circuit
97
Alternative Encoding Circuit
G(x) = ? Gate
98
Alternative Encoding Circuit
FCS SR
Receive SR
99
Exercise
• Given the following polynomial divisor circuit, derive
the corresponding generator polynomial G(x).
• Verify that the above circuit produces maximum
sequence as it is clocked, for any pre-loaded bit
patterns except 0000.
• Assuming an incoming code-word T ’ = 10110110,
show the outcome of the error detection process
with a step-by-step shift of the incoming bit string
(MSB first).
Input Output
100
M-out-of-N Code
• An m-out-of-n code: with a code word length of n
bits, each valid code word contains exactly m 1s and
n-m 0s
• A single bit error will cause the code word to have
either m + 1 or m – 1 1s
101
3-out-of-6 Code
• The simplest implementation is to append a string of
1s to the original data until it contains m 1s, then
append 0s to create a code of length n.
Original 3 Data Bits Appended Bits
0 0 0 1 1 1
0 0 1 1 1 0
0 1 0 1 1 0
0 1 1 1 0 0
1 0 0 1 1 0
1 0 1 1 0 0
1 1 0 1 0 0
1 1 1 0 0 0
102
2-out-of-5 Code
• Ten possible combinations
with two 1s in a five-bit code Digit Telecomm. POSTNET
01236 74210
word.
0 01100 11000
• Popular for representing
1 11000 00011
decimal digits
• A weighted code. There are 2 10100 00101
different ways to assign 3 10010 00110
weights to each bit so that 4 01010 01001
the sum is the desired value, 5 00110 01010
with an exception for 0. 6 10001 01100
7 01001 10001
8 00101 10010
9 00011 10100
103
Checker for M-out-of-N Code
• For valid m-out-of-n code inputs, the checker’s
output is 01 or 10
• If the number of 1s at the input is greater or less than
m (invalid code inputs), the output is 11 or 00
• Code words contain the same numbers of 1s and 0s,
i.e. n=2m. Code of this type are known as k -out-of-
2k codes
104
Checker for k-out-of-2k Code
• The 2k bits are partitioned into two disjoint subsets
A & B:
A(x1, x2, x3, …, xk) & B(xk+1, xk+2, xk+3, …, x2k)
105
Checker for k-out-of-2k Code
• T(kAi) Represents the function which has the value
1 if and only if the number of 1s in A is greater than
or equal to the value i
106
Example
• Design a totally self-checking 2-out-of-4 checker:
k=2, A=(x1,x2) & B=(x3,x4)
= x3 x4 + x 1 x2
107
Example
• Design a totally self-checking 3-out-of-6 checker:
k=3, A=(x1,x2,x3) & B=(x4,x5,x6)
108
M-out-of-N Checker
• A general m-out-of-n checker, where n≠2m, can be
realized by translating the given code to a 1-out-of-
𝑪𝒏𝒎 code, which is converted to a k-out-of-2k code via
a totally self-checking translator
109
Example
• Design a 2-out-of-5 code checker
110
Example
• Design steps
– Changing the 2-out-of-5 code into a 1-out-of-10 code
– Translating the 1-out-of-10 code into a 3-out-of-6 code
– Design a 3-out-of-6 checker
111
Example
• Design steps
– 1st Step: Changing the 2-out-of-5 code into a 1-out-of-10
code
– 2nd Step: Translating the 1-out-of-10 code into a 3-out-of-6
code
– 3rd Step: Design a 3-out-of-6 checker
112
Example
• 1st step: Decoding the 2-out-of-5 code into the 1-out-
of-10 code
– Truth table for 2-out-of-5 to 1-out-of-10 decoder
113
Example
• 1st step: Decoding the 2-out-of-5 code into the 1-out-
of-10 code
– 2-out-of-5 to 1-out-of-10 decoder
114
Example
• 2nd step: translate the 1-out-of-10 code into a 3-out-
of-6 code
– Truth table for 1-out-of-10 to 3-out-of-6 translator
115
Example
• 2nd step: translate the 1-out-of-10 code into a 3-out-
of-6 code
– 1-out-of-10 to 3-out-of-6 translator
116
SUMMARY:
DATA CODING
• Secure digital data transmission can be achieved by
error detection/correction codes.
• Error detection/correction codes are implemented
through additional bit(s) appended.
• Error detection codes include
– Parity Check, Cyclic Redundancy Check (CRC) , M-Out-Of-
N codes and Cryptographic Hash Function
• Error correction codes include
– Repetition code, 2-D Parity Check, Hamming codes, Reed-
Solomon code, Turbo code, and Low Density Parity Check
code (LDPC)
• Shannon’s theorem for fundamental knowledge
117