Chapter 5 - Arithmetic Circuits
Chapter 5 - Arithmetic Circuits
ARITHMETIC
CIRCUITS
Objectives
When adding a larger numbers that has multiple bits, it is still necessary
to add each pair of bits with a carry-in Cin. For example, A=1101 (13) and
B=0110 (6).
Cin Cin Cin Cin 1 1 0 0
A4 A3 A2 A1 1 1 0 1
+ B4 B3 B2 B1 + 0 1 1 0
Cout S4 S3 S2 S1 1 0 0 1 1
The 1s column adds 2 bits A + B and generates 2 outputs S and Co. This
is known as a half adder operation.
A Half S
Adder
B Co
68 Arithmetic Circuits
The half adder truth table and circuit are shown below.
A B S Co
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
S = A.B + A.B = A ⊕ B
C out = A.B
A
S
B
Cout
The 2s, 4s and 8s columns add 3 bits Cin + A + B and generates S and
Cout, which known as a full adder operation.
Cin S
Full
A Adder
B Co
The full adder truth table and circuit are shown below.
A B Cin S Co
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
Arithmetic Circuits 69
Cout
A
B
Cin S
To construct a 4 bit parallel adder, a single half adder and three full adder
circuits are used. The top half adder adds the 1s column ( A1 + B1 ) and
generates S1 and Co. The 2s, 4s and 8s columns use a full adder. Note
that the carry out Co is connected to the Cin of the next adder.
S1
Cin Cin Cin Cin
A1 Half
Adder A 4 A3 A 2 A1
B1 Co + B4 B3 B2 B1
Cout S4 S3 S2 S1
Cin S2
Full
A2 Adder
B2 Co
Cin S3
Full
A3 Adder
B3 Co
Cin S4
Full
A4 Adder
B4 Co
70 Arithmetic Circuits
7483 is a commercial 4-bit full adder. It has four full adders connected as
shown below. To perform a 4 bit addition, the Cin is connected to GND
(0).
74LS83A Cin = 0 S1
A4 Full
A3
A2 A2 Adder
A1 s4
B4 s3 B2 Co
B3 s2
B2 s1
B1
Cin Cout
Cin S2
Full
A2 Adder
B2 Co
Cin S3
Full
A3 Adder
B3 Co
Cin S4
Full
A4 Adder
B4 Co
An 8-bit parallel adder is constructed using two 7483 ICs. The Cout of the
first IC is connected to the Cin of the preceding IC.
74LS83A
A4
Cin = 0 A3
A2
A1 s4
A8 A7 A6 A5 A 4 A3 A 2 A1 B4
B3
s3
s2
B2 s1
B8 B7 B6 B5 B4 B3 B2 B1 B1
74LS83A
A4
A3
A2
A1 s4
B4 s3
B3 s2
B2 s1
B1
Cin Cout
Arithmetic Circuits 71
Example 1: Find the 2’s complement number for +30 and -30.
Example 3: Determine the decimal value for the following 2’s complement
number: a. 00100010 b. 00100010 c. 11111111
a. From the sign bit, 00100010 is a positive number. The decimal value is
+34.
10100010
01011101 Complement each bit
+1
01011110 Decimal value = -94
11111111
00000000 Complement each bit
+1
00000001 Decimal value = -1
The number of bits available in the computer’s arithmetic unit, limits the
range of numbers that can be represented in the machine. Numbers that
fall outside this range cannot be handled by the system. Machines that
uses 2’s complement number system can represent integers in the range
− 2 n −1 ≤ N ≤ 2 n −1 − 1
where n is the number of bits available for representing N. If an operation
produces a result that falls outside the available range, than an overflow
occurs.
We will now learn how to add and subtract using 2’s complement system.
Four cases will be considered: A+B, A-B, -A+B and –A-B.
Since both A and B are positive, the result will also be positive. So, there
is no need to use the 2’s complement.
Example 1: 2+ 4 = +6
sign bit
↓
0 0 1 0
+ 0 1 0 0
0 1 1 0
sign bit
↓
0 1 0 0 1
+ 0 0 1 0 0
0 1 1 0 1
There are cases when an operation produces a result that exceeds the
range of the number system, producing a condition known as overflow.
When we add two numbers with the same sign, which produce a sum that
is larger than the largest representable number, we can obtain an
incorrect result. As a rule, addition overflow occurs whenever the sign of
the sum is different from the signs of both addends.
Example 1: 6+3=-7
sign bit
↓
0 1 1 0
+ 0 0 1 1
1 0 0 1
76 Arithmetic Circuits
The result 1001 is interpreted as -7. The sign bit shows that it is a
negative number. The correct answer is +9, which is outside the 4-bit 2’s
complement range [-8,+7]. Hence an overflow condition has occurred. The
sum of the two given numbers requires more than the allotted 4 bits to
represent it.
sign bit
↓
0 1 1 0 0
+ 0 0 1 1 1
1 0 0 1 1
The result 10011 is interpreted as -13. The correct answer is +19, which
is outside the 5-bit 2’s complement range [-16,+15]. The sum of the two
given numbers requires more than the allotted 5 bits to represent it.
sign bit
↓
0 0 1 1 0
+ 0 0 0 1 1
0 1 0 0 1
The range for a 5-bit 2’s complement is [-16,+15]. Since the sign bit is 0, it
correctly represents the desired answer which is interpreted as +9.
sign bit
↓
0 0 1 1 0 0
+ 0 0 0 1 1 1
0 1 0 0 1 1
Arithmetic Circuits 77
The range for a 6-bit 2’s complement is [+32,-31]. Since the sign bit is 0, it
correctly represents the desired answer which is interpreted as +19.
The sum is +46 which requires at least 7 bits, where the range for a 7-bit
2’s complement is [-64,+63].
sign bit
↓
0 0 1 0 0 1 1
+ 0 0 1 1 0 1 1
0 1 0 1 1 1 0
Example 1: -3-2 = +6
sign bit
↓
1 1 0 1
+ 1 1 1 0
1/ 1 0 1 1
78 Arithmetic Circuits
Example 2: -12-5
The sum is -17 which requires 6 bits. The range for a 6-bit 2’s
complement is [-32,+31].
1 1 0 1 0 0
+ 1 1 1 0 1 1
1/ 1 0 1 1 1 1
Suppose we use 5 bits to compute -12-5, the answer is 01111 = +15. Note
that the sign bit (0) is incorrect, indicating an overflow. The desired result
(-17) exceeds the number range for a 5-bit 2’s complement [-16,+15].
1 0 1 0 0
+ 1 1 0 1 1
1/ 0 1 1 1 1
Case 3: A-B
Example 1: 3-2 =
+ 3 = 0011
− 2 = −(0010) → 1101 + 1 = 1110
Add the two numbers. Ignore the carry beyond the sign bit. The result is
0001 = +1.
sign bit
↓
0 0 1 1
+ 1 1 1 0
1/ 0 0 0 1
Arithmetic Circuits 79
Example 2: 12-5
+ 12 = 01100
− 5 = −(00101) → 11010 + 1 = 11011
sign bit
↓
0 1 1 0 0
+ 1 1 0 1 1
1/ 0 0 1 1 1
Example 3: 5-12
+ 5 = 00101
− 12 = −(01100) → 10011 + 1 = 10100
sign bit
↓
0 0 1 0 1
+ 1 0 1 0 0
1 1 0 0 1
Case 3: -A+B
Add the two numbers. Ignore the carry beyond the sign bit. The result is
1111 = -1.
sign bit
↓
1 1 0 1
+ 0 0 1 0
1 1 1 1
80 Arithmetic Circuits
The 2’s complement for B is obtained by complementing each bit and then
adding 1 to the LSB.
A 4 A3 A 2 A1
B4 B3 B2 B1
+ 1
S4 S3 S2 S1
Cin= 1 S1
Full
A1 Adder Co
B1
Cin
S2
A2 Full
Co
B2 Adder
Cin
Full S3
A3 Adder Co
B3
Cin
Full S4
A4 Adder
B4
Arithmetic Circuits 81
The diagram shown below is a 4-bit subtractor circuit using a 7483 adder
and NOT gates.
Sign Bit
1 7 4 2 1
4321 4321
74LS83A
A4
A3
A2
A1 s4
B4 s3
B3 s2
B2 s1
B1
Cin Cout Ignore C4
5V
This circuit can only accept values between -7 (1001) and +7 (0111), and
the result is also limited to values between -7 to +7. Some arithmetic
operation can result in an overflow condition if the output result is
beyond the range of valid numbers.
Example 1: 7-1=6
A=7 → 0 1 1 1 → 0 1 1 1
B =1 → 0 0 0 1 → 1 1 1 0
Cin = 1 → + 1 → + 1
0 1 1 0
Example 2: 7-0=7
A=7 → 0 1 1 1 → 0 1 1 1
B=0 → 0 0 0 0 → 1 1 1 1
Cin = 1 → + 1 → + 1
0 1 1 1
82 Arithmetic Circuits
74LS83A
A4
A4..A1 A3
A2
A1 s4
B4 s3 S4..S1
B3 s2
B2 s1
B1
B4..B1
Cin Cout
5V 74LS83A
A4 S8:Bit tanda
A3
A8..A5 A2
A1 s4
B4 s3 S8..S5
B3 s2
B2 s1
B1
B8..B5
Cin Cout Abaikan
This circuit can accept values between -127 (10000001) and +127
(01111111), and the result is also limited to values between -127 to +127.
Example 1: 127-0=127
A = 127 → 0 1 1 1 1 1 1 1
B=0 → 0 0 0 0 0 0 0 0
Cin = 1 → + 1
0 1 1 1 1 1 1 1
→ 1 1 1 1 1 1 1 1
+ 1
0 1 1 1 1 1 1 1
Arithmetic Circuits 83
Example 2: 7-1=6
A=7 → 0 0 0 0 0 1 1 1
B =1 → 0 0 0 0 0 0 0 1
Cin = 1 → + 1
0 1 1 1 1 1 1 1
→ 1 1 1 1 1 1 1 0
+ 1
0 0 0 0 0 1 1 0
The 4-bit adder and subtractor circuits are almost identical. These
circuits can be combined to form an adder-subtractor circuit. The circuit
has an additional input called the control input. If the control input is 0,
the circuit performs addition, A + B + 0 , where Cin=0. If the control input
is 1, the circuit performs subtraction A + B + 1 , where Cin=1.
Cin
S1
Full
A1 Adder Co
B1 ?
Cin
Full
S2
A2 Adder Co
B2 ?
Cin
S3
Full
A3 Co
Adder
B3 ?
Cin
Full
S4
A4
Adder
B4 ?
Control
84 Arithmetic Circuits
Control Y
B ?
Y
Add 0 B
Subtract 1 B
Control
B
Y
Control
The 4 bit adder-subtractor circuit is shown below. When the control input
is 1, the input Cin=1 and the XOR gate will act as inverter to perform
subtraction. When the control input is 0, the input Cin=0 and the XOR
gate has no effect on B.
Cin
S1
Full
A1 Adder Co
B1
Cin
Full
S2
A2 Adder Co
B2
Cin
Full
S3
A3 Adder Co
B3
Cin
Full S4
A4 Adder
B4
Control
Arithmetic Circuits 85
Exercises
a. 3+1 b. 7 - 6 c. 6 - 7 d. –3 –2