1. Department of Electronics and Communication Engineering, MIT, Manipal
PART II
DIGITAL ELECTRONICS
1
Reference:
1. Malvino and Leach, Digital Principles & applications, 7th
edition, TMH, 2010
2. Morris Mano, “Digital design”, Prentice Hall of India, Third
Edition.
Chapter 4 : Number systems and Codes
2. Department of Electronics and Communication Engineering, MIT, Manipal
Module 2: Codes
2
Learning outcomes
At the end of this module, students will be able to:
• Discuss different binary combinations to represent code
characters.
• Explain error detection using parity bit.
• Describe error correction using hamming code.
3. Department of Electronics and Communication Engineering, MIT, Manipal
Binary coded decimal codes
3
Weighted Codes
4. Department of Electronics and Communication Engineering, MIT, Manipal
Binary coded decimal codes
4
• Weighted binary codes are those binary codes which
obey the positional weight principle.
• Each position of the number represents a specific weight.
• There exists a fixed weight associated with each bit
position in the binary representation of the code
character.
Weighted codes
5. Department of Electronics and Communication Engineering, MIT, Manipal
Binary coded decimal codes
5
Decimal number (A)10
Encoded in the binary form as a3 a2 a1 a0.
w3, w2, w1 and w0 are the weights selected for a given
code
(A)10 = w3a3 + w2a2 + w1a1 +w0a0
The more popularly used codes have these weights as
W3 W2 W1 W0
8 4 2 1
2 4 2 1
8 4 -2 -1
6. Department of Electronics and Communication Engineering, MIT, Manipal
Binary coded decimal codes
6
Binary Coded Decimal code (BCD)
Consider the number (16.85)10
(16.85)10 = (0001 0110 . 1000 0101)
7. Department of Electronics and Communication Engineering, MIT, Manipal
Binary coded decimal codes
7
Non-Weighted Code is one in which the positions in the code
do not have a specific weight. Examples are Excess-3. And
Gray.
• EXCESS-3 CODE
• GRAY CODE
9. Department of Electronics and Communication Engineering, MIT, Manipal
Self complementing codes
9
Example: Consider the 2421 code.
The 2421 code of (4)10 is 0100.
Its complement is 1011 which is 2421 code for (5)10 = (9 - 4)10.
The complement of a code (by inverting each bit of code word)
the new code word formed represents the complement of the
number then such codes are called self-complementing code.
10. Department of Electronics and Communication Engineering, MIT, Manipal
Self Test
1. What do you mean by a code word?
2. What are the two types of BCD codes?
3. What do you mean by self – complementing code?
10
11. Department of Electronics and Communication Engineering, MIT, Manipal
Error Detection and Correction
11
• Introduction
• Single bit Error detection using parity bit
• Single bit error correction using (7,4) Hamming code
12. Department of Electronics and Communication Engineering, MIT, Manipal
Introduction
• When data is transmitted in digital form from one place to
another place through a transmission channel some data bits
may be modified.
• In a communication system data integrity is extremely
important.
• Ability to identify the error is called the error detection. It
would be preferred even well if we can correct the error besides
detection.
• A code which has the ability to correct the is called error
correction code.
13. Department of Electronics and Communication Engineering, MIT, Manipal
Error Detection Codes
13
• Parity: Number of ones in the given code word.
• Even & Odd parity:
Example: 0000 (1)odd-parity (0)even-parity
Example: 0100 (1)odd-parity (0)even-parity
14. Department of Electronics and Communication Engineering, MIT, Manipal
Error Correction code
Principle of error correction
Consider a (7,4) Hamming code
Let i1 i2 i3 i4 be information symbols
Let p1p2 p4 be check symbols
The parity equations:
p1 = i1 i2 i4
p2 = i1 i3 i4
p4 = i2 i3 i4
14
15. Department of Electronics and Communication Engineering, MIT, Manipal
Hamming Code
15
Can write the equations as follows (easy to remember)
p1 p2 i1 p4 i2 i3 i4
1 0 1 0 1 0 1
0 1 1 0 0 1 1
0 0 0 1 1 1 1
1 2 3 4 5 6 7
This encodes a 4-bit information word into a 7-bit code
word
16. Department of Electronics and Communication Engineering, MIT, Manipal
Structure of Encoder and Decoder of
Hamming Code
16
18. Department of Electronics and Communication Engineering, MIT, Manipal
Self Test
1. What is parity bit? How many types are there?
2. What do you mean by distance between two words?
3. What is the minimum distance of 7- bit Hamming code?
4. What must be the minimum distance of a code for it to be
single – bit error correcting code?
18
19. Department of Electronics and Communication Engineering, MIT, Manipal
Summary
19
Different forms of BCD representation
Weighted and non weighted codes
Error detection using parity bit.
Error correction using Hamming code.
Editor's Notes
Even parity: The parity bit is set to 0 or 1 at the transmitter in such a way that the total number of 1’s in the resulting code word (including the parity) bit is an even number.
Odd parity: The parity bit is set to 0 or 1 at the transmitter in such a way that the total number of 1’s in the resulting code word (including the parity bit) is an odd number.
Properties of the code
If there is no error, all parity equations will be satisfied
Denote the outcomes of these equation checks as c1, c2, c4
If there is exactly one error, then c1, c2, c4 point to the error
The vector c1, c2, c4 is called syndrome
The above (7,4) Hamming code is SEC code
The above method of construction can be generalized to construct an (n,k) Hamming code
Simple bound
k = number of information bits
r = number of check bits
n = k + r = total number of bits
n + 1 = number of single or fewer errors
Each error (including no error) must have a distinct syndrome
With r check bits max possible syndrome = 2r
Hence: 2r n + 1