CH 3 DLD

Download as pdf or txt
Download as pdf or txt
You are on page 1of 45

Digital Logic Design

CHAPTER 3
Number Systems and Arithmetic Circuits

1
Decimal Numbers
• The decimal number system has ten digits:
0, 1, 2, 3, 4, 5, 6, 7, 8, and 9
• The decimal numbering system has a base
of 10 with each position weighted by a
factor of 10:

2
Binary Numbers
• Two digits called bits
• 0 or 1
• Right most bit is least significant bit
• Left most bit is most significant bit
• Each position is weighted by a factor of 2.
2 2 2 2 .2 2 2 2
3 2 1 0 -1 -2 -3 -4

Decimal point

3
Counting in Binary
Decimal Number Binary Number

23 22 21 20
0 0 0 0 0
1 0 0 0 1
2 0 0 1 0
3 0 0 1 1
4 0 1 0 0
5 0 1 0 1
6 0 1 1 0
7 0 1 1 1
8 1 0 0 0
9 1 0 0 1
10 1 0 1 0
11 1 0 1 1
12 1 1 0 0
13 1 1 0 1
14 1 1 1 0
15 1 1 1 1
4
Binary Numbers
• The binary number system has two digits:
0 and 1

• The binary numbering system has a base of 2 with


each position weighted by a factor of 2:

5
Binary to Decimal
• Add the weights of all the bits that are 1.
• Ignore the bits that are 0.

• Convert 1101101 to decimal.


1st determine the weights
26 25 24 23 22 21 20
1 1 0 1 1 0 1
1 1 0 1 1 0 1 = 2 6 + 2 5 + 2 3 + 2 2 + 20
= 64 + 32 + 8 + 4 + 1
= 109
6
Decimal-to-Binary Conversion
• Sum-of-weights method
• Repeated division-by-2 method
• Conversion of decimal fractions to
binary

7
Repeated Division by 2
• Divide the number by 2 and write down the
remainder.
• Continue the process until the whole-
number quotient is 0.

• Convert decimal 19 to binary.


• Convert decimal 45 to binary.

8
Decimal Fractions
• Repeated multiplication by 2
• Multiply the decimal fraction by 2
• Write down the carry bit if more than 1
• Continue process until you have the
desired number of bits or when the
fractional part is all zeros.

9
• Convert 0.3125 to binary
Carry MSB LSB
0.0 1 0 1
0.3125 X 2 = 0.625 0
0.625 X 2 = 1.25 1
0.25 X 2 = 0.50 0
0.50 X 2 = 1.00 1

10
Complements of Binary
Numbers
• 1’s complement
• Change all 1s to 0s and all 0s to 1s

11
Complements of Binary
Numbers
• 2’s complement
• Find 1’s complement and then add 1

12
Signed Numbers
• Signed-magnitude form
– The sign bit is the left-most bit in a signed
binary number
– A 0 sign bit indicates a positive magnitude
– A 1 sign bit indicates a negative magnitude

• 1’s complement form


– A negative value is the 1’s complement of the
corresponding positive value
• 2’s complement form
– A negative value is the 2’s complement of the
corresponding positive value
13
Signed Numbers
• Decimal value of signed numbers
– Sign-magnitude
– 1’s complement
– 2’s complement
• Range of Values
Total combinations = 2n
2’s complement form:
– (2n – 1) to + (2n – 1 – 1)
Range for 8 bit number:
n=8
-(28-1) = -27 = -128 minimum
+(28-1) – 1 = +27 - 1 = +127 maximum
Total combination of numbers is 28 = 256.
14
Signed Numbers
Range for 16 bit number:
n = 16
-(216-1) = -215 = -32768 minimum
+(216-1) - 1 = +215 = +32767 maximum
Total combinations is 216 = 65536 (64K)

8 bit examples:
10000000 = -128

11111111 = -1

10000001 = -127
01111111 = +127 15
Arithmetic Operations with
Signed Numbers
Addition of Signed Numbers
• The parts of an addition function are:
– Augend - The first number
– Addend - The second number
– Sum - The result
Numbers are always added two at a time.

16
Arithmetic Operations with
Signed Numbers
Four conditions for adding numbers:
1. Both numbers are positive.
2. A positive number that is larger than a
negative number.
3. A negative number that is larger than
a positive number.
4. Both numbers are negative.

17
Arithmetic Operations with
Signed Numbers
Signs for Addition
• When both numbers are positive, the
sum is positive.
• When the larger number is positive and
the smaller is negative, the sum is
positive. The carry is discarded.

18
Arithmetic Operations with
Signed Numbers
Signs for Addition
• When the larger number is negative and
the smaller is positive, the sum is
negative (2’s complement form).
• When both numbers are negative, the
sum is negative (2’s complement form).
The carry bit is discarded.

19
Examples (8 bit numbers)
• Add 7 and 4 (both positive) 00000111 7
+00000100 +4
00001011 11

• Add 15 and -6 (positive > negative) 00001111 15


+11111010 + -6
Discard carry 1 00001001 9

• Add 16 and -24 (negative > positive) 00010000 16


+11101000 + -24
Sign bit is negative so negative 11111000 -8
number in 2’s complement form

• Add -5 and -9 (both negative) 11111011 -5


+11110111 + -9
Discard carry 1 11110010 -14 20
Overflow
• Overflow occurs when number of bits in
sum exceeds number of bits in addend or
augend.
• Overflow is indicated by the wrong sign.
• Occurs only when both numbers are
positive or both numbers are negative
01111101 126
+ 00111010 + 58
_________ ____
10110111 183

Sign Incorrect
Magnitude Incorrect
21
Arithmetic Operations with
Signed Numbers
Subtraction of Signed Numbers
• The parts of a subtraction function are:
– Minuend - The first number
– Subtrahend - The second number
– Difference - The result
Subtraction is addition with the sign of the
subtrahend changed.

22
Arithmetic Operations with
Signed Numbers
Subtraction
• The sign of a positive or negative binary
number is changed by taking its 2’s
complement
• To subtract two signed numbers, take
the 2’s complement of the subtrahend
and add. Discard any final carry bit.

23
Subtraction Examples
• Find 8 minus 3. 00001000 8 Minuend
+11111101 -3 Subtrahend
Discard carry 1 00000101 5 Difference

• Find 12 minus -9. 00001100 12


+00001001 - -9
00010101 21

• Find -25 minus 19. 11100111 -25


+11101101 - 19
Discard carry 1 11010100 -44

• Find -120 minus -30. 10001000 -120


+00011110 - -30
10100110 -90
24
Arithmetic Operations with
Signed Numbers
Multiplication of Signed Numbers
• The parts of a multiplication function are:
– Multiplicand - First number
– Multiplier - Second number
– Product - Result
Multiplication is equivalent to adding a
number to itself a number of times equal to
the multiplier.

25
Arithmetic Operations with
Signed Numbers
There are two methods for multiplication:
• Direct addition
– add multiplicand multiple times equal to the
multiplier
– Can take a long time if multiplier is large
• Partial products
– Similar to long hand multiplication

The method of partial products is the most


commonly used.
26
Arithmetic Operations with
Signed Numbers
Multiplication of Signed Numbers
• If the signs are the same, the product is
positive. (+ X + = + or - X - = +)
• If the signs are different, the product is
negative. (+ X - = - or - X + = -)

27
Multiplication Example
• Both numbers must be in uncomplemented form
• Multiply 3 by -5.
Opposite signs, so product will be negative.
310 = 000000112 00000011 Multiplicand
X 00000101 Multiplier
-510 = 111110112 00000011 First partial product
+ 0000000 Second partial product
00000011 Sum of 1st and 2nd
2’s complement of -5 + 000011 Third partial product
00000101 00001111 Sum and Final Product

Final result is negative, so take 2’s complement.


11110001 is the result which in decimal is -15.
28
Arithmetic Operations with
Signed Numbers
Division of Signed Numbers
• The parts of a division operation are:
– Dividend
dividend
– Divisor =quotient
divisor
– Quotient
Division is equivalent to subtracting the
divisor from the dividend a number of
times equal to the quotient.

29
Arithmetic Operations with
Signed Numbers
Division of Signed Numbers
• If the signs are the same, the quotient is
positive. (+ ÷ + = + or - ÷ - = +)
• If the signs are different, the quotient is
negative. (+ ÷ - = - or - ÷ + = -)

30
Division Example
• Both numbers must be in uncomplemented form
• Divide 01100100 by 00110010.
Both numbers are positive so
quotient will be positive.
quotient: 00000000
Set the quotient to zero initially.
Subtract the divisor from the 01100100 Dividend
dividend by using 2’s complement + 11001110 2’s complement of Divisor

addition. (11001110) 1 00110010 First partial remainder


Ignore the carry bit. Add 1 to quotient: 00000000 + 1 = 00000001
Subtract the divisor from the 00110010 First partial remainder
1st partial remainder using 2’s + 11001110 2’s complement of Divisor
complement addition.
1 00000000 zero remainder
Add 1 to quotient: 00000001 + 1 = 00000010
31
So final quotient is 00000010 and final remainder is 00000000
Basic Arithmetic Circuits
Half-Adder

Simple Binary Addition


0+0=0 Zero plus zero equals zero
0+1=1 Zero plus one equals one
1+0=1 One plus zero equals one
1 + 1 = 10 One plus one equals zero with a carry
of one
Half-Adder
Full-Adder
Design of a Full Adder
• Construct a truth table…
– 3 inputs (2 numbers to
be added and carry in).
– 2 outputs (sum and
– carry out).

Digital Systems: Principles and Applications, 11/e Copyright © 2011, 2007, 2004, 2001, 1998 by Pearson Education, Inc.
Ronald J. Tocci, Neal S. Widmer, Gregory L. Moss Upper Saddle River, New Jersey 07458 • All rights reserved
Full-Adder
• Full adder from two half-adder circuits

is equal to
Parallel Binary Adders
• Two-bit parallel binary adder
Ripple Carry Adder
Parallel Binary Adders

• Four-bit parallel binary adder


Carry Propagation

Riple carry adder (RCA) causes an unstable factor on carry bit
, and produces a longest propagation delay.

The signal from Ci to the output carry Ci+1, propagates through
an AND and OR gates, so, for an n-bit RCA, there are 2n gate
levels for the carry to propagate from input to output.


Because the propagation delay will affect the output signals
on different time, so the signals are given enough time to get
the precise and stable outputs.

The most widely used technique employs the principle of
carry look-ahead to improve the speed of the algorithm.

39
Boolean expression

Pi = Ai ⊕ Bi steady state value


Gi = AiBi steady state value
Output sum and carry
Si = Pi ⊕ Ci
Ci+1 = Gi + PiCi
Gi : carry generate Pi : carry propagate
C0 = input carry
C1 = G0 + P0C0
C2 = G1 + P1C1 = G1 + P1G0 + P1P0C0
C3 = G2 + P2C2 = G2 + P2G1 + P2P1G0 + P2P1P0C0

C3 does not have to wait for C2 and C1 to propagate. 40


Logic diagram of
carry look-ahead generator
C3 is propagated at the same time as C2 and C1.

41
4-bit adder with carry lookahead
Delay time of n-bit CLAA = XOR + (AND + OR) + XOR

42
Binary subtractor
M = 1subtractor ; M = 0adder

43
Binary multiplier
Usually there are more bits in the partial products and it is necessary to use
full adders to produce the sum of the partial products.

And

44
4-bit by 3-bit binary multiplier
For J multiplier bits and K
multiplicand bits we need (J X
K) AND gates and (J − 1) K-
bit adders to produce a
product of J+K bits.

K=4 and J=3, we need 12


AND gates and two 4-bit
adders.

45

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy