We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 4
CHAPTER 3
BINARY CODES
only two states namely HIGH and LOW or ON and OFF
of binary nature. In the previous chapters we
have gone through the binary number system and binary arithmetic. In binary number
system, the number of bits required goes on increasing as the numbers become larger
and larger. When the number is large, the conversion procedure to get the binary equivalent
is tedious. Also, some special binary codes are required to represent alphabets and special
characters. Digital calculators, multimeters, frequency meters etc., prefer 4-bit code to
represent decimal numbers 0 to 9. Based on these points, different types of binary codes
have been developed. This chapter discusses some important codes under the following
All digital circuits operate with
or 1 and 0.That is, all the operations are
headings
3.1 BCD codes - 8421 code
3.2. Excess-3 code
3.3. Gray code
3.4 ASCII code
3.1 BCD CODES - 8421 CODE
‘A group of bits (usually four) which are used to represent decimal numbers 0 to 9 are
called Binary Coded Decimal codes or BCD codes
The most popular BCD code is the 6421 code. The 8421 indicates the binary weights
of the four bits (2°,22,2',2"). Using the four bits with weights 6,4,2,1 we can easily represett
the decimal numbers 0 to 9 as given in Table (3.1a).
From the Table (3.1a), we can see that the four bit binary combination given is ony
the first ten: combination of the four bit binary progression, The six remaining combinations:
inamly 1010, 1014, 1100, 1101, 1110 and 1111 are invalid 8421 BCD codes
@ scanned with OKEN ScannerBINARY CODES
43
Decimal
Table 3.1a
| Any decimal number greater than 9 can be easily represented in 8421 BCD, by
| repeatedly using the four bit code for each digit. Few examples are shown in Table 3,1b.
Decimal 8421 BCD code
15 0001 0101
29 0010 1004
468 0100 0110 1000
} 97.5° 1001 0111 . 0101
Table 3.1b
Note:
Each digit must be represented by @ 4-bit BCD code.
BCD (8421) Addition:
Many applications require the arithmetic operations to be performed using BCD codes
(as in calculators).
The general rule for binary addition is
0+0=0
o+1=1
@ scanned with OKEN Scanner4 DIGITAL ELECTRONICS & MICROPROCESSOR soe
14024
14420, cany1
The same rule is followed for BCD addition, but we should make sure that the resuy
does not contain any invalid BCD codes, mentioned earber, The following steps are fotloweg
to add two BCD numbers.
1. Add the two numbers, using the rules of binary addition.
2.1f the 4-bit sum is equal to or less than 9, it is a valid BCD number.
3.1 the 4-bit sum is greater than 9, or if a carry out of a BCD group is generated. the
result is invalid BCD. To get the correct BCD result, add 6 (i.e. 0110) to the first group
and take the carry to the next group.
The following examples illustrate the above points.
(a) 5+ 0101+
2 0010
7 0111 —_ Valid BCD result; No correction required.
Ont +
& . 0110
13 1101+ Invalid BCD as it exceeds 9;
0110 Add 6 to get correct BCD
1001 Valid BCD number (0001 0011)
-
a
+
17 10001+ Valid BCD, but we get a carry,
ON10_ Add 6 to get correct BCD
10191 Valid BCD number (0001 0111)
3.2 EXCESS -3 CODE
The Excess-3 code is another BCD code used in earlier computers. The Excess-3 cod?
for # decimal digit iS obtained by adding 0011 (3) to the 6421 BCO code. The Excess?
tode also has ten valid codes and six invalid codes. The six invalid codes are 6000, 0001
O40, 1101,.1110 and 1111) The valid Excess-3 codes are given in Table 3.2.
@ scanned with OKEN ScannerBINARY CODES
COP
; Decimal 8421 Excess-3
0 0000 0011
1 0001 0100
2 . 0010 0101
3 0011 0110
4 0100 0111
- 0101 1000
0110 1001
0111 1010
1000 1011
1100
| Table 3.2
Like in 8421 BCD code, in Excess-3 code also, if the number is greater than 9, the
code is given separately for each digit. Few examples are given below.
Decimal Number Excess-3 code
- 26 0101 1001
97 1100 1010
853 1011 1000 0110
We also note that the Excess-3 code is not a weighted code. From table 3.2, we see
that the excess 3 code for 0 is 0011. The 1's complement of 0011 is 1100 which is the
excess 3 code for 9, and 9 is 9's complement of 0. Similarly, the excess 3 code for 1 is
0100. The 1's complement of 0100 is 1011 which is the excess 3 code for 8, and & is 9's
complement of 1,.This can be checked for other numbers. Hence excess 3 code is called
as self complementry code
@ scanned with OKEN Scanner