48
Chapter 6 Digital Arithmetic : Operations and Circuits

Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

Embed Size (px)

Citation preview

Page 1: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

Chapter 6Digital Arithmetic :

Operations and Circuits

Page 2: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

IntroductionTo understand how digital

machines (i.e., computers) perform the basic arithmetic operations.

Chapter 6 Digital Arithmetic: Operations & CircuitsINC222 Logic Theory and Digital Circuit Design

Page 3: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

Binary Addition

INC222 Logic Theory and Digital Circuit Design Chapter 6 Digital Arithmetic: Operations & Circuits

Page 4: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

Representing Signed Numbers Sign-Magnitude System

INC222 Logic Theory and Digital Circuit Design

2’s-Complement System

Chapter 6 Digital Arithmetic: Operations & Circuits

Page 5: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

Representing Signed Numbers Using 2’s Complement 2’s-Complement System

INC222 Logic Theory and Digital Circuit Design Chapter 6 Digital Arithmetic: Operations & Circuits

Page 6: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

1’s-Complement Form

INC222 Logic Theory and Digital Circuit Design Chapter 6 Digital Arithmetic: Operations & Circuits

Page 7: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

2’s-Complement Form (Negation)

INC222 Logic Theory and Digital Circuit Design Chapter 6 Digital Arithmetic: Operations & Circuits

Page 8: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

Special Case in 2’s-Complement Representation

INC222 Logic Theory and Digital Circuit Design

Range of values :

N : Number of magnitude bits

There are a total of 2N +1 different values, including zero

Chapter 6 Digital Arithmetic: Operations & Circuits

Page 9: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

INC222 Logic Theory and Digital Circuit Design

Decimal Value Signed Binary Using 2’s Complement+ 7 = 23 - 1 0111+ 6 0110+ 5 0101+ 4 0100+ 3 0011+ 2 0010+ 1 0001

0 0000- 1 1111- 2 1110- 3 1101- 4 1100- 5 1011- 6 1010- 7 1001- 8 = -23 1000

Chapter 6 Digital Arithmetic: Operations & Circuits

Page 10: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

Addition in the 2’s-Complement System Case Ⅰ: Two Positive Numbers

INC222 Logic Theory and Digital Circuit Design

sign bits

+13

Chapter 6 Digital Arithmetic: Operations & Circuits

Page 11: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

Addition in the 2’s-Complement System Case Ⅱ: Positive Number and Smaller

Negative Number

INC222 Logic Theory and Digital Circuit Design

sign bits

This carry is disregarded

+5

Chapter 6 Digital Arithmetic: Operations & Circuits

Page 12: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

Addition in the 2’s-Complement System Case Ⅲ: Positive Number and Larger

Negative Number

INC222 Logic Theory and Digital Circuit Design

sign bits

-5

Chapter 6 Digital Arithmetic: Operations & Circuits

Page 13: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

Addition in the 2’s-Complement System Case Ⅳ: Two Negative Numbers

INC222 Logic Theory and Digital Circuit Design

sign bits

-13

This carry is disregarded

Chapter 6 Digital Arithmetic: Operations & Circuits

Page 14: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

Addition in the 2’s-Complement System Case Ⅴ: Equal and Opposite Numbers

INC222 Logic Theory and Digital Circuit Design

sign bits

0

This carry is disregarded

Chapter 6 Digital Arithmetic: Operations & Circuits

Page 15: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

Subtraction in the 2’s-Complement System When subtracting one binary number (the

subtrahend) from another binary number (the minuend), use the following procedure:

Negate the subtrahend.

Add this to the minuend.

INC222 Logic Theory and Digital Circuit Design Chapter 6 Digital Arithmetic: Operations & Circuits

Page 16: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

Arithmetic Overflow

INC222 Logic Theory and Digital Circuit Design

incorrect magnitudeincorrect sign

Chapter 6 Digital Arithmetic: Operations & Circuits

Page 17: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

Multiplication of Binary Numbers

INC222 Logic Theory and Digital Circuit Design

1 0 0 11 0 1 11 0 0 1

1 0 0 10 0 0 0

1 0 0 11 1 0 0 0 1 1

multiplicand = 910

multiplier = 1110

partial products

final product = 9910

Chapter 6 Digital Arithmetic: Operations & Circuits

Page 18: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

Multiplication of Binary Numbers

INC222 Logic Theory and Digital Circuit Design

1 0 0 1

1 0 1 1

1 0 0 11 0 0 1

0 0 0 0

1 0 0 11 1 0 0 0 1 1

multiplicand = 910

multiplier = 1110

final product = 9910

1 1 0 1 1

0 1 1 0 1 14th partial product shifted left

sum of 1st 3 partial products

3rd partial product shifted left

sum of 1st 2 partial products

2nd partial product shifted left

1st partial product

Chapter 6 Digital Arithmetic: Operations & Circuits

Page 19: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

Multiplication in the 2’s-Complement System

If +A x +B = +(A x B)

If -A x –B = +(A x B)

If +A x –B or –A x +B = -(A x B)

INC222 Logic Theory and Digital Circuit Design Chapter 6 Digital Arithmetic: Operations & Circuits

Page 20: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

Binary Division

INC222 Logic Theory and Digital Circuit Design Chapter 6 Digital Arithmetic: Operations & Circuits

Page 21: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

BCD Addition Sum Equals 9 or Less

INC222 Logic Theory and Digital Circuit Design Chapter 6 Digital Arithmetic: Operations & Circuits

Page 22: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

BCD Addition Sum Greater Than 9

INC222 Logic Theory and Digital Circuit Design Chapter 6 Digital Arithmetic: Operations & Circuits

Page 23: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

INC222 Logic Theory and Digital Circuit Design

8 2

Chapter 6 Digital Arithmetic: Operations & Circuits

Page 24: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

INC222 Logic Theory and Digital Circuit Design

9 7

Chapter 6 Digital Arithmetic: Operations & Circuits

Page 25: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

Hexadecimal Arithmetic Hex Addition

INC222 Logic Theory and Digital Circuit Design Chapter 6 Digital Arithmetic: Operations & Circuits

Page 26: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

Hexadecimal Arithmetic Hex Subtraction

2’s Complement of a hex number

INC222 Logic Theory and Digital Circuit Design Chapter 6 Digital Arithmetic: Operations & Circuits

Page 27: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

INC222 Logic Theory and Digital Circuit Design Chapter 6 Digital Arithmetic: Operations & Circuits

Page 28: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

Ex. 2’s complement of 3A5 Add to the minuend

INC222 Logic Theory and Digital Circuit Design

Disregard carry

Chapter 6 Digital Arithmetic: Operations & Circuits

Page 29: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

Hex Representation of Signed Numbers

INC222 Logic Theory and Digital Circuit Design

Hex Address Stored Binary Data Hex Value Decimal Value

4000 00111010 3A +58

4001 11100101 E5 -27

4002 01010111 57 +87

4003 10000000 80 -128

Chapter 6 Digital Arithmetic: Operations & Circuits

Page 30: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

Arithmetic Circuit

INC222 Logic Theory and Digital Circuit Design Chapter 6 Digital Arithmetic: Operations & Circuits

Page 31: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

Parallel Binary Adder

INC222 Logic Theory and Digital Circuit Design Chapter 6 Digital Arithmetic: Operations & Circuits

Page 32: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

5-bits parallel adder circuit

INC222 Logic Theory and Digital Circuit Design Chapter 6 Digital Arithmetic: Operations & Circuits

Page 33: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

Design of a Full Adder

INC222 Logic Theory and Digital Circuit Design Chapter 6 Digital Arithmetic: Operations & Circuits

Page 34: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

Full Adder

INC222 Logic Theory and Digital Circuit Design Chapter 6 Digital Arithmetic: Operations & Circuits

Page 35: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

Complete Parallel Adder with Registers

INC222 Logic Theory and Digital Circuit Design Chapter 6 Digital Arithmetic: Operations & Circuits

Page 36: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

Integrated-Circuit Parallel Adder

INC222 Logic Theory and Digital Circuit Design Chapter 6 Digital Arithmetic: Operations & Circuits

Page 37: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

Cascading Parallel Adders

INC222 Logic Theory and Digital Circuit Design Chapter 6 Digital Arithmetic: Operations & Circuits

Page 38: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

2’s-Complement System

INC222 Logic Theory and Digital Circuit Design Chapter 6 Digital Arithmetic: Operations & Circuits

Page 39: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

Parallel adder used to subtract

INC222 Logic Theory and Digital Circuit Design Chapter 6 Digital Arithmetic: Operations & Circuits

Page 40: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

Combined Addition & Subtraction

Addition : ADD = 1 & SUB = 0note: C0 = 0

Subtraction : ADD = 0 & SUB = 1note: C0 = 1

INC222 Logic Theory and Digital Circuit Design Chapter 6 Digital Arithmetic: Operations & Circuits

Page 41: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

INC222 Logic Theory and Digital Circuit Design Chapter 6 Digital Arithmetic: Operations & Circuits

Page 42: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

BCD Adder

INC222 Logic Theory and Digital Circuit Design Chapter 6 Digital Arithmetic: Operations & Circuits

Page 43: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

Correction invalid code

INC222 Logic Theory and Digital Circuit Design

S4S3S2S1S0 can range anywhere from 00000 to 10010

Chapter 6 Digital Arithmetic: Operations & Circuits

Page 44: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

INC222 Logic Theory and Digital Circuit Design

01010 to 10010 are the invalid codesS4 S3 S2 S1 S0 Z

(0-8) 00 1 0 0 1 (9) 00 1 0 1 0 (10) 10 1 0 1 1 (11) 10 1 1 0 0 (12) 10 1 1 0 1 (13) 10 1 1 1 0 (14) 10 1 1 1 1 (15) 11 0 0 0 0 (16) 11 0 0 0 1 (17) 11 0 0 1 0 (18) 11 0 0 1 1 (19) x

(20-31) x

Chapter 6 Digital Arithmetic: Operations & Circuits

Page 45: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

INC222 Logic Theory and Digital Circuit Design Chapter 6 Digital Arithmetic: Operations & Circuits

Page 46: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

Cascading BCD Adders

INC222 Logic Theory and Digital Circuit Design Chapter 6 Digital Arithmetic: Operations & Circuits

Page 47: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

ALU Integrate Circuits

INC222 Logic Theory and Digital Circuit Design Chapter 6 Digital Arithmetic: Operations & Circuits

Page 48: Chapter 6inc.kmutt.ac.th/course/inc222/Document/Chapter6.pdfIntroduction To understand how digital machines (i.e., computers) perform the basic arithmetic operations. INC222 Logic

Expanding the ALU

INC222 Logic Theory and Digital Circuit Design Chapter 6 Digital Arithmetic: Operations & Circuits