IT12 DigD CS21 DigD - Module 8

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

IT12-DigD/CS21-DigD (Digital Design)

PAMBAYANG DALUBHASAAN NG MARILAO


College of Computer Studies

I. INTRODUCTION
This module introduces numbers or letters are
represented by a specific group of symbols, it is
said to be that number or letter is being encoded.
The group of symbols is called a code. The digital
data is represented, stored, and transmitted as
Module 8 groups of bits. This group of bits is also called
binary code.

BINARY CODED DECIMAL


II. OBJECTIVES
1. Identify the base of a particular number
system
2. Formulates the given value of a number
system

III. PRELIMINARY ACTIVITIES


Review the number system and apply the complement given problem

(supporting video tutorial)

IV. LESSON PROPER


Binary codes can be classified into two types.

Weighted codes
Unweighted codes

If the code has positional weights, then it is said to be weighted code. Otherwise, it is an unweighted
code. Weighted codes can be further classified as positively weighted codes and negatively weighted
codes.

Page 1 of 6
IT12-DigD/CS21-DigD (Digital Design)
PAMBAYANG DALUBHASAAN NG MARILAO
College of Computer Studies

Binary Codes for Decimal digits


The following table shows the various binary codes for decimal digits 0 to 9.
Decimal Digit 8421 Code 2421 Code 84-2-1 Code Excess 3 Code

0 0000 0000 0000 0011

1 0001 0001 0111 0100

2 0010 0010 0110 0101

3 0011 0011 0101 0110

4 0100 0100 0100 0111

5 0101 1011 1011 1000

6 0110 1100 1010 1001

7 0111 1101 1001 1010

8 1000 1110 1000 1011

9 1001 1111 1111 1100

We have 10 digits in decimal number system. To represent these 10 digits in binary, we require
minimum of 4 bits. But, with 4 bits there will be 16 unique combinations of zeros and ones. Since, we
have only 10 decimal digits, the other 6 combinations of zeros and ones are not required.

8 4 2 1 code
● The weights of this code are 8, 4, 2 and 1.

● This code has all positive weights. So, it is a positively weighted code.

● This code is also called as natural BCD BinaryCodedDecimal code.


Example

Let us find the BCD equivalent of the decimal number 786. This number has 3 decimal digits 7, 8 and 6.
From the table, we can write the BCD 8421
codes of 7, 8 and 6 are 0111, 1000 and 0110 respectively.

∴ 78610 = 011110000110BCD
There are 12 bits in BCD representation, since each BCD code of decimal digit has 4 bits.

Page 2 of 6
IT12-DigD/CS21-DigD (Digital Design)
PAMBAYANG DALUBHASAAN NG MARILAO
College of Computer Studies

2 4 2 1 code
● The weights of this code are 2, 4, 2 and 1.

● This code has all positive weights. So, it is a positively weighted code.

● It is an unnatural BCD code. Sum of weights of unnatural BCD codes is equal to 9.

● It is a self-complementing code. Self-complementing codes provide the 9’s complement of a


decimal number, just by interchanging 1’s and 0’s in its equivalent 2421 representation.
Example

Let us find the 2421 equivalent of the decimal number 786. This number has 3 decimal digits 7, 8 and 6.
From the table, we can write the 2421 codes of 7, 8 and 6 are 1101, 1110 and 1100 respectively.

Therefore, the 2421 equivalent of the decimal number 786 is 110111101100.

8 4 -2 -1 code
● The weights of this code are 8, 4, -2 and -1.

● This code has negative weights along with positive weights. So, it is a negatively weighted code.

● It is an unnatural BCD code.

● It is a self-complementing code.
Example

Let us find the 8 4-2-1 equivalent of the decimal number 786. This number has 3 decimal digits 7, 8 and
6. From the table, we can write the 8 4 -2 -1 codes of 7, 8 and 6 are 1001, 1000 and 1010 respectively.

Therefore, the 8 4 -2 -1 equivalent of the decimal number 786 is 100110001010.

Excess 3 code
● This code doesn’t have any weights. So, it is an un-weighted code.

● We will get the Excess 3 code of a decimal number by adding three 0011
to the binary equivalent of that decimal number. Hence, it is called as Excess 3 code.
● It is a self-complementing code.
Example

Page 3 of 6
IT12-DigD/CS21-DigD (Digital Design)
PAMBAYANG DALUBHASAAN NG MARILAO
College of Computer Studies

Let us find the Excess 3 equivalent of the decimal number 786. This number has 3 decimal digits 7, 8 and
6. From the table, we can write the Excess 3 codes of 7, 8 and 6 are 1010, 1011 and 1001 respectively.

Therefore, the Excess 3 equivalent of the decimal number 786 is 101010111001

Gray Code
The following table shows the 4-bit Gray codes corresponding to each 4-bit binary code.
Decimal Number Binary Code Gray Code

0 0000 0000

1 0001 0001

2 0010 0011

3 0011 0010

4 0100 0110

5 0101 0111

6 0110 0101

7 0111 0100

8 1000 1100

9 1001 1101

10 1010 1111

11 1011 1110

12 1100 1010

13 1101 1011

Page 4 of 6
IT12-DigD/CS21-DigD (Digital Design)
PAMBAYANG DALUBHASAAN NG MARILAO
College of Computer Studies

14 1110 1001

15 1111 1000

This code doesn’t have any weights. So, it is an un-weighted code.

In the above table, the successive Gray codes are differed in one bit position only. Hence, this code is
called as unit distance code.

Binary code to Gray Code Conversion


Follow these steps for converting a binary code into its equivalent Gray code.
● Consider the given binary code and place a zero to the left of MSB.

● Compare the successive two bits starting from zero. If the 2 bits are same, then the output is
zero. Otherwise, output is one.
● Repeat the above step till the LSB of Gray code is obtained.
Example

From the table, we know that the Gray code corresponding to binary code 1000 is 1100. Now, let us
verify it by using the above procedure.

Given, binary code is 1000.

Step 1 − By placing zero to the left of MSB, the binary code will be 01000.

Step 2 − By comparing successive two bits of new binary code, we will get the gray code as 1100.

V. PRACTICE EXERCISES/ACTIVITIES
The instructions for the activity will be posted in the LMS or to be given in a separate worksheet

VI. ADDITIONAL RESOURCES


https://tinkercad.com

VII. ASSESSMENT
The instructions for the assessment will be posted in the LMS or to be given in a separate
worksheet.

II. REFERENCES

Page 5 of 6
IT12-DigD/CS21-DigD (Digital Design)
PAMBAYANG DALUBHASAAN NG MARILAO
College of Computer Studies

● M. Morris Mano., Digital Logic And Computer Design

● Anil Kumar Maini, Digital Electronics: Principles, Devices and Applications

Page 6 of 6

You might also like