Binary Arithmetic and Arithmetic Circuits-2
Binary Arithmetic and Arithmetic Circuits-2
1
Institute of Lifelong Learning, University of Delhi
Binary Arithmetic and Arithmetic Circuits-2
Arithmetic Circuits-2
Table of Contents
2
Institute of Lifelong Learning, University of Delhi
Binary Arithmetic and Arithmetic Circuits-2
2.2 Introduction
Logic circuits in digital systems are broadly classified as A) Combinational logic circuits B)
Sequential logic circuits. A combinational circuit is one whose output at any time is
determined from the present combination of inputs whereas the outputs of sequential
circuits at any time depend not only on present value of inputs but also on the past inputs.
Arithmetic circuits are the examples of combinational circuits.
Feedback
Arithmetic circuits are the circuits that perform arithmetic operations such as addition and
subtraction, examples of arithmetic circuit are adders and subtractors. Adders are important
in digital systems in which numerical data are processed. In this section adders, subtractor
and adder/subtractor are introduced.
2.4 Adder
The half adder accepts two binary digits on its input and provides two binary digits on its
outputs, a sum bit and a carry bit. The logic symbol of half adder is given in figure 2.
A Σ Sum
Input bits Output bits
B Cout Carry
3
Institute of Lifelong Learning, University of Delhi
Binary Arithmetic and Arithmetic Circuits-2
The truth table for half adder is given as
A B Cout Σ
0 0 0 0
0 1 0 1
1 0 0 1
1 1 1 0
Σ Sum
Cout=Carry
A & B are the input variables
Tip to memorize
Whenever odd number of 1 is present in truth table then sum will be high.
When both inputs are 1 then only carry will be high.
From the above truth table the Boolean expression for sum and carry are
S AB AB A B
C AB
A half adder can therefore be realized by using one X-OR gate (for sum operation) and one
AND gate (for carry operation). The logic circuit for half adder is shown in figure 3
Figure 4: Circuit diagram for half adder implemented using NAND gates only
4
Institute of Lifelong Learning, University of Delhi
Binary Arithmetic and Arithmetic Circuits-2
Sum A AB B AB
A AB B AB
A ( A B) B ( A B)
A A AB B A B B
AB AB
Carry AB AB
Try yourself
Draw logic circuit for half adder using only NOR gates only.
Solution:
A half adder has only two inputs and there is no provision to add a carry coming from the
lower bits even in the case of 4 bit addition operation. For this another circuit is required
which can add three bits simultaneously. A full adder is a combinational logic circuit that
performs the arithmetic addition of three input bits. The full adder accepts two input bits
and input carry and generates a sum output and an output carry. So a full adder has three
inputs and two outputs. The logic symbol of full adder is given in figure 5
B Output bits
Input Carry Cin Cout Carry
5
Institute of Lifelong Learning, University of Delhi
Binary Arithmetic and Arithmetic Circuits-2
Two of the input variables denoted by A and B represent the two significant bits to be
added. The third input Cin represents the carry from the previous lower significant position.
Table 2 shows the truth table for a full adder.
A B Cin Cout Σ
0 0 0 0 0
0 0 1 0 1
0 1 0 0 1
0 1 1 1 0
1 0 0 0 1
1 0 1 1 0
1 1 0 1 0
1 1 1 1 1
Σ Sum
Cin=Input Carry
Cout=Output Carry
A, B & Cin are the input variables
Tip to memorize
When the number of 1’s in truth table is odd then the output for sum would be high. i.e it will follow a three
input XOR gate function. Whenever the number of 1’s in truth table appear more than once, then carry will be
high.
When both inputs are 1 then only carry will be high.
C C
0 1
AB
AB 1 0
AB 0 1
1 0
AB
6
Institute of Lifelong Learning, University of Delhi
Binary Arithmetic and Arithmetic Circuits-2
C C
AB 0 0
AB 1
0
1
AB 1
AB 0 1
From the above Boolean expression we can design the logic circuit for full adder. Students
are advised to first design the circuit on their own and then verify their results. Figure 6
shows the simplified circuit diagram of Full adder
Full adder can also be designed using two half adders. Logic circuit of Full adder using two
half adders is given in figure 7
7
Institute of Lifelong Learning, University of Delhi
Binary Arithmetic and Arithmetic Circuits-2
Figure 8: Complete logic circuit of Full adder using two half adders
The sum output of the first half adder is the exclusive OR (X-OR) of two input variables
A B . This output is fed as input for the second half adder. The second input variable for
the second half adder is Cin (carry input). Therefore this input carry Cin must be exclusive
ORed with A B , yielding the equation for the sum
Sum, A B Cin
AB AB Cin AB AB C in
A B A B Cin ABC in ABC in
AB AB Cin ABC in ABC in
ABC in ABCin ABC in ABC in
The output carry is a 1 when both inputs to the first XOR gate are 1s or when both inputs to
the second XOR gate are 1s. The output carry of the full adder is therefore produced by the
inputs A ANDed with B and A B ANDed with Cin. These two terms are ORed and the
expression is given as
8
Institute of Lifelong Learning, University of Delhi
Binary Arithmetic and Arithmetic Circuits-2
COut AB A B Cin
AB AB AB Cin
AB ABC in ABCin
A B BCin ABC in
AB Cin ABC in
AB AC in ABC in
AB A AB Cin
AB A B Cin
AB AC in BC in
Try Yourself
9
Institute of Lifelong Learning, University of Delhi
Binary Arithmetic and Arithmetic Circuits-2
Value Addition
More complex adders
Ripple-carry adder
It is possible to create a logical circuit using multiple full adders to add N-bit numbers. Each
full adder inputs a Cin, which is the Cout of the previous adder. This kind of adder is called
a ripple-carry adder, since each carry bit "ripples" to the next full adder. The first (and only
the first) full adder may be replaced by a half adder (under the assumption that Cin = 0).
The layout of a ripple-carry adder is simple, which allows for fast design time; however, the
ripple-carry adder is relatively slow, since each full adder must wait for the carry bit to be
calculated from the previous full adder.
Carry-lookahead adder
A carry-look ahead adder (CLA) is a type of adder used in digital logic. A carry-look
ahead adder improves speed by reducing the amount of time required to determine carry
bits. It can be constructed with the simpler, but usually slower, ripple carry adder for which
the carry bit is calculated alongside the sum bit, and each bit must wait until the previous
carry has been calculated to begin calculating its own result and carry bits. The carry-look
ahead adder calculates one or more carry bits before the sum, which reduces the wait time
to calculate the result of the larger value bits. The Kogge-Stone adder and Brent-Kung
adder are examples of this type of adder.
Gerald Rosenberger of IBM filed for a patent on a modern binary carry-look ahead adder in
1957.
From Wikipedia, the free encyclopedia:
http://en.wikipedia.org/wiki/Adder_(electronics)#Full_adder
10
Institute of Lifelong Learning, University of Delhi
Binary Arithmetic and Arithmetic Circuits-2
2.5 Subtractor
Trivia
Half Subtractor: The circuit which will subtract two bits and produce a borrow and difference.
Full Subtractor: The circuit which will subtract three bits and produce a borrow and difference.
The half subtractor needs two inputs a minuend and a subtrahend bit and output bits are
borrow and difference. The logic symbol of the half subtractor is given in figure 9.
A Borrow
Input bits Output bits
B Difference
A B Difference Borrow
0 0 0 0
0 1 1 1
1 0 1 0
1 1 0 0
A & B are the input variables
Difference AB AB A B
Borrow AB
Students are advised to design logic circuits using the above Boolean expression and verify
their diagram (see figure 10)
11
Institute of Lifelong Learning, University of Delhi
Binary Arithmetic and Arithmetic Circuits-2
Half subtractor can be realized using NAND gates only and is given in figure 11
Figure 11: Logic circuit for Half subtractor using NAND gates only
Difference A AB B AB
A AB B AB
A A B B A B
AB B A
Borrow B AB B AB B A B AB
12
Institute of Lifelong Learning, University of Delhi
Binary Arithmetic and Arithmetic Circuits-2
Try Yourself
Design half subtractor using NOR gates only and obtain Boolean expression for difference &
borrow
Difference A A B B A B
A A B B A B
A A B B A B
AB AB
Borrow A A B A( A B) AB
The half subtractor can be used only for LSB subtraction. If there is a borrow during the
subtraction of the LSBs, it affects the subtractions in the next higher column; the
subtrahend bit is subtracted from the minuend bit, considering the borrow from that column
used for the subtraction in the preceding column. Such a subtraction is performed by a full
subtractor. It subtracts one bit (B) from another bit (A), when already there is a borrow B in
from the column for the subtraction in the preceding column, and outputs the difference bit
and the borrow bit required from the next column. The block diagram and the truth table of
a full subtractor are shown below:
13
Institute of Lifelong Learning, University of Delhi
Binary Arithmetic and Arithmetic Circuits-2
1 0 0 0 1
1 0 1 0 0
1 1 0 0 0
1 1 1 1 1
Bin=Input Borrow
Bout=Borrow
A, B & Bin are the input variables
A Difference
Input bits
B Output bits
Input Borrow
Bin Bout Borrow
The difference and borrow for full subtractor are evaluated as:
Figure 12: Block diagram of Full subtractor using two half subtractors
14
Institute of Lifelong Learning, University of Delhi
Binary Arithmetic and Arithmetic Circuits-2
The complete circuit diagram of Full subtractor is given in figure 13.
The full subtractor can also be realized in Universal logic using either only NAND gates and
is shown in figure 14.
2.6 Adder/Subtractor
The 4-bit parallel Adder/Subtractor can perform the operation of addition and subtraction.
The logic circuit is given in Figure 15
The circuit is used for addition or subtraction of 4 bit inputs A 3A2A1A0 and B3B2B1B0.
A3 A2 A1 A0
B3 B2 B1 B0
8s 4s 2s 1s
The circuit can either do addition or can do subtraction which is controlled by a control line,
but both the operation can not be performed simultaneously.
15
Institute of Lifelong Learning, University of Delhi
Binary Arithmetic and Arithmetic Circuits-2
Control A B Y
0 0 0 0
0 1 1
1 1 0 1
1 1 0
When the control line is low i.e 0, then when a 0 is placed in input A of the XOR gates, the
bits pass through the XOR gate with no change. This can be verified from the truth table
that when A is 0 the output is the same as that of the input present at the input B. With the
control at 0, the inputs available at the Full Adders (FA) are A3A2A1A0, B3B2B1B0 and Cin. The
AND gate is disabled as one of the input is zero. Since the output of the AND gate is zero
16
Institute of Lifelong Learning, University of Delhi
Binary Arithmetic and Arithmetic Circuits-2
so there is no end carry Cin input for FA (1s). Thus with the control at 0 the units add the
binary number A3A2A1A0 to B3B2B1B0. The result appears at the output indicators.
When the control bit is in 1 position this causes the XOR gate to act as an inverter for the B
inputs to the full adders. From the truth table it can be verified that when control is in 1
position. The output is complement of B input. The 1 at the control bit also activates the
AND gate so that the information from the 8s Full adder can take the end around carry line
back to the 1s full adder. This subtractor, subtracts the binary input number B 3B2B1B0 from
A3A2A1A0. With 2’s complement method.
Taking an example as
10 1010
-6 -0110
4 0100
With the control line at 1, the inputs at FA as A3A2A1A0 and B3B2B1B0. i.e. 1’s complement of
input B3B2B1B0 first take place.
1010
After 1’s complement of Minuend
and finally adding Minuend and 1001
Subtrahend.
10011
End around carry + 1
0100(difference)
17
Institute of Lifelong Learning, University of Delhi
Binary Arithmetic and Arithmetic Circuits-2
Adding machine
Blaise Pascal and Wilhelm Schickard were the two original inventors of the mechanical
calculator in 1642; For Pascal this was an adding machine that could perform additions and
subtractions directly and multiplication and divisions by repetitions, whilst Schickard's
machine, invented several decades earlier was less functionally efficient but was supported
by a mechanized form of multiplication tables. These two were followed by a string of
inventors and inventions leading to those ofThomas de Colmar who launched the
mechanical calculator industry in 1851 when he released his simplified arithmometer (it
took him thirty years to refine his machine, patented in 1820, into a simpler and more
reliable form). However, they didn't gain widespread use until Dorr E. Felt started
manufacturing his comptometer (1887) and Burroughs started the commercialization of
differently conceived adding machines (1892)
An adding machine
Summary
A combinational circuit is one whose output at any time is determined from the
present combination of inputs with no storage or memory capability.
The truth table for half adder is summarized as
A B Cout Sum
0 0 0 0
0 1 0 1
1 0 0 1
1 1 1 0
A B Difference Borrow
0 0 0 0
0 1 1 1
1 0 1 0
1 1 0 0
19
Institute of Lifelong Learning, University of Delhi
Binary Arithmetic and Arithmetic Circuits-2
A 4-bit parallel Adder/Subtractor can be designed using full adders only and can
perform both addition and subtraction operation.
2.8 Exercises
2.8.1 Subjective Questions
1) Draw the circuit diagram of Half Adder using NAND gate only. Describe the operation
performed by Half adder.
2) Draw a block diagram of a full adder labeling all the inputs and outputs. Write the truth table
for full adder.
3) Draw the circuit diagram of Half Subtractor using NAND gate only. Describe its operation.
4) Draw a block diagram of a full Subtractor labeling all the inputs and outputs. Write the truth
table for full Subtractor.
5) Draw the Half Adder circuit using two input NOR gate.
6) Draw the Full Adder circuit using two input NOR gate.
7) Draw the Half Subtractor circuit using two input NOR gate.
8) Draw the Half Subtractor circuit using two input NOR gate.
9) Draw a logic circuit that has three inputs A, B and C and whose output will be high only
when majority inputs are high.
1) A half adder circuit is used for adding only the ………………. (1s, 2s, 4s, 8s) column of a
binary addition problem.
2) Adder circuits are widely used in ………………. Section of microprocessor.
3) The output of full adder is Σ = 1, Cout =1 when the inputs are ………………. .
4) The input of the full subtractor is A=B=Bin=1 then the output is given as ………………. .
1) 1s
2) Arithmetic logic unit (ALU)
3) 1,1,1
4) Difference = 1 & Borrow = 1
A) 2,3 B) 2, 2
20
Institute of Lifelong Learning, University of Delhi
Binary Arithmetic and Arithmetic Circuits-2
C) 3, 2 D) 3, 3
4) The control line should be kept ………………. For performing subtraction using 4 bit
adder/subtractor
A) 0 B)1
C) 11 D) 10
1) 3,2
Justification: Full Subtractor has 3 inputs A, B, Bin and 2 outputs namely difference
and Borrow output
4) 1
Justification: With Control line at 1, the Adder/subtractor subtracts two number using
2’s complement method.
21
Institute of Lifelong Learning, University of Delhi
Binary Arithmetic and Arithmetic Circuits-2
2.9 Glossary
Combinational Logic Circuit A combinational logic circuit is one whose output at any time
is determined from the present combination of inputs
Half Adder A digital circuit that adds two bits and produces a sum and a carry.
Full Adder A digital circuit which adds two bits and an input carry to produce a sum and an
output carry
Half Subtractor A digital circuit that subtracts two bits and produces difference and a
borrow if any.
Full Subtractor It subtracts one bit (B) from another bit (A), when already there is a
borrow Bin from the column for the subtraction in the precedingcolumn, and outputs the
difference bit and a borrow bit.
Digital Principles & Applications, A.P.Malvino, D.P.Leach & Saha, 7th Ed., 2011, Tata
McGraw
Fundamentals of Digital Circuits, A. Anand Kumar, 2nd Edition, 2009, PHI Learning
Pvt. Ltd.
Digital Electronics, Principles and applications, Roger L Tokheim, 2003, Tata McGraw
Hill.
Digital Systems: Principles and Applications, R.J. Tocci, N.S.Widmer, 2001, PHI
Learning.
Digital Electronics, An introduction to theory and practice, W H Gothmann, 1982, PHI
Learning.
22
Institute of Lifelong Learning, University of Delhi