©2008 the mcgraw-hill companies, inc. all rights reserved. digital electronics principles &...

29
©2008 The McGraw-Hill Companies, Inc. All rights reserved. Digital Digital Electronics Electronics Principles & Applications Principles & Applications Seventh Edition Seventh Edition Chapter 10 Arithmetic Circuits Roger L. Tokheim ©2008 The McGraw-Hill Companies, Inc. All rights reserved.

Upload: jonah-joseph

Post on 23-Dec-2015

216 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: ©2008 The McGraw-Hill Companies, Inc. All rights reserved. Digital Electronics Principles & Applications Seventh Edition Chapter 10 Arithmetic Circuits

©2008 The McGraw-Hill Companies, Inc. All rights reserved.

Digital ElectronicsDigital Electronics

Principles & ApplicationsPrinciples & ApplicationsSeventh EditionSeventh Edition

Chapter 10Arithmetic Circuits

Roger L. Tokheim

©2008 The McGraw-Hill Companies, Inc. All rights reserved.

Page 2: ©2008 The McGraw-Hill Companies, Inc. All rights reserved. Digital Electronics Principles & Applications Seventh Edition 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

Page 3: ©2008 The McGraw-Hill Companies, Inc. All rights reserved. Digital Electronics Principles & Applications Seventh Edition Chapter 10 Arithmetic Circuits

©2008 The McGraw-Hill Companies, Inc. All rights reserved.

• Conceptually similar to decimal addition

• Example: Add the binary numbers 1010 and 11

Binary Addition

1 0 1 0+ 1 1

(carry)

1

1011

Page 4: ©2008 The McGraw-Hill Companies, Inc. All rights reserved. Digital Electronics Principles & Applications Seventh Edition Chapter 10 Arithmetic Circuits

©2008 The McGraw-Hill Companies, Inc. All rights reserved.

Add the Binary numbers 11010 and 1100

QUIZ

1 1 0 1 0+ 1 1 0 0

(carry)

1

011001

(carry)

1

Page 5: ©2008 The McGraw-Hill Companies, Inc. All rights reserved. Digital Electronics Principles & Applications Seventh Edition Chapter 10 Arithmetic Circuits

©2008 The McGraw-Hill Companies, Inc. All rights reserved.

• Logic device that adds two binary numbers

• Only adds Least Significant Digit (LSD) column (1s column) in binary addition

Half Adder

A

B

(sum)

C0 (carry out)

HalfAdder

Input Output

Logic Symbol:

Logic Diagram:

Page 6: ©2008 The McGraw-Hill Companies, Inc. All rights reserved. Digital Electronics Principles & Applications Seventh Edition Chapter 10 Arithmetic Circuits

©2008 The McGraw-Hill Companies, Inc. All rights reserved.

?

?

QUIZ

Q#1- This circuit is called a ___.

ANS: Half-adder

Q#2- What are the sum and carry out outputsfrom the half adder circuit?

A = 0

B = 0

ANS: Sum=0, Carry out=0

Q#3- What are the sum and carry out outputsfrom the half adder circuit?

A = 0

B = 1

ANS: Sum=1, Carry out=0

Q#4- What are the sum and carry out outputsfrom the half adder circuit?

A = 1

B = 1

ANS: Sum=0, Carry out=1

Q#5- What are the sum and carry out outputsfrom the half adder circuit?

A = 1

B = 0

ANS: Sum=1, Carry out=0

Page 7: ©2008 The McGraw-Hill Companies, Inc. All rights reserved. Digital Electronics Principles & Applications Seventh Edition Chapter 10 Arithmetic Circuits

©2008 The McGraw-Hill Companies, Inc. All rights reserved.

Used for adding binary place values other than the 1s place

Full Adder

Logic Symbol:

Logic Diagram:

AB

(sum)

C0 (carry out)

FullAdder

Input Output

Cin

Page 8: ©2008 The McGraw-Hill Companies, Inc. All rights reserved. Digital Electronics Principles & Applications Seventh Edition Chapter 10 Arithmetic Circuits

©2008 The McGraw-Hill Companies, Inc. All rights reserved.

QUIZ

?

?

Q#1- This combinational logic circuit is described as a(n) ___.

ANS: full-adder

Q#2- What are the sum and carry out outputs of thisfull-adder circuit?

Cin = 0

A = 0

B = 0

ANS: Sum=0, Carry out=0

Q#3- What are the sum and carry out outputs of thisfull-adder circuit?

Cin = 0

A = 0

B = 1

ANS: Sum=1, Carry out=0

Q#4- What are the sum and carry out outputs of thisfull-adder circuit?

Cin = 1

A = 0

B = 1

ANS: Sum=0, Carry out=1

Q#5- What are the sum and carry out outputs of thisfull-adder circuit?

Cin = 1

A = 1

B = 1

ANS: Sum=1, Carry out=1

Q#6- What are the sum and carry out outputs of thisfull-adder circuit?

Cin = 0

A = 1

B = 1

ANS: Sum=0, Carry out=1

Page 9: ©2008 The McGraw-Hill Companies, Inc. All rights reserved. Digital Electronics Principles & Applications Seventh Edition Chapter 10 Arithmetic Circuits

©2008 The McGraw-Hill Companies, Inc. All rights reserved.

Example: Subtract binary number 101 from 1011

Binary Subtraction

1 0 1 1- 1 0

1

(borrow)

0110

10

Page 10: ©2008 The McGraw-Hill Companies, Inc. All rights reserved. Digital Electronics Principles & Applications Seventh Edition Chapter 10 Arithmetic Circuits

©2008 The McGraw-Hill Companies, Inc. All rights reserved.

Subtract binary number 11 from 1010

QUIZ

1 0 1 0- 1 1

1110

1100 001

1

Page 11: ©2008 The McGraw-Hill Companies, Inc. All rights reserved. Digital Electronics Principles & Applications Seventh Edition Chapter 10 Arithmetic Circuits

©2008 The McGraw-Hill Companies, Inc. All rights reserved.

Subtracts LSD column in binary subtraction

Half Subtractor

A

B

Di (difference)

B0 (borrow out)

HalfSubtractor

Input Output

Logic Symbol:

Logic Diagram:

Page 12: ©2008 The McGraw-Hill Companies, Inc. All rights reserved. Digital Electronics Principles & Applications Seventh Edition Chapter 10 Arithmetic Circuits

©2008 The McGraw-Hill Companies, Inc. All rights reserved.

QUIZ

?

?

Q#1- What is the difference and borrow outputs fromThis half-subtractor circuit?

(A – B)

A = 0

B = 0

ANS: Di= 0, Bo= 0

Q#2- What is the difference and borrow outputs fromthis half-subtractor circuit?

(A – B)

A = 1

B = 0

ANS: Di= 1, Bo= 0

Q#3- What is the difference and borrow outputs fromthis half-subtractor circuit?

(A – B)

A = 1

B = 1

ANS: Di= 0, Bo= 0

Q#4- What is the difference and borrow outputs fromthis half-subtractor circuit?

(A – B)

A = 0

B = 1

ANS: Di= 1, Bo= 1

Page 13: ©2008 The McGraw-Hill Companies, Inc. All rights reserved. Digital Electronics Principles & Applications Seventh Edition Chapter 10 Arithmetic Circuits

©2008 The McGraw-Hill Companies, Inc. All rights reserved.

Used for subtracting binary place values other than the 1s place

Full Subtractor

Logic Symbol:

Logic Diagram:

AB

Di (difference)

B0 (borrow out)

FullSubtractor

Input Output

Bin

AB

DiB0H. S.

H. S.Bin

Page 14: ©2008 The McGraw-Hill Companies, Inc. All rights reserved. Digital Electronics Principles & Applications Seventh Edition Chapter 10 Arithmetic Circuits

©2008 The McGraw-Hill Companies, Inc. All rights reserved.

QUIZ

?

?

Q#1- What are the Difference and Borrow out output fromthis full-subtractor circuit?

(A – B - Bin)Bin = 0

A = 0

B = 0

HINT: truth table from textbook (Fig. 10-10) is helpfulANSWER: Di = 0, Bo = 0

Q#2- What are the Difference and Borrow out output fromthis full-subtractor circuit?

(A – B - Bin)Bin = 1

A = 0

B = 0

ANSWER: Di = 1, Bo = 1

Q#3- What are the Difference and Borrow out output fromthis full-subtractor circuit?

(A – B - Bin)Bin = 1

A = 1

B = 1

ANSWER: Di = 1, Bo = 1

Q#4- What are the Difference and Borrow out output fromthis full-subtractor circuit?

(A – B - Bin)Bin = 1

A = 0

B = 1

ANSWER: Di = 0, Bo = 1

Q#5- What are the Difference and Borrow out output fromthis full-subtractor circuit?

(A – B - Bin)Bin = 0

A = 1

B = 0

ANSWER: Di = 1, Bo = 0

Q#6- What are the Difference and Borrow out output fromthis full-subtractor circuit?

(A – B - Bin)Bin = 0

A = 1

B = 1

ANSWER: Di = 0, Bo = 0

Page 15: ©2008 The McGraw-Hill Companies, Inc. All rights reserved. Digital Electronics Principles & Applications Seventh Edition Chapter 10 Arithmetic Circuits

©2008 The McGraw-Hill Companies, Inc. All rights reserved.

• Use half adder for LSD

• Use full adder for other digits

Parallel Adding

A2 A1 A0

+ B2 B1 B0

Page 16: ©2008 The McGraw-Hill Companies, Inc. All rights reserved. Digital Electronics Principles & Applications Seventh Edition Chapter 10 Arithmetic Circuits

©2008 The McGraw-Hill Companies, Inc. All rights reserved.

Parallel Adder

1s place uses half-adder

2s, 4s, 8s places use full adders

SUM appears here

Enter binary

numbersto be added here0 0 1 1 + 1 0 0

0

0 1 0 1 1

1 1 0 0 + 1 1 1 1

1 1 0 1 11 0 1 0 0

1 1 1 0 + 0 1 1 0

Parallel adders are available in IC form.

©2008 The McGraw-Hill Companies, Inc. All rights reserved.

Page 17: ©2008 The McGraw-Hill Companies, Inc. All rights reserved. Digital Electronics Principles & Applications Seventh Edition Chapter 10 Arithmetic Circuits

©2008 The McGraw-Hill Companies, Inc. All rights reserved.

QUIZQ#1- With the top full adder’s Cin input LOW, this operatesas a half-adder while the bottom three are full adders. (T or F)

4-bit number 4-bit number

Q#2- When the 4-bit parallel adder adds binary 1100 and 0011the sum appearing at the lower right will be ___. Q#3- When the 4-bit parallel adder adds binary 0111 and 1001the sum appearing at the lower right will be ___. Q#4- When the 4-bit parallel adder adds binary 1101 and 1001the sum appearing at the lower right will be ___. Q#5- When the 4-bit parallel adder adds binary 0011 and 0110the sum appearing at the lower right will be ___. Q#6- When the 4-bit parallel adder adds binary 1111 and 1111the sum appearing at the lower right will be ___. Q#7- When the 4-bit parallel adder adds binary 1010 and 1001the sum appearing at the lower right will be ___.

ANS: TrueANS: 01111ANS: 10000ANS: 10110ANS: 01001ANS: 11110ANS: 10011

Page 18: ©2008 The McGraw-Hill Companies, Inc. All rights reserved. Digital Electronics Principles & Applications Seventh Edition Chapter 10 Arithmetic Circuits

©2008 The McGraw-Hill Companies, Inc. All rights reserved.

Parallel Subtractor Using Full Adders

Note the use of four full adder circuits

Also notice the addition of four inverters on the B inputs to the

FAs

Inverters

HIGH at Carry

in input

makes this perfo

rm as a

full adder c

ircuitBinary numbers to be

subtracted are input here 1 1 1 1 - 0 0 1 1

The result (difference) of the subtraction problem will appear

here.

1 1 0 0

1 0 0 1 - 0 1 1 1

0 0 1 0

HIGH at Carry

in input acts

like adding +1 to a 1s C

number to fo

rm th

e 2s

complement.

1sC is form

ed by four

inverters.

Page 19: ©2008 The McGraw-Hill Companies, Inc. All rights reserved. Digital Electronics Principles & Applications Seventh Edition Chapter 10 Arithmetic Circuits

©2008 The McGraw-Hill Companies, Inc. All rights reserved.

Example: Multiply the binary numbers 111 and 101.

Binary Multiplication

111000

111110001

1 1 1x 1 0 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

Page 20: ©2008 The McGraw-Hill Companies, Inc. All rights reserved. Digital Electronics Principles & Applications Seventh Edition Chapter 10 Arithmetic Circuits

©2008 The McGraw-Hill Companies, Inc. All rights reserved.

Multiply the binary numbers 101 and 100.

1 0 1x 1 0 0

000000

10100101

QUIZ

Page 21: ©2008 The McGraw-Hill Companies, Inc. All rights reserved. Digital Electronics Principles & Applications Seventh Edition Chapter 10 Arithmetic Circuits

©2008 The McGraw-Hill Companies, Inc. All rights reserved.

Binary multiplier circuits – utilize repeated addition.

Binary Multipliers

Block Diagram:

Multiplicand

register

Multiplierdown counter

Productregister

Adder

Page 22: ©2008 The McGraw-Hill Companies, Inc. All rights reserved. Digital Electronics Principles & Applications Seventh Edition Chapter 10 Arithmetic Circuits

©2008 The McGraw-Hill Companies, Inc. All rights reserved.

• 2s complement representation - widely used in microprocessors.

• Represents sign and magnitude

2s Complement Notation

Decimal: +7 +4 +1 0 -1 -4 -7

2s Complement: 0111 0100 0001 0000 1111 1100 1001

MSB LSB

Sign bit (0 = + ; 1 = -)

Page 23: ©2008 The McGraw-Hill Companies, Inc. All rights reserved. Digital Electronics Principles & Applications Seventh Edition Chapter 10 Arithmetic Circuits

©2008 The McGraw-Hill Companies, Inc. All rights reserved.

• Converting positive numbers to 2s complement:

• Same as converting to binary

• Converting negative numbers to 2s complement:

2s Complement - Conversions

- 4 (decimal)

0 1 0 0

1 0 1 1

- 4 = 1 1 0 0 (2s Complement)

Decimal to 2s Complement

Convert decimalto binary

1s complement

Add 1

2s Complement toBinary

1 1 0 0 (2s C)

0 0 1 1

0 1 0 0 (Binary)

1s complement

Add 1

Page 24: ©2008 The McGraw-Hill Companies, Inc. All rights reserved. Digital Electronics Principles & Applications Seventh Edition Chapter 10 Arithmetic Circuits

©2008 The McGraw-Hill Companies, Inc. All rights reserved.

QUIZ

Q#1- Convert the decimal number –4 to 2s complement.

4 (decimal)

0100

1011

Step 1: convert decimal to binary

Step 2: convert to 1s complement

Step 3: add +1 equaling 2s complement

1100 2s C

ANS: -4 = 1100 2sC

Q#2- Convert the decimal number –-7 to 2s complement.

7 (decimal)

0111

1000

1001 2s C

ANS: -7 = 1001 2sC

Q#3- Convert the decimal number –1 to 2s complement.

1 (decimal)

0001

1110

1111 2s C

ANS: -1 = 1111 2sC

Q#4- Convert the decimal number +6 to 2s complement.

6 (decimal)

0110

Not needed

Not needed

ANS: +6 = 0110 2sC

Q#5- Convert the decimal number -8 to 2s complement.

8 (decimal)

1000

0111

1000 2sC

ANS: -8 = 1000 2sC

Page 25: ©2008 The McGraw-Hill Companies, Inc. All rights reserved. Digital Electronics Principles & Applications Seventh Edition Chapter 10 Arithmetic Circuits

©2008 The McGraw-Hill Companies, Inc. All rights reserved.

QUIZ

Q#1- Convert the 2s complement number 1110 to decimal.

0001

0010 binary

Step 1: convert to 1s complement

Step 2: Add +1

Step 3: convert binary to decimal

2 decimal

ANS: 1110 2sC = -2 decimal

1110

Q#2- Convert the 2s complement number 0101 to decimal.

Not needed

Not needed

0101 binary

5 decimal

ANS: 0101 2sC = +5 decimal

Q#3- Convert the 2s complement number 1001 to decimal.

1001

0110

0111 binary

7 decimal

ANS: 1001 2sC = -7 decimal

Q#4- Convert the 2s complement number 1111 to decimal.

1111

0000

0001 binary

1 decimal

ANS: 1111 2sC = -1 decimal

Page 26: ©2008 The McGraw-Hill Companies, Inc. All rights reserved. Digital Electronics Principles & Applications Seventh Edition Chapter 10 Arithmetic Circuits

©2008 The McGraw-Hill Companies, Inc. All rights reserved.

2s complement notation makes it possible to add and subtract signed numbers

Adding/Subtracting in 2s Complement

(- 1)+ (- 2)

(- 3)

1 1 1 1+ 1 1 1

010111

Discard

(+1)+ (- 3)

(- 2)

0 0 0 1+ 1 1 0

10111

(Decimal)

2s Complement

2s complement

2s complement

Page 27: ©2008 The McGraw-Hill Companies, Inc. All rights reserved. Digital Electronics Principles & Applications Seventh Edition Chapter 10 Arithmetic Circuits

©2008 The McGraw-Hill Companies, Inc. All rights reserved.

Add the following 2s complement numbers:

0 1 0 1+ 1 1 0

0100

QUIZ

01

(+5)+ (-

4)(+1)Discard

Page 28: ©2008 The McGraw-Hill Companies, Inc. All rights reserved. Digital Electronics Principles & Applications Seventh Edition Chapter 10 Arithmetic Circuits

©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.

Page 29: ©2008 The McGraw-Hill Companies, Inc. All rights reserved. Digital Electronics Principles & Applications Seventh Edition Chapter 10 Arithmetic Circuits

©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