IT12 DigD CS21 DigD - Module 8
IT12 DigD CS21 DigD - Module 8
IT12 DigD CS21 DigD - Module 8
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.
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
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.
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.
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.
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 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.
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.
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
In the above table, the successive Gray codes are differed in one bit position only. Hence, this code is
called as unit distance code.
● 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.
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
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
Page 6 of 6