0% found this document useful (0 votes)
9 views21 pages

DigitalElectronics Numbersystem 2

Uploaded by

Aditya Chawla
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views21 pages

DigitalElectronics Numbersystem 2

Uploaded by

Aditya Chawla
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

PART II

DIGITAL ELECTRONICS

Chapter 4 : Number systems and Codes

Reference:
1. Malvino and Leach, Digital Principles & applications, 7th
edition, TMH, 2010
2. Morris Mano, “Digital design”, Prentice Hall of India, Third
Edition.

Department of Electronics and Communication Engineering, MIT, Manipal 1


Module 2: Codes

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.

Department of Electronics and Communication Engineering, MIT, Manipal


Numeric Codes
• Weighted Codes
• Obey positional weighting principle
• Non-Weighted Codes
• Positions do not have specific weight
• Self-Complementing Codes
• Logical compliment of a coded number is a arithmetic compliment
• Sequential
• Each succeeding codeword is one binary number greater than the preceeding
codeword
• Cyclic Code
• One bit positional difference between successive codes (unit distance code)
• Error Detecting Codes 3

• Error Correcting Codes


Department of Electronics and Communication Engineering, MIT, Manipal
Weighted codes
• Numeric codes
• Weighted binary codes obey the positional weight
principle.
• There exists a fixed weight associated with each bit
position in the binary representation of the code character.
• Number (A) is encoded in the binary form as a3 a2 a1 a0 and
w3, w2, w1 and w0 are the weights selected for a given code
(A) = w3a3 + w2a2 + w1a1 +w0a0
4
• Examples: Binary coded decimal(BCD)

Department of Electronics and Communication Engineering, MIT, Manipal


Binary coded decimal codes

Weighted Codes

5
Department of Electronics and Communication Engineering, MIT, Manipal
Binary coded decimal codes

Weighted codes

• 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.

6
Department of Electronics and Communication Engineering, MIT, Manipal
Binary coded decimal codes

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
7

Department of Electronics and Communication Engineering, MIT, Manipal


Binary coded decimal codes

Binary Coded Decimal code (BCD)

Consider the number (16.85)10

(16.85)10 = (0001 0110 . 1000 0101)

Department of Electronics and Communication Engineering, MIT, Manipal


Binary coded decimal codes

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

Department of Electronics and Communication Engineering, MIT, Manipal


Binary coded decimal codes
Decimal to BCD, Excess-3 and Gray code

Decimal BCD = 8421 Excess-3 Gray


0 0000 0011 0000
1 0001 0100 0001
2 0010 0101 0011
3 0011 0110 0010
4 0100 0111 0110
5 0101 1000 0111
6 0110 1001 0101
7 0111 1010 0100
8 1000 1011 1100
9 1001 1100 1101
10

Department of Electronics and Communication Engineering, MIT, Manipal


Self complementing codes

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.

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.

11

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?

12
Department of Electronics and Communication Engineering, MIT, Manipal
Error Detection and Correction

• Introduction

• Single bit Error detection using parity bit


• Single bit error correction using (7,4) Hamming code

13

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 error is called error
correction code.
Department of Electronics and Communication Engineering, MIT, Manipal
Error Detection Codes

• Parity: Number of ones in the given code word.

• Even & Odd parity:

Example: 0000 (1)odd-parity (0)even-parity

Example: 0100 (0)odd-parity (1)even-parity

15
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  i 4
p2 = i1  i3  i 4
p4 = i2  i 3  i 4
16

Department of Electronics and Communication Engineering, MIT, Manipal


Hamming Code

Can write the equations as follows (easy to remember)


p1 p2 i 1 p4 i 2 i 3 i 4
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

17

Department of Electronics and Communication Engineering, MIT, Manipal


Structure of Encoder and Decoder of
Hamming Code

18

Department of Electronics and Communication Engineering, MIT, Manipal


Hamming Code

There is 10 different messages for BCD and EXCESS-3.

Decimal Digit Hamming Code bits

For BCD For EXCESS 3


P1 P2 D3 P4 D5 D6 D7 P1 P2 D3 P4 D5 D6 D7
0 0 0 0 0 0 0 0 1 0 0 0 0 1 1
1 1 1 0 1 0 0 1 1 0 0 1 1 0 0
2 0 1 0 1 0 1 1 0 1 0 0 1 0 1
3 1 0 0 0 0 1 1 1 1 0 0 1 1 0
4 1 0 0 1 1 0 0 0 0 0 1 1 1 1
5 0 1 0 0 1 0 1 1 1 1 0 0 0 0
6 1 1 0 0 1 1 0 0 0 1 1 0 0 1
7 0 0 0 1 1 1 1 1 0 1 1 0 1 0
8 1 1 1 0 0 0 0 0 1 1 0 0 1 1
9 0 0 1 1 0 0 1 0 1 1 1 1 0 0

19

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?

20
Department of Electronics and Communication Engineering, MIT, Manipal
Summary

 Different forms of BCD representation

 Weighted and non weighted codes

 Error detection using parity bit.

 Error correction using Hamming code.

Department of Electronics and Communication Engineering, MIT, Manipal 21

You might also like