(+1) + - Share ITS

Digital Electronics
Principles & Applications
Seventh Edition
Roger L. Tokheim
Chapter 10
Arithmetic Circuits
©2008 The McGraw-Hill Companies, Inc. All rights reserved.
INTRODUCTION
• Binary Addition
• Half & Full Adders
• Binary Subtraction
• Half & Full Subtractors
• Parallel Adders and Subtractors
• Using Adders for Subtraction
• Binary Multiplication
• Binary Multipliers
• 2s Complement Notation
• 2s Complement Adding/Subtracting
©2008 The McGraw-Hill Companies, Inc. All rights reserved.
Binary Addition
• Conceptually similar to decimal addition
• Example: Add the binary numbers 1010 and 11
(carry)
1
1 0 1 0
+
1 1
1 1 0 1
©2008 The McGraw-Hill Companies, Inc. All rights reserved.
QUIZ
Add the Binary numbers 11010 and 1100
(carry)(carry)
1
1
1 1 0 1 0
+ 1 1 0 0
1 0 0 1 1 0
©2008 The McGraw-Hill Companies, Inc. All rights reserved.
Half Adder
• Logic device that adds two binary numbers
• Only adds Least Significant Digit (LSD)
column (1s column) in binary addition
Input
Logic
Symbol:
A
B
Output
Half
Adder
 (sum)
C0 (carry out)
Logic
Diagram:
©2008 The McGraw-Hill Companies, Inc. All rights reserved.
QUIZ
Q#2What
are
the
sum
and
carry
out
outputs
Q#1Q#3This
What
circuit
are
the
is
called
sum
and
a ___.
carry
out
outputs
Q#4What
are
the
sum
and
carry
out
outputs
Q#5What
are
the
sum
and
carry
out
outputs
from
the
half
adder
circuit?
from
the
half
adder
circuit?
from
fromthe
thehalf
halfadder
addercircuit?
circuit?
ANS:
Half-adder
ANS:
Sum=0,
Carry
out=0
ANS:
Sum=1,
Carry
out=0
ANS:
Sum=0,
Carry
ANS: Sum=1, Carryout=1
out=0
AA==00
AA==11
BB==01
BB==10
?
?
©2008 The McGraw-Hill Companies, Inc. All rights reserved.
Full Adder
Used for adding binary place
values other than the 1s place
Input
Logic
Symbol:
Cin
A
B
Output
Full
Adder
 (sum)
C0 (carry out)
Logic
Diagram:
©2008 The McGraw-Hill Companies, Inc. All rights reserved.
QUIZ
Q#2What
are
the
sum
and
carry
out
of
this
Q#1Q#3This
What
combinational
are
the
sum
and
logic
carry
circuit
out
isoutputs
outputs
described
of
as
this
a(n) ___.
Q#4What
are
the
sum
and
carry
out
outputs
of
this
Q#5What
are
the
sum
and
carry
out
outputs
of
this
full-adder
Q#6- What
circuit?
are the sum and carry out outputs of this
full-adder
circuit?
full-adder
circuit?
full-adder
full-addercircuit?
circuit?
ANS:
full-adder
ANS:
Sum=0,
Carry
out=0
ANS:
Sum=1,
Carry
out=0
ANS:
Sum=0,
Carry
out=1
ANS:
Sum=1,
Carry
ANS: Sum=0, Carryout=1
out=1
Cin
==00
Cin
Cin
=1
Cin
Cin==10
AA==00
AA==01
A=1
BB==01
BB==11
B=1
?
?
©2008 The McGraw-Hill Companies, Inc. All rights reserved.
Binary Subtraction
Example:
Subtract binary number 101 from 1011
(borrow)
01
1 0 1 1
- 1 0 1
0 1 1 0
©2008 The McGraw-Hill Companies, Inc. All rights reserved.
QUIZ
Subtract binary number 11 from 1010
0
01
10 1 0
1
1 0 1 0
1 1
0 1 1 1
©2008 The McGraw-Hill Companies, Inc. All rights reserved.
Half Subtractor
Subtracts LSD column in binary subtraction
Input
Logic
Symbol:
A
B
Output
Half
Subtractor
Di (difference)
B0 (borrow out)
Logic
Diagram:
©2008 The McGraw-Hill Companies, Inc. All rights reserved.
QUIZ
Q#1What
isisthe
difference
and
borrow
outputs
from
Q#2What
the
difference
and
borrow
outputs
from
Q#3What
is
the
difference
and
borrow
outputs
from
Q#4What
is
the
difference
and
borrow
outputs
from
This
half-subtractor
circuit?
this
half-subtractor
circuit?
this
thishalf-subtractor
half-subtractorcircuit?
circuit?
ANS:
Di=
0,1,Bo=
00
ANS:
Di=
Bo=
ANS:
Di=
0,
Bo=
ANS: Di= 1, Bo=01
(A
––B)
(A
B)
(A
(A––B)
B)
AA==01
AA==10
BB==00
BB==11
?
?
©2008 The McGraw-Hill Companies, Inc. All rights reserved.
Full Subtractor
Used for subtracting binary place
values other than the 1s place
Input
Logic
Symbol:
Logic
Diagram:
Bin
A
B
Bin
A
B
Output
Full
Subtractor
H. S.
H. S.
Di (difference)
B0 (borrow out)
Di
B0
©2008 The McGraw-Hill Companies, Inc. All rights reserved.
QUIZ
Q#1What
are
the
Difference
and
Borrow
out
output
from
Q#2What
are
the
Difference
and
Borrow
out
output
from
Q#3What
are
the
Difference
and
Borrow
out
output
from
Q#4What
are
the
Difference
and
Borrow
out
output
from
this
Q#5full-subtractor
What
are
the
circuit?
Difference
and
Borrow
out
output
from
this
Q#6full-subtractor
What
are
the
circuit?
Difference
and
Borrow
out
output
from
this
full-subtractor
circuit?
this
full-subtractor
circuit?
this
thisfull-subtractor
full-subtractorcircuit?
circuit?
HINT: truth table
from textbook
is helpful
ANSWER:
Di
==0,1,(Fig.
Bo
==10-10)
01
ANSWER:
Di
Bo
ANSWER:
Di
==1,0,Bo
==11
ANSWER:
Di
Bo
ANSWER:
Di
=
1,
Bo
ANSWER: Di = 0, Bo==00
(A
––BB--Bin)
(A
(A
––BB-Bin)
(A
-Bin)
Bin
(A
–
=
B
0
-Bin)
Bin
(A
–
=
B
1
-Bin)
Bin)
Bin
=
1
Bin
=
1
Bin
Bin==00
AA==00
AA==10
AA==11
BB==00
BB==11
BB==01
?
?
©2008 The McGraw-Hill Companies, Inc. All rights reserved.
Parallel Adding
A 2 A1 A0
+ B 2 B1 B0
• Use half adder for LSD
• Use full adder for other digits
©2008 The McGraw-Hill Companies, Inc. All rights reserved.
Parallel Adder
+ 110011011010
+
011011101100+
011110001110110
SUM appears here
Parallel adders are available in IC form.
1s place uses half-adder
2s, 4s, 8s places use full adders
©2008 The McGraw-Hill Companies, Inc. All rights reserved.
QUIZ
Q#1With
the
top
fullparallel
adder’sadder
Cin input
LOW,
this
operates
Q#2When
the
4-bit
adds
binary
1100
and
0011
Q#3When
the
4-bit
parallel
adder
adds
binary
0111
and
1001
Q#4When
the
4-bit
parallel
adder
adds
binary
1101
and
1001
as
a
Q#5half-adder
When
the
while
4-bit
the
parallel
bottom
adder
three
are
adds
full
binary
adders.
0011
(T
and
or
F)
0110
the
Q#6sum
appearing
When
the
4-bit
at
the
parallel
lower
right
adder
will
adds
be
___.
binary
1111
and
1111
the
Q#7sum
appearing
When
the
4-bit
at
the
parallel
lower
right
adder
will
adds
be
___.
binary
1010
and
1001
the
sum
appearing
at
the
lower
right
will
be
___.
the
sum
appearing
at
the
lower
right
will
be
___.
the
thesum
sumappearing
appearingat
atthe
thelower
lowerright
rightwill
willbe
be___.
___.
4-bit number
4-bit number
ANS:
True
ANS:
01111
ANS:
10000
ANS:
10110
ANS:
01001
ANS:
ANS: 11110
10011
©2008 The McGraw-Hill Companies, Inc. All rights reserved.
Parallel Subtractor Using Full Adders
11101011--00011111
Inverters
10 10 01 00
Thefull
result
(difference) of the
Note the use of four
adder
subtraction problem will appear here.
circuits
Also notice the addition of four
inverters on the B inputs to the FAs
©2008 The McGraw-Hill Companies, Inc. All rights reserved.
Binary Multiplication
Example:
Multiply the binary numbers 111 and 101.
1 1 1
x 1 0 1
1 1 1
0 0 0
1 1 1
10 0 0 1 1
Multiplicand
Multiplier
1st partial product
2nd partial product
3rd partial product
Product
111 x 101 can also be calculated: 111 + 111 + 111 + 111 + 111
©2008 The McGraw-Hill Companies, Inc. All rights reserved.
QUIZ
Multiply the binary numbers 101 and 100.
1 0 1
x 1 0 0
0 0 0
0 0 0
1 0 1
1 0 1 0 0
©2008 The McGraw-Hill Companies, Inc. All rights reserved.
Binary Multipliers
Binary multiplier circuits –
utilize repeated addition.
Block
Diagram:
Multiplicand
register
Adder
Multiplier
down counter
Product
register
©2008 The McGraw-Hill Companies, Inc. All rights reserved.
2s Complement Notation
• 2s complement representation - widely
used in microprocessors.
• Represents sign and magnitude
MSB
LSB
Sign bit (0 = + ; 1 = -)
Decimal:
2s Complement:
+7
0111
+4
+1
0
-1
-4
-7
0100 0001 0000 1111 1100 1001
©2008 The McGraw-Hill Companies, Inc. All rights reserved.
2s Complement - Conversions
• Converting positive numbers to 2s complement:
• Same as converting to binary
• Converting negative numbers to 2s complement:
Decimal to 2s
Complement
- 4 (decimal)
Convert decimal
to binary
0100
1s
complement
1011
Add 1
- 4 = 1 1 0 0 (2s Complement)
2s Complement to
Binary
1 1 0 0 (2s C)
1s
complement
0011
Add 1
0 1 0 0 (Binary)
©2008 The McGraw-Hill Companies, Inc. All rights reserved.
QUIZ
Q#1Convert
the
decimal
number
–4
toto2s2scomplement.
Q#2Convert
the
decimal
number
–-7
complement.
Q#3Convert
the
decimal
number
–1
toto2s
complement.
Q#4Convert
the
decimal
number
+6
2s
Q#5- Convert the decimal number -8 to 2s complement.
complement.
47(decimal)
16(decimal)
(decimal)
8 (decimal)
(decimal)
Step 1: convert decimal to binary
0100
0111
0001
0110
1000
Step 2: convert to 1s complement
1011
1000
Not1110
needed
0111
Step 3: add +1 equaling 2s complement
1100
2s
CC
1001
2s
1111
2s
C
Not
needed
1000
2sC
ANS:
-4
2sC
ANS:
-7-1===1100
1001
2sC
ANS:
1111
2sC
ANS:
+6
=
0110
ANS: -8 = 10002sC
2sC
©2008 The McGraw-Hill Companies, Inc. All rights reserved.
QUIZ
Q#1Convert
the
2s
complement
number
1110
totodecimal.
Q#2Convert
the
2s
complement
number
0101
decimal.
Q#3Convert
the
2s
complement
number
1001
Q#4- Convert the 2s complement number 1111 to
to decimal.
decimal.
Not1110
needed
1001
1111
Step 1: convert to 1s complement
Not0001
needed
0110
0000
Step 2: Add +1
0010
binary
0101
binary
0111
0001binary
binary
Step 3: convert binary to decimal
25decimal
71decimal
decimal
decimal
ANS:
1110
2sC
==-2
decimal
ANS:
0101
2sC
+5
decimal
ANS:
1001
2sC
=
-7
ANS: 1111 2sC = -1decimal
decimal
©2008 The McGraw-Hill Companies, Inc. All rights reserved.
Adding/Subtracting in 2s Complement
2s complement notation makes it possible
to add and subtract signed numbers
(Decimal)
(- 1)
+ (- 2)
2s
Complement
1111
+ 1110
1 11 0 1
(- 3)
2s complement
Discard
(+1)
+ (- 3)
0001
+ 1101
(- 2)
11 1 0
2s complement
©2008 The McGraw-Hill Companies, Inc. All rights reserved.
QUIZ
Add the following 2s complement numbers:
(+5)
+ (- 4)
0 1 0 1
+ 1 1 0 0
(+1)
1 0 0 0 1
Discard
©2008 The McGraw-Hill Companies, Inc. All rights reserved.
Practical Suggestion for Binary Math
• Use a scientific calculator.
• Most scientific calculators have
DEC, BIN, OCT, and HEX modes
and can either convert between
codes or perform arithmetic in
different number systems.
• Most scientific calculators also
have other functions that are
valuable in digital electronics
such as AND, OR, NOT, XOR,
and XNOR logic functions.
©2008 The McGraw-Hill Companies, Inc. All rights reserved.
REVIEW
• Binary Addition
• Half & Full Adders
• Binary Subtraction
• Half & Full Subtractors
• Parallel Adders and Subtractors
• Using Adders for Subtraction
• Binary Multiplication
• Binary Multipliers
• 2s Complement Notation
• 2s Complement Adding/Subtracting
©2008 The McGraw-Hill Companies, Inc. All rights reserved.