CprE 281: Digital Logic

Similar documents
CprE 281: Digital Logic

CprE 281: Digital Logic

CprE 281: Digital Logic

CprE 281: Digital Logic

CprE 281: Digital Logic

CprE 281: Digital Logic

CprE 281: Digital Logic

CprE 281: Digital Logic

CprE 281: Digital Logic

CprE 281: Digital Logic

Carry Look Ahead Adders

Chapter 5 Arithmetic Circuits

CprE 281: Digital Logic

Number representation

Combinational Logic Design Arithmetic Functions and Circuits

Combinational Logic. By : Ali Mustafa

Binary addition by hand. Adding two bits

Total Time = 90 Minutes, Total Marks = 100. Total /10 /25 /20 /10 /15 /20

Adders, subtractors comparators, multipliers and other ALU elements

We are here. Assembly Language. Processors Arithmetic Logic Units. Finite State Machines. Circuits Gates. Transistors

COE 202: Digital Logic Design Combinational Circuits Part 2. Dr. Ahmad Almulhem ahmadsm AT kfupm Phone: Office:

UNSIGNED BINARY NUMBERS DIGITAL ELECTRONICS SYSTEM DESIGN WHAT ABOUT NEGATIVE NUMBERS? BINARY ADDITION 11/9/2018

1 Short adders. t total_ripple8 = t first + 6*t middle + t last = 4t p + 6*2t p + 2t p = 18t p

Midterm Exam Two is scheduled on April 8 in class. On March 27 I will help you prepare Midterm Exam Two.

Adders, subtractors comparators, multipliers and other ALU elements

CS 140 Lecture 14 Standard Combinational Modules

Numbers and Arithmetic

Module 2. Basic Digital Building Blocks. Binary Arithmetic & Arithmetic Circuits Comparators, Decoders, Encoders, Multiplexors Flip-Flops

14:332:231 DIGITAL LOGIC DESIGN

Floating Point Representation and Digital Logic. Lecture 11 CS301

Chapter 5. Digital Design and Computer Architecture, 2 nd Edition. David Money Harris and Sarah L. Harris. Chapter 5 <1>

CMSC 313 Lecture 17. Focus Groups. Announcement: in-class lab Thu 10/30 Homework 3 Questions Circuits for Addition Midterm Exam returned

Logic and Computer Design Fundamentals. Chapter 5 Arithmetic Functions and Circuits

Chapter 03: Computer Arithmetic. Lesson 03: Arithmetic Operations Adder and Subtractor circuits Design

Chapter 4. Combinational: Circuits with logic gates whose outputs depend on the present combination of the inputs. elements. Dr.

Combinational Logic. Mantıksal Tasarım BBM231. section instructor: Ufuk Çelikcan

Logic. Combinational. inputs. outputs. the result. system can

Numbers and Arithmetic

EECS150. Arithmetic Circuits

Overview. Arithmetic circuits. Binary half adder. Binary full adder. Last lecture PLDs ROMs Tristates Design examples

ELCT201: DIGITAL LOGIC DESIGN

Homework 4 due today Quiz #4 today In class (80min) final exam on April 29 Project reports due on May 4. Project presentations May 5, 1-4pm

CprE 281: Digital Logic

Systems I: Computer Organization and Architecture

Total Time = 90 Minutes, Total Marks = 50. Total /50 /10 /18

Hakim Weatherspoon CS 3410 Computer Science Cornell University

CSE 20 DISCRETE MATH. Fall

Binary addition (1-bit) P Q Y = P + Q Comments Carry = Carry = Carry = Carry = 1 P Q

Numbers & Arithmetic. Hakim Weatherspoon CS 3410, Spring 2012 Computer Science Cornell University. See: P&H Chapter , 3.2, C.5 C.

Adders - Subtractors

EECS150 - Digital Design Lecture 10 - Combinational Logic Circuits Part 1

CprE 281: Digital Logic

211: Computer Architecture Summer 2016

Class Website:

ARITHMETIC COMBINATIONAL MODULES AND NETWORKS

CMP 334: Seventh Class

Review for Test 1 : Ch1 5

Combinational Logic. Lan-Da Van ( 范倫達 ), Ph. D. Department of Computer Science National Chiao Tung University Taiwan, R.O.C.

Introduction to Digital Logic Missouri S&T University CPE 2210 Subtractors

Boolean Algebra & Digital Logic

Numbering Systems. Contents: Binary & Decimal. Converting From: B D, D B. Arithmetic operation on Binary.

CSE370 HW3 Solutions (Winter 2010)

CMPUT 329. Circuits for binary addition

Department of Electrical and Computer Engineering University of Wisconsin - Madison. ECE/CS 352 Digital System Fundamentals.

ECE 2300 Digital Logic & Computer Organization

THE LOGIC OF COMPOUND STATEMENTS

ECE380 Digital Logic. Positional representation

ELEN Electronique numérique

The logic is straightforward. Adding two 0s will result in 0. Adding two 1s results in 10 where 1 is the carry bit and 0 is the sum bit.

Quiz 2 Room 10 Evans Hall, 2:10pm Tuesday April 2 (Open Katz only, Calculators OK, 1hr 20mins)

CMSC 313 Lecture 18 Midterm Exam returned Assign Homework 3 Circuits for Addition Digital Logic Components Programmable Logic Arrays

3. Combinational Circuit Design

XOR - XNOR Gates. The graphic symbol and truth table of XOR gate is shown in the figure.

CSEE 3827: Fundamentals of Computer Systems. Combinational Circuits

UNIT 4 MINTERM AND MAXTERM EXPANSIONS

Combinational Logic. Lan-Da Van ( 范倫達 ), Ph. D. Department of Computer Science National Chiao Tung University Taiwan, R.O.C.

CSE140: Components and Design Techniques for Digital Systems. Decoders, adders, comparators, multipliers and other ALU elements. Tajana Simunic Rosing

UNIT II COMBINATIONAL CIRCUITS:

E40M. Binary Numbers. M. Horowitz, J. Plummer, R. Howe 1

Arithmetic Circuits How to add and subtract using combinational logic Setting flags Adding faster

Lecture 5: Arithmetic

Combina-onal Logic Chapter 4. Topics. Combina-on Circuit 10/13/10. EECE 256 Dr. Sidney Fels Steven Oldridge

IT T35 Digital system desigm y - ii /s - iii

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Digital Logic

L8/9: Arithmetic Structures

ENGIN 112 Intro to Electrical and Computer Engineering

Section 3: Combinational Logic Design. Department of Electrical Engineering, University of Waterloo. Combinational Logic

CDA 3200 Digital Systems. Instructor: Dr. Janusz Zalewski Developed by: Dr. Dahai Guo Spring 2012

COMBINATIONAL LOGIC FUNCTIONS

Quiz 2 Solutions Room 10 Evans Hall, 2:10pm Tuesday April 2 (Open Katz only, Calculators OK, 1hr 20mins)

CSCI 255. S i g n e d N u m s / S h i f t i n g / A r i t h m e t i c O p s.

convert a two s complement number back into a recognizable magnitude.

EECS 427 Lecture 8: Adders Readings: EECS 427 F09 Lecture 8 1. Reminders. HW3 project initial proposal: due Wednesday 10/7

EE260: Digital Design, Spring n Binary Addition. n Complement forms. n Subtraction. n Multiplication. n Inputs: A 0, B 0. n Boolean equations:

COSC 243. Introduction to Logic And Combinatorial Logic. Lecture 4 - Introduction to Logic and Combinatorial Logic. COSC 243 (Computer Architecture)

Chapter 5. Digital systems. 5.1 Boolean algebra Negation, conjunction and disjunction

ECE 645: Lecture 2. Carry-Lookahead, Carry-Select, & Hybrid Adders

EE141- Spring 2004 Digital Integrated Circuits

Combinational Logic Trainer Lab Manual

CMSC 313 Lecture 18 Midterm Exam returned Assign Homework 3 Circuits for Addition Digital Logic Components Programmable Logic Arrays

Transcription:

CprE 281: Digital Logic Instructor: Alexander Stoytchev http://www.ece.iastate.edu/~alexs/classes/

Fast Adders CprE 281: Digital Logic Iowa State University, Ames, IA Copyright Alexander Stoytchev

HW5 is out Administrative Stuff It is due on Monday Oct 2 @ 4pm. Please write clearly on the first page (in block capital letters) the following three things: Your First and Last Name Your Student ID Number Your Lab Section Letter Also, please staple all of your pages together.

Labs Next Week Administrative Stuff Mini-Project This one is worth 3% of your grade. Make sure to get all the points. http://www.ece.iastate.edu/~alexs/classes/ 2017_Fall_281/labs/Project-Mini/

Quick Review

The problems in which row are easier to calculate? - 82-48 - 32 61 26 11?????? - 82-48 - 32 64 29 13??????

The problems in which row are easier to calculate? - 82-48 - 32 61 26 11 21 22 21 Why? - 82-48 - 32 64 29 13 18 19 19

Another Way to Do Subtraction 82 64 = 82 100 100-64

Another Way to Do Subtraction 82 64 = 82 100 100-64 = 82 (100 64) - 100

Another Way to Do Subtraction 82 64 = 82 100 100-64 = 82 (100 64) - 100 = 82 (99 1 64) - 100

Another Way to Do Subtraction 82 64 = 82 100 100-64 = 82 (100 64) - 100 = 82 (99 1 64) - 100 = 82 (99 64) 1-100

Another Way to Do Subtraction 82 64 = 82 100 100-64 = 82 (100 64) - 100 = 82 (99 1 64) - 100 Does not require borrows = 82 (99 64) 1-100

9 s Complement (subtract each digit from 9) - 99 64 35

10 s Complement (subtract each digit from 9 and add 1 to the result) - 99 64 35 1 = 36

Another Way to Do Subtraction 82 64 = 82 (99 64) 1-100

Another Way to Do Subtraction 9 s complement 82 64 = 82 (99 64) 1-100

Another Way to Do Subtraction 9 s complement 82 64 = 82 (99 64) 1-100 = 82 35 1-100

Another Way to Do Subtraction 9 s complement 82 64 = 82 (99 64) 1-100 = 82 35 1-100 10 s complement

Another Way to Do Subtraction 9 s complement 82 64 = 82 (99 64) 1-100 = 82 35 1-100 10 s complement = 82 36-100

Another Way to Do Subtraction 9 s complement 82 64 = 82 (99 64) 1-100 = 82 35 1-100 10 s complement = 82 36-100 // Add the first two. = 118-100

Another Way to Do Subtraction 9 s complement 82 64 = 82 (99 64) 1-100 = 82 35 1-100 10 s complement = 82 36-100 // Add the first two. = 118-100 = 18 // Just delete the leading 1. // No need to subtract 100.

2 s complement Let K be the negative equivalent of an n-bit positive number P. Then, in 2 s complement representation K is obtained by subtracting P from 2 n, namely K = 2 n P

Deriving 2 s complement For a positive n-bit number P, let K 1 and K 2 denote its 1 s and 2 s complements, respectively. K 1 = (2 n 1) P K 2 = 2 n P Since K 2 = K 1 1, it is evident that in a logic circuit the 2 s complement can computed by inverting all bits of P and then adding 1 to the resulting 1 s-complement number.

Find the 2 s complement of 0 1 0 1 0 0 1 0 0 1 0 0 0 1 1 1

Find the 2 s complement of 0 1 0 1 0 0 1 0 1 0 1 0 1 1 0 1 0 1 0 0 0 1 1 1 1 0 1 1 1 0 0 0 Invert all bits.

Find the 2 s complement of 0 1 0 1 0 0 1 0 1 0 1 0 1 1 0 1 1 1 1 0 1 1 1 1 1 0 0 1 0 0 0 1 1 1 1 0 1 1 1 1 1 0 0 1 0 0 0 1 1 0 0 1 Then add 1.

Interpretation of four-bit signed integers [ Table 3.2 from the textbook ]

Interpretation of four-bit signed integers The top half is the same in all three representations. It corresponds to the positive integers.

Interpretation of four-bit signed integers In all three representations the first bit represents the sign. If that bit is 1, then the number is negative.

Interpretation of four-bit signed integers Notice that in this representation there are two zeros!

Interpretation of four-bit signed integers There are two zeros in this representation as well!

Interpretation of four-bit signed integers In this representation there is one more negative number.

Taking the 2 s complement negates the number decimal b 3 b 2 b 1 b 0 take the 2's complement b 3 b 2 b 1 b 0 decimal 7 0111 1001-7 6 0110 1010-6 5 0101 1011-5 4 0100 1100-4 3 0011 1101-3 2 0010 1110-2 1 0001 1111-1 0 0000 0000 0-8 1000 1000-8 -7 1001 0111 7-6 1010 0110 6-5 1011 0101 5-4 1100 0100 4-3 1101 0011 3-2 1110 0010 2-1 1111 0001 1

Taking the 2 s complement negates the number decimal b 3 b 2 b 1 b 0 take the 2's complement b 3 b 2 b 1 b 0 decimal 7 0111 1001-7 6 0110 1010-6 5 0101 1011-5 4 0100 1100-4 3 0011 1101-3 2 0010 1110-2 1 0001 1111-1 0 0000 0000 0-8 1000 1000-8 -7 1001 0111 7-6 1010 0110 6-5 1011 0101 5-4 1100 0100 4-3 1101 0011 3-2 1110 0010 2-1 1111 0001 1 This is the only exception

Taking the 2 s complement negates the number decimal b 3 b 2 b 1 b 0 take the 2's complement b 3 b 2 b 1 b 0 decimal 7 0111 1001-7 6 0110 1010-6 5 0101 1011-5 4 0100 1100-4 3 0011 1101-3 2 0010 1110-2 1 0001 1111-1 0 0000 0000 0-8 1000 1000-8 -7 1001 0111 7-6 1010 0110 6-5 1011 0101 5-4 1100 0100 4-3 1101 0011 3-2 1110 0010 2-1 1111 0001 1 And this one too.

The number circle for 2's complement [ Figure 3.11a from the textbook ]

A) Example of 2 s complement addition ( 5) ( 2) ( 7) 0 1 0 1 0 0 1 0 0 1 1 1 [ Figure 3.9 from the textbook ]

B) Example of 2 s complement addition ( 5) ( 2) 1 0 1 1 0 0 1 0 ( 3) 1 1 0 1 [ Figure 3.9 from the textbook ]

C) Example of 2 s complement addition ( 5) ( 2) ( 3) 1 0 1 0 1 1 1 1 0 0 0 1 1 ignore [ Figure 3.9 from the textbook ]

D) Example of 2 s complement addition ( 5) ( 2) ( 7) 1 1 0 1 1 1 1 1 0 1 0 0 1 ignore [ Figure 3.9 from the textbook ]

Naming Ambiguity: 2's Complement 2's complement has two different meanings: representation for signed integer numbers algorithm for computing the 2's complement (regardless of the representation of the number)

Naming Ambiguity: 2's Complement 2's complement has two different meanings: representation for signed integer numbers in 2's complement algorithm for computing the 2's complement (regardless of the representation of the number) take the 2's complement

Example of 2 s complement subtraction ( 5) ( 2) 0 1 0 1 0 0 1 0 0 1 0 1 1 1 1 0 ( 3) 1 0 0 1 1 ignore means take the 2's complement [ Figure 3.10 from the textbook ]

Example of 2 s complement subtraction ( 5) ( 2) 0 1 0 1 0 0 1 0 0 1 0 1 1 1 1 0 ( 3) 1 0 0 1 1 ignore Notice that the minus changes to a plus. means take the 2's complement [ Figure 3.10 from the textbook ]

Example of 2 s complement subtraction ( 5) ( 2) 0 1 0 1 0 0 1 0 0 1 0 1 1 1 1 0 ( 3) 1 0 0 1 1 ignore [ Figure 3.10 from the textbook ]

Example of 2 s complement subtraction ( 5) ( 2) 0 1 0 1 0 0 1 0 0 1 0 1 1 1 1 0 ( 3) 1 0 0 1 1 ignore [ Figure 3.10 from the textbook ]

Graphical interpretation of four-bit 2 s complement numbers [ Figure 3.11 from the textbook ]

Example of 2 s complement subtraction ( 5) ( 2) 1 0 1 1 0 0 1 0 1 0 1 1 1 1 1 0 ( 7) 1 1 0 0 1 ignore [ Figure 3.10 from the textbook ]

Example of 2 s complement subtraction ( 5) 0 1 0 1 ( 2) 1 1 1 0 ( 7) 0 1 0 1 0 0 1 0 0 1 1 1 [ Figure 3.10 from the textbook ]

Example of 2 s complement subtraction ( 5) 1 0 1 1 ( 2) 1 1 1 0 ( 3) 1 0 1 1 0 0 1 0 1 1 0 1 [ Figure 3.10 from the textbook ]

Take Home Message Subtraction can be performed by simply adding the 2 s complement of the second number, regardless of the signs of the two numbers. Thus, the same adder circuit can be used to perform both addition and subtraction!!!

Adder/subtractor unit y n 1 y 1 y 0 Add Sub control x n 1 x 1 x 0 c n n -bit adder c 0 s n 1 s 1 s 0 [ Figure 3.12 from the textbook ]

XOR Tricks control out y

XOR as a repeater 0 y y

XOR as an inverter 1 y y

Addition: when control = 0 y n 1 y 1 y 0 Add Sub control x n 1 x 1 x 0 c n n -bit adder c 0 s n 1 s 1 s 0 [ Figure 3.12 from the textbook ]

Addition: when control = 0 y n 1 0 y 1 0 y 0 0 0 Add Sub control x n 1 x 1 x 0 c n n -bit adder c 0 s n 1 s 1 s 0 [ Figure 3.12 from the textbook ]

Addition: when control = 0 y n 1 0 y 1 0 y 0 0 0 Add Sub control x n 1 x 1 x 0 c n n -bit adder y n-1 y 1 y 0 c 0 s n 1 s 1 s 0 [ Figure 3.12 from the textbook ]

Subtraction: when control = 1 y n 1 y 1 y 0 Add Sub control x n 1 x 1 x 0 c n n -bit adder c 0 s n 1 s 1 s 0 [ Figure 3.12 from the textbook ]

Subtraction: when control = 1 y n 1 1 y 1 1 y 0 1 1 Add Sub control x n 1 x 1 x 0 c n n -bit adder c 0 s n 1 s 1 s 0 [ Figure 3.12 from the textbook ]

Subtraction: when control = 1 y n 1 1 y 1 1 y 0 1 1 Add Sub control x n 1 x 1 x 0 c n n -bit adder y n-1 y 1 y 0 c 0 s n 1 s 1 s 0 [ Figure 3.12 from the textbook ]

Subtraction: when control = 1 y n 1 1 y 1 1 y 0 1 1 Add Sub control x n 1 x 1 x 0 c n n -bit adder y n-1 y 1 y 0 1 c 0 s n 1 s 1 s 0 carry for the first column! [ Figure 3.12 from the textbook ]

Examples of determination of overflow ( 7) ( 2) 0 1 1 1 0 0 1 0 ( 7) ( 2) 1 0 0 1 0 0 1 0 ( 9) 1 0 0 1 ( 5) 1 0 1 1 ( 7) ( 2) 0 1 1 1 1 1 1 0 ( 7) ( 2) 1 0 0 1 1 1 1 0 ( 5) 1 0 1 0 1 ( 9) 1 0 1 1 1 [ Figure 3.13 from the textbook ]

Examples of determination of overflow ( 7) ( 2) 0 1 1 0 0 0 0 0 0 0 0 1 1 1 ( 7) 1 0 0 1 0 0 1 0 ( 2) 0 0 1 0 ( 9) 1 0 0 1 ( 5) 1 0 1 1 ( 7) ( 2) 1 1 1 0 0 0 1 1 1 1 1 1 0 ( 7) ( 2) 1 0 0 0 0 1 0 0 1 1 1 1 0 ( 5) 1 0 1 0 1 ( 9) 1 0 1 1 1 Include the carry bits: c 4 c 3 c 2 c 1 c 0

Examples of determination of overflow ( 7) ( 2) 0 1 1 0 0 0 0 0 0 0 0 1 1 1 ( 7) 1 0 0 1 0 0 1 0 ( 2) 0 0 1 0 ( 9) 1 0 0 1 ( 5) 1 0 1 1 ( 7) ( 2) 1 1 1 0 0 0 1 1 1 1 1 1 0 ( 7) ( 2) 1 0 0 0 0 1 0 0 1 1 1 1 0 ( 5) 1 0 1 0 1 ( 9) 1 0 1 1 1 Include the carry bits: c 4 c 3 c 2 c 1 c 0

Examples of determination of overflow c 4 = 0 c 3 = 1 ( 7) ( 2) 0 1 1 0 0 0 0 0 0 0 0 1 1 1 ( 7) 1 0 0 1 0 0 1 0 ( 2) 0 0 1 0 c 4 = 0 c 3 = 0 ( 9) 1 0 0 1 ( 5) 1 0 1 1 c 4 = 1 c 3 = 1 ( 7) ( 2) 1 1 1 0 0 0 1 1 1 1 1 1 0 ( 7) ( 2) 1 0 0 0 0 1 0 0 1 1 1 1 0 c 4 = 1 c 3 = 0 ( 5) 1 0 1 0 1 ( 9) 1 0 1 1 1 Include the carry bits: c 4 c 3 c 2 c 1 c 0

Examples of determination of overflow c 4 = 0 c 3 = 1 ( 7) ( 2) 0 1 1 0 0 0 0 0 0 0 0 1 1 1 ( 7) 1 0 0 1 0 0 1 0 ( 2) 0 0 1 0 c 4 = 0 c 3 = 0 ( 9) 1 0 0 1 ( 5) 1 0 1 1 c 4 = 1 c 3 = 1 ( 7) ( 2) 1 1 1 0 0 0 1 1 1 1 1 1 0 ( 7) ( 2) 1 0 0 0 0 1 0 0 1 1 1 1 0 c 4 = 1 c 3 = 0 ( 5) 1 0 1 0 1 ( 9) 1 0 1 1 1 Overflow occurs only in these two cases.

Examples of determination of overflow c 4 = 0 c 3 = 1 ( 7) ( 2) 0 1 1 0 0 0 0 0 0 0 0 1 1 1 ( 7) 1 0 0 1 0 0 1 0 ( 2) 0 0 1 0 c 4 = 0 c 3 = 0 ( 9) 1 0 0 1 ( 5) 1 0 1 1 c 4 = 1 c 3 = 1 ( 7) ( 2) 1 1 1 0 0 0 1 1 1 1 1 1 0 ( 7) ( 2) 1 0 0 0 0 1 0 0 1 1 1 1 0 c 4 = 1 c 3 = 0 ( 5) 1 0 1 0 1 ( 9) 1 0 1 1 1 Overflow = c 3 c 4 c 3 c 4

Examples of determination of overflow c 4 = 0 c 3 = 1 ( 7) ( 2) 0 1 1 0 0 0 0 0 0 0 0 1 1 1 ( 7) 1 0 0 1 0 0 1 0 ( 2) 0 0 1 0 c 4 = 0 c 3 = 0 ( 9) 1 0 0 1 ( 5) 1 0 1 1 c 4 = 1 c 3 = 1 ( 7) ( 2) 1 1 1 0 0 0 1 1 1 1 1 1 0 ( 7) ( 2) 1 0 0 0 0 1 0 0 1 1 1 1 0 c 4 = 1 c 3 = 0 ( 5) 1 0 1 0 1 ( 9) 1 0 1 1 1 Overflow = c 3 c 4 c 3 c 4 XOR

Calculating overflow for 4-bit numbers with only three significant bits

Calculating overflow for n-bit numbers with only n-1 significant bits

Detecting Overflow x n 1 y n 1 x 1 y 1 x 0 y 0 c n FA c n 1 c 2 FA c 1 FA c 0 s n 1 s 1 s 0

Detecting Overflow (with one extra XOR) x n 1 y n 1 x 1 y 1 x 0 y 0 c n FA c n 1 c 2 FA c 1 FA c 0 s n 1 s 1 s 0 overflow

Another way to look at the overflow issue X= x 3 x 2 x 1 x 0 Y= y 3 y 2 y 1 y 0 S= s 3 s 2 s 1 s 0

Another way to look at the overflow issue X= x 3 x 2 x 1 x 0 Y= y 3 y 2 y 1 y 0 S= s 3 s 2 s 1 s 0 If both numbers that we are adding have the same sign but the sum does not, then we have an overflow.

Examples of determination of overflow ( 7) ( 2) 0 1 1 1 0 0 1 0 ( 7) ( 2) 1 0 0 1 0 0 1 0 ( 9) 1 0 0 1 ( 5) 1 0 1 1 ( 7) ( 2) 0 1 1 1 1 1 1 0 ( 7) ( 2) 1 0 0 1 1 1 1 0 ( 5) 1 0 1 0 1 ( 9) 1 0 1 1 1

Examples of determination of overflow ( 7) ( 2) 0 1 1 1 0 0 1 0 ( 7) ( 2) 1 0 0 1 0 0 1 0 ( 9) 1 0 0 1 ( 5) 1 0 1 1 ( 7) ( 2) 0 1 1 1 1 1 1 0 ( 7) ( 2) 1 0 0 1 1 1 1 0 ( 5) 1 0 1 0 1 ( 9) 1 0 1 1 1

Examples of determination of overflow x 3 = 0 y 3 = 0 s 3 = 1 ( 7) ( 2) 0 1 1 1 0 0 1 0 ( 7) ( 2) 1 0 0 1 0 0 1 0 x 3 = 1 y 3 = 0 s 3 = 1 ( 9) 1 0 0 1 ( 5) 1 0 1 1 x 3 = 0 y 3 = 1 s 3 = 0 ( 7) ( 2) 0 1 1 1 1 1 1 0 ( 7) ( 2) 1 0 0 1 1 1 1 0 x 3 = 1 y 3 = 1 s 3 = 0 ( 5) 1 0 1 0 1 ( 9) 1 0 1 1 1

Examples of determination of overflow x 3 = 0 y 3 = 0 s 3 = 1 ( 7) ( 2) 0 1 1 1 0 0 1 0 ( 7) ( 2) 1 0 0 1 0 0 1 0 x 3 = 1 y 3 = 0 s 3 = 1 ( 9) 1 0 0 1 ( 5) 1 0 1 1 x 3 = 0 y 3 = 1 s 3 = 0 ( 7) ( 2) 0 1 1 1 1 1 1 0 ( 7) ( 2) 1 0 0 1 1 1 1 0 x 3 = 1 y 3 = 1 s 3 = 0 ( 5) 1 0 1 0 1 ( 9) 1 0 1 1 1 In 2's complement, both 9 and -9 are not representable with 4 bits.

Examples of determination of overflow x 3 = 0 y 3 = 0 s 3 = 1 ( 7) ( 2) 0 1 1 1 0 0 1 0 ( 7) ( 2) 1 0 0 1 0 0 1 0 x 3 = 1 y 3 = 0 s 3 = 1 ( 9) 1 0 0 1 ( 5) 1 0 1 1 x 3 = 0 y 3 = 1 s 3 = 0 ( 7) ( 2) 0 1 1 1 1 1 1 0 ( 7) ( 2) 1 0 0 1 1 1 1 0 x 3 = 1 y 3 = 1 s 3 = 0 ( 5) 1 0 1 0 1 ( 9) 1 0 1 1 1 Overflow occurs only in these two cases.

Examples of determination of overflow x 3 = 0 y 3 = 0 s 3 = 1 ( 7) ( 2) 0 1 1 1 0 0 1 0 ( 7) ( 2) 1 0 0 1 0 0 1 0 x 3 = 1 y 3 = 0 s 3 = 1 ( 9) 1 0 0 1 ( 5) 1 0 1 1 x 3 = 0 y 3 = 1 s 3 = 0 ( 7) ( 2) 0 1 1 1 1 1 1 0 ( 7) ( 2) 1 0 0 1 1 1 1 0 x 3 = 1 y 3 = 1 s 3 = 0 ( 5) 1 0 1 0 1 ( 9) 1 0 1 1 1 Overflow = x 3 y 3 s 3 x 3 y 3 s 3

Another way to look at the overflow issue X= x 3 x 2 x 1 x 0 Y= y 3 y 2 y 1 y 0 S= s 3 s 2 s 1 s 0 If both numbers that we are adding have the same sign but the sum does not, then we have an overflow. Overflow = x 3 y 3 s 3 x 3 y 3 s 3

How long does it take to compute all sum bits and all carry bits? x n 1 y n 1 x 1 y 1 x 0 y 0 c n FA c n 1 c 2 FA c 1 FA c 0 s n 1 s 1 s 0

Can we perform addition even faster? The goal is to evaluate very fast if the carry from the previous stage will be equal to 0 or 1.

The Full-Adder Circuit [ Figure 3.3c from the textbook ]

The Full-Adder Circuit Let's take a closer look at this. [ Figure 3.3c from the textbook ]

Decomposing the Carry Expression c i1 = x i y i x i c i y i c i

Decomposing the Carry Expression c i1 = x i y i x i c i y i c i c i1 = x i y i (x i y i )c i

Decomposing the Carry Expression c i1 = x i y i x i c i y i c i c i1 = x i y i (x i y i )c i c i y i x i c i1

Another Way to Draw the Full-Adder Circuit c i1 = x i y i x i c i y i c i c i1 = x i y i (x i y i )c i c i y i s i x i c i1

Another Way to Draw the Full-Adder Circuit c i1 = x i y i (x i y i )c i c i y i s i x i c i1

Another Way to Draw the Full-Adder Circuit c i1 = x i y i (x i y i )c i g i p i c i y i s i x i c i1

Another Way to Draw the Full-Adder Circuit g - generate p - propagate c i1 = x i y i (x i y i )c i g i p i c i y i s i x i p i g i c i1

Yet Another Way to Draw It (Just Rotate It) x i y i g i p i c i c i1 s i

Now we can Build a Ripple-Carry Adder x 1 y 1 x 0 y 0 g 1 p 1 g 0 p 0 c 2 c 1 c 0 Stage 1 Stage 0 s 1 s 0 [ Figure 3.14 from the textbook ]

Now we can Build a Ripple-Carry Adder x 1 y 1 x 0 y 0 g 1 p 1 g 0 p 0 c 2 c 1 c 0 Stage 1 Stage 0 s 1 s 0 [ Figure 3.14 from the textbook ]

The delay is 5 gates (122) x 1 y 1 x 0 y 0 g 1 p 1 g 0 p 0 c 2 c 1 c 0 Stage 1 Stage 0 s 1 s 0

n-bit ripple-carry adder: 2n1 gate delays x 1 y 1 x 0 y 0 g 1 p 1 g 0 p 0 c 2 c 1 c 0... Stage 1 Stage 0 s 1 s 0

Decomposing the Carry Expression c i1 = x i y i x i c i y i c i c i1 = x i y i (x i y i )c i g i p i c i1 = g i p i c i c i1 = g i p i (g i-1 p i-1 c i-1 ) = g i p i g i-1 p i p i-1 c i-1

Carry for the first two stages c 1 = g 0 p 0 c 0 c 2 = g 1 p 1 g 0 p 1 p 0 c 0

The first two stages of a carry-lookahead adder x 1 y 1 x 0 y 0 x 0 y 0 g 1 p 1 g 0 p 0 c 0 c 2 c 1 s 1 s 0 [ Figure 3.15 from the textbook ]

It takes 3 gate delays to generate c 1 x 1 y 1 x 0 y 0 x 0 y 0 g 1 p 1 g 0 p 0 c 0 c 2 c 1 s 1 s 0

It takes 3 gate delays to generate c 2 x 1 y 1 x 0 y 0 x 0 y 0 g 1 p 1 g 0 p 0 c 0 c 2 c 1 s 1 s 0

The first two stages of a carry-lookahead adder x 1 y 1 x 0 y 0 x 0 y 0 g 1 p 1 g 0 p 0 c 0 c 2 c 1 s 1 s 0

It takes 4 gate delays to generate s 1 x 1 y 1 x 0 y 0 x 0 y 0 g 1 p 1 g 0 p 0 c 0 c 2 c 1 s 1 s 0

It takes 4 gate delays to generate s 2 x 1 y 1 x 0 y 0 x 0 y 0 g 1 p 1 g 0 p 0 c 0 c 2 c 1 s 2 s 1 s 0

N-bit Carry-Lookahead Adder It takes 3 gate delays to generate all carry signals It takes 1 more gate delay to generate all sum bits Thus, the total delay through an n-bit carry-lookahead adder is only 4 gate delays!

Expanding the Carry Expression c i1 = g i p i c i c 1 = g 0 p 0 c 0 c 2 = g 1 p 1 g 0 p 1 p 0 c 0 c 3 = g 2 p 2 g 1 p 2 p 1 g 0 p 2 p 1 p 0 c 0... c 8 = g 7 p 7 g 6 p 7 p 6 g 5 p 7 p 6 p 5 g 4 p 7 p 6 p 5 p 4 g 3 p 7 p 6 p 5 p 4 p 3 g 2 p 7 p 6 p 5 p 4 p 3 p 2 g 1 p 7 p 6 p 5 p 4 p 3 p 2 p 1 g 0 p 7 p 6 p 5 p 4 p 3 p 2 p 1 p 0 c 0

Expanding the Carry Expression c i1 = g i p i c i c 1 = g 0 p 0 c 0 c 2 = g 1 p 1 g 0 p 1 p 0 c 0 c 3 = g 2 p 2 g 1 p 2 p 1 g 0 p 2 p 1 p 0 c 0... c 8 = g 7 p 7 g 6 p 7 p 6 g 5 p 7 p 6 p 5 g 4 Even this takes only 3 gate delays p 7 p 6 p 5 p 4 g 3 p 7 p 6 p 5 p 4 p 3 g 2 p 7 p 6 p 5 p 4 p 3 p 2 g 1 p 7 p 6 p 5 p 4 p 3 p 2 p 1 g 0 p 7 p 6 p 5 p 4 p 3 p 2 p 1 p 0 c 0

A hierarchical carry-lookahead adder with ripple-carry between blocks x 31 24 y 31 24 x 23 16 y 23 16 x 15 8 y 15 8 x 7 0 y 7 0 c c 32 Block 24 3 Block 2 c 16 Block 1 c 8 Block 0 c 0 s 31 24 s 23 16 s 15 8 s 7 0

A hierarchical carry-lookahead adder with ripple-carry between blocks x 31 24 y 31 24 x 23 16 y 23 16 x 15 8 y 15 8 x 7 0 y 7 0 c c 32 Block 24 3 Block 2 c 16 Block 1 c 8 Block 0 c 0 s 31 24 s 23 16 s 15 8 s 7 0

A hierarchical carry-lookahead adder with ripple-carry between blocks x 31 24 y 31 24 x 23 16 y 23 16 x 15 8 y 15 8 x 7 0 y 7 0 c 32 c 24 c 16 c 8 c 0 s 31 24 s 23 16 s 15 8 s 7 0

A hierarchical carry-lookahead adder with ripple-carry between blocks x 31 24 y 31 24 x 15 8 y 15 8 x 7 0 y 7 0 c 32 Block c 3 24 c 16 Block 1 c 8 Block 0 c 0 s 31 24 s 15 8 s 7 0 [ Figure 3.16 from the textbook ]

A hierarchical carry-lookahead adder x 31 24 y 31 24 x 15 8 y 15 8 x 7 0 y 7 0 Block 3 c 24 Block 1 Block 0 c 0 G 3 P 3 G 1 P 1 G 0 P 0 s 31 24 s 15 8 s 7 0 c 32 c 16 c 8 Second-level lookahead [ Figure 3.17 from the textbook ]

A hierarchical carry-lookahead adder x 31 24 y 31 24 x 15 8 y 15 8 x 7 0 y 7 0 Block 3 c 24 Block 1 Block 0 c 0 G 3 P 3 G 1 P 1 G 0 P 0 c 32 s 31 24 s 15 8 s 7 0 c 32 c 16 c 8 Second-level lookahead

A hierarchical carry-lookahead adder x 31 24 y 31 24 x 15 8 y 15 8 x 7 0 y 7 0 Block 3 c 24 Block 1 Block 0 c 0 G 3 P 3 G 1 P 1 G 0 P 0 c 32 s 31 24 s 15 8 s 7 0 c 32 c 16 c 8 Second-level lookahead

A hierarchical carry-lookahead adder x 31 24 y 31 24 x 15 8 y 15 8 x 7 0 y 7 0 Block 3 c 24 Block 1 Block 0 c 0 G 3 P 3 G 1 P 1 G 0 P 0 c 32 s 31 24 s 15 8 s 7 0 c 32??? c 16 c 8 Second-level lookahead

The Hierarchical Carry Expression c 8 = g 7 p 7 g 6 p 7 p 6 g 5 p 7 p 6 p 5 g 4 p 7 p 6 p 5 p 4 g 3 p 7 p 6 p 5 p 4 p 3 g 2 p 7 p 6 p 5 p 4 p 3 p 2 g 1 p 7 p 6 p 5 p 4 p 3 p 2 p 1 g 0 p 7 p 6 p 5 p 4 p 3 p 2 p 1 p 0 c 0

The Hierarchical Carry Expression c 8 = g 7 p 7 g 6 p 7 p 6 g 5 p 7 p 6 p 5 g 4 p 7 p 6 p 5 p 4 g 3 p 7 p 6 p 5 p 4 p 3 g 2 p 7 p 6 p 5 p 4 p 3 p 2 g 1 p 7 p 6 p 5 p 4 p 3 p 2 p 1 g 0 p 7 p 6 p 5 p 4 p 3 p 2 p 1 p 0 c 0

The Hierarchical Carry Expression c 8 = g 7 p 7 g 6 p 7 p 6 g 5 p 7 p 6 p 5 g 4 G 0 p 7 p 6 p 5 p 4 g 3 p 7 p 6 p 5 p 4 p 3 g 2 p 7 p 6 p 5 p 4 p 3 p 2 g 1 p 7 p 6 p 5 p 4 p 3 p 2 p 1 g 0 p 7 p 6 p 5 p 4 p 3 p 2 p 1 p 0 c 0 P 0

The Hierarchical Carry Expression c 8 = g 7 p 7 g 6 p 7 p 6 g 5 p 7 p 6 p 5 g 4 G 0 p 7 p 6 p 5 p 4 g 3 p 7 p 6 p 5 p 4 p 3 g 2 p 7 p 6 p 5 p 4 p 3 p 2 g 1 p 7 p 6 p 5 p 4 p 3 p 2 p 1 g 0 p 7 p 6 p 5 p 4 p 3 p 2 p 1 p 0 c 0 P 0 c 8 = G 0 P 0 c 0

The Hierarchical Carry Expression c 8 = G 0 P 0 c 0 c 16 = G 1 P 1 c 8 = G 1 P 1 G 0 P 1 P 0 c 0 c 24 = G 2 P 2 G 1 P 2 P 1 G 0 P 2 P 1 P 0 c 0 c 32 = G 3 P 3 G 2 P 3 P 2 G 1 P 3 P 2 P 1 G 0 P 3 P 2 P 1 P 0 c 0

A hierarchical carry-lookahead adder x 31 24 y 31 24 x 15 8 y 15 8 x 7 0 y 7 0 Block 3 c 24 Block 1 Block 0 c 0 G 3 P 3 G 1 P 1 G 0 P 0 s 31 24 s 15 8 s 7 0 c 32 c 16 c 8 Second-level lookahead [ Figure 3.17 from the textbook ]

A hierarchical carry-lookahead adder x 31 24 y 31 24 x 15 8 y 15 8 x 7 0 y 7 0 Block 3 c 24 Block 1 Block 0 c 0 G 3 P 3 G 1 P 1 G 0 P 0 s 31 24 s 15 8 s 7 0 c 32 c 16 c 8 c 32 =G 3 P 3 G 2 P 3 P 2 G 1 P 3 P 2 P 1 G 0 P 3 P 2 P 1 P 0 c 0 Second-level lookahead c 16 = G 1 P 1 G 0 P 1 P 0 c 0 c 8 = G 0 P 0 c 0 [ Figure 3.17 from the textbook ]

Hierarchical CLA Adder Carry Logic Block 2 P1 P0 c0 p7 x7 y7 g7 x6 y6 p7g6 g6 p7p6g5 p7p6p5g4 Block 1 p7p6p5p4g3 p7p6p5p4p3g2 p7p6p5p4p3p2g1 p7p6p5p4p3p2p1g0 P0 c0 C8 5 gate delays C16 5 gate delays C24 5 Gate delays C32 5 Gate delays SECOND LEVEL HIERARCHY c16 G1 P1 G0 P0 c0 c8 P1 G0 G0 P1 P0 c0 Block 3 Block 2 Block 1 c 0 p 17 c 17 p 9 c 9 p 0 g 0 c 1 g 17 g 9 FIRST LEVEL HIERARCHY

Hierarchical CLA Critical Path Block 2 p7 x7 y7 g7 x6 y6 p7g6 g6 p7p6g5 p7p6p5g4 Block 1 p7p6p5p4g3 p7p6p5p4p3g2 p7p6p5p4p3p2g1 p7p6p5p4p3p2p1g0 G1 G0 P0 c0 c8 P1 P1 G0 G0 P1 P0 c0 c16 P1 P0 c0 P0 c0 C9 7 gate delays C17 7 gate delays C25 7 Gate delays SECOND LEVEL HIERARCHY Block 3 Block 2 Block 1 c 0 p 17 c 17 p 9 c 9 p 0 g 0 c 1 g 17 g 9 FIRST LEVEL HIERARCHY

Total Gate Delay Through a Hierarchical Carry-Lookahead Adder Is 8 gates 3 to generate all Gj and Pj 2 to generate c8, c16, c24, and c32 2 to generate internal carries in the blocks 1 to generate the sum bits (one extra XOR)

Questions?

THE END