Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Experiment5
BCD Adder and Comparator
November, 2016
DIGITAL LOGIC DESIGN LAB ECOM 2112 ENG. Mai Z. Alyazji
Objectives:
To be familiar with BCD adder/ subtractor circuits.
To be familiar with digital comparators circuits.
PreLab:
Using Logisim implement the circuit shown in Figure 3 and test it.
Background:
Decimal
BCD Digit
Symbol
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
2
DIGITAL LOGIC DESIGN LAB ECOM 2112 ENG. Mai Z. Alyazji
BCD Addition
Consider the addition of two decimal digits in BCD, together with a possible
carry from a previous less significant pair of digits. Since each digit does not
exceed 9, the sum cannot be greater than 9 + 9 + 1 = 19, with the 1 being a
previous carry. Suppose we add the BCD digits as if they were binary
numbers. Then the binary sum will produce a result in the range from 0 to 19.
In binary, this range will be from 0000 to 10011, but in BCD, it is from 0000 to
1 1001, with the first (i.e., leftmost) 1 being a carry and the next four bits
being the BCD sum. When the binary sum is equal to or less than 1001
(without a carry), the corresponding BCD digit is correct. However, when the
binary sum is greater than or equal to 1010, the result is an invalid BCD digit.
The addition of 6 = (0110)2 to the binary sum converts it to the correct digit
and also produces a carry as required. This is because a carry in the most
significant bit position of the binary sum and a decimal carry differ by 16 - 10
= 6. See the following example which shows the addition of 791 and 658 in
BCD.
1 1 1
0111 1001 0001
+
0110 0101 1000
1 1 1 11 1 1
1101 1110 1001
0110 0110 +
BCD Adder
Suppose we apply two BCD digits to a four-bit binary adder. The adder will
form the sum in binary and produce a result that ranges from 0 through 19.
These binary numbers are listed in Table 1. The problem is to find a rule by
which the binary sum is converted to the correct BCD digit representation of
the number in the BCD sum. In examining the contents of the table, it becomes
apparent that when the binary sum is equal to or less than 1001, the
3
DIGITAL LOGIC DESIGN LAB ECOM 2112 ENG. Mai Z. Alyazji
The logic circuit that detects the necessary correction can be derived from the
entries in the table. It is obvious that a correction is needed when the binary
sum has an output carry K = 1. The other six combinations from 1010 through
1111 that need a correction have a 1 in position Z8. To distinguish them from
binary 1000 and 1001, which also have a 1 in position Z8, we specify further
that either Z4 or Z2 must have a 1. The condition for a correction and an output
carry can be expressed by the Boolean function
C = K + Z8Z4 + Z8Z2
4
DIGITAL LOGIC DESIGN LAB ECOM 2112 ENG. Mai Z. Alyazji
A BCD adder that adds two BCD digits and produces a sum digit in BCD is
shown in Figure 1.
5
DIGITAL LOGIC DESIGN LAB ECOM 2112 ENG. Mai Z. Alyazji
Comparator
The comparison of two numbers is an operation that determines whether one
number is greater than, less than, or equal to the other number. A magnitude
comparator is a combinational circuit that compares two numbers A and B
and determines their relative magnitudes.
6
DIGITAL LOGIC DESIGN LAB ECOM 2112 ENG. Mai Z. Alyazji
A = A3 A2 A1 A0
B = B3 B2 B1 B0
Each subscripted letter represents one of the digits in the number. The two
numbers are equal if all pairs of significant digits are equal: A3 = B3, A2 = B2, A1
= B1, and A0 = B0. When the numbers are binary, the digits are either 1 or 0,
and the equality of
(A = B) = x3x2x1x0
The binary variable (A = B) is equal to 1 only if all pairs of digits of the two
numbers are equal.
The symbols (A > B) and (A < B) are binary output variables that are equal to
1 when A > B and A < B, respectively. Figure 3 show a 4-bit comparator.
Lab work:
Equipment’s required:
IC's 74LS04 (Hex Inverter), 74LS08 (Quad 2 input AND), 74LS32 (Quad
2 input OR), 74LS86 (Quad 2 input Exclusive OR), 74LS83 (4-bit binary
adder)
8
DIGITAL LOGIC DESIGN LAB ECOM 2112 ENG. Mai Z. Alyazji
Module KL-33004.
The Datasheets of the IC’s.
Exercises:
Using Logisim