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

Similar documents
Introduction to Digital Logic Missouri S&T University CPE 2210 Multiplexers/Demultiplexers

Introduction to Digital Logic Missouri S&T University CPE 2210 Combinatorial Circuit Analysis and Synthesis

Introduction to Digital Logic Missouri S&T University CPE 2210 Boolean Algebra

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

Introduction to Digital Logic Missouri S&T University CPE 2210 Karnaugh Maps

Introduction to Digital Logic Missouri S&T University CPE 2210 Boolean Representations

COMBINATIONAL LOGIC FUNCTIONS

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

Systems I: Computer Organization and Architecture

Combinational Logic Design Arithmetic Functions and Circuits

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

Combinational Logic. By : Ali Mustafa

Introduction to Digital Logic Missouri S&T University CPE 2210 Number Systems

Chapter 5 Arithmetic Circuits

EE260: Digital Design, Spring n Digital Computers. n Number Systems. n Representations. n Conversions. n Arithmetic Operations.

Introduction to Digital Logic Missouri S&T University CPE 2210 Number Systems

ECE 545 Digital System Design with VHDL Lecture 1. Digital Logic Refresher Part A Combinational Logic Building Blocks

14:332:231 DIGITAL LOGIC DESIGN. Why Binary Number System?

Fundamentals of Digital Design

Unit II Chapter 4:- Digital Logic Contents 4.1 Introduction... 4

Design of Sequential Circuits

Digital Techniques. Figure 1: Block diagram of digital computer. Processor or Arithmetic logic unit ALU. Control Unit. Storage or memory unit

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

Adders, subtractors comparators, multipliers and other ALU elements

ELCT201: DIGITAL LOGIC DESIGN

Chapter 1 CSCI

Hakim Weatherspoon CS 3410 Computer Science Cornell University

UNIT II COMBINATIONAL CIRCUITS:

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

Adders, subtractors comparators, multipliers and other ALU elements

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

Adders - Subtractors

DIGITAL TECHNICS. Dr. Bálint Pődör. Óbuda University, Microelectronics and Technology Institute

CHAPTER 2 NUMBER SYSTEMS

Combinational Logic. Course Instructor Mohammed Abdul kader

Hardware Design I Chap. 4 Representative combinational logic

CprE 281: Digital Logic

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

ELEN Electronique numérique

Lecture 2 Review on Digital Logic (Part 1)

ECE 545 Digital System Design with VHDL Lecture 1A. Digital Logic Refresher Part A Combinational Logic Building Blocks

3. Complete the following table of equivalent values. Use binary numbers with a sign bit and 7 bits for the value

Number representation

Carry Look Ahead Adders

Digital Systems Roberto Muscedere Images 2013 Pearson Education Inc. 1

SAU1A FUNDAMENTALS OF DIGITAL COMPUTERS

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

ECE/CS 250 Computer Architecture

XI STANDARD [ COMPUTER SCIENCE ] 5 MARKS STUDY MATERIAL.

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

ECE 250 / CPS 250 Computer Architecture. Basics of Logic Design Boolean Algebra, Logic Gates

CS/COE0447: Computer Organization and Assembly Language

University of Guelph School of Engineering ENG 2410 Digital Design Fall There are 7 questions, answer all questions.

CS61C : Machine Structures

Complement Arithmetic

CS/COE1541: Introduction to Computer Architecture. Logic Design Review. Sangyeun Cho. Computer Science Department University of Pittsburgh

PG - TRB UNIT-X- DIGITAL ELECTRONICS. POLYTECHNIC-TRB MATERIALS

UNIT 4 MINTERM AND MAXTERM EXPANSIONS

Chapter 7 Logic Circuits

CprE 281: Digital Logic

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

CS61C : Machine Structures

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

Binary addition by hand. Adding two bits

Menu. Binary Adder EEL3701 EEL3701. Add, Subtract, Compare, ALU

Number System. Decimal to binary Binary to Decimal Binary to octal Binary to hexadecimal Hexadecimal to binary Octal to binary

CSE 140L Spring 2010 Lab 1 Assignment Due beginning of the class on 14 th April

Class Website:

CSE 20 DISCRETE MATH. Fall

CMP 334: Seventh Class

ENGIN 112 Intro to Electrical and Computer Engineering

Numbers and Arithmetic

CPE100: Digital Logic Design I

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

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

Digital Logic: Boolean Algebra and Gates. Textbook Chapter 3

Review for Final Exam

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

14:332:231 DIGITAL LOGIC DESIGN

Philadelphia University Student Name: Student Number:

Ex code

CS/COE0447: Computer Organization

Schedule. ECEN 301 Discussion #25 Final Review 1. Date Day Class No. 1 Dec Mon 25 Final Review. Title Chapters HW Due date. Lab Due date.

CS/COE0447: Computer Organization

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

CPS 104 Computer Organization and Programming Lecture 11: Gates, Buses, Latches. Robert Wagner

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

UNIVERSITI TENAGA NASIONAL. College of Information Technology

Time Allowed 3:00 hrs. April, pages

Digital Electronics Circuits 2017

EE40 Lec 15. Logic Synthesis and Sequential Logic Circuits

2 Application of Boolean Algebra Theorems (15 Points - graded for completion only)

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

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

Department of Electrical & Electronics EE-333 DIGITAL SYSTEMS

10/14/2009. Reading: Hambley Chapters

Digital Logic. CS211 Computer Architecture. l Topics. l Transistors (Design & Types) l Logic Gates. l Combinational Circuits.

BOOLEAN ALGEBRA. Introduction. 1854: Logical algebra was published by George Boole known today as Boolean Algebra

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

Transcription:

Introduction to Digital Logic Missouri S&T University CPE 2210 Egemen K. Çetinkaya Egemen K. Çetinkaya Department of Electrical & Computer Engineering Missouri University of Science and Technology cetinkayae@mst.edu http://web.mst.edu/~cetinkayae/teaching/cpe2210fall2016 9 November 2016 rev. 16.0 2014 2016 Egemen K. Çetinkaya

Introduction Half-subtractor Full-subtractor Outline 1 s complement representation 2 s complement representation Overflow Summary 2

Digital Logic Systems Overview Combinatorial logic circuits for no memory systems Boolean algebra to mathematically design/analyze logic gates are building blocks Sequential logic circuits for memory systems Finite State Machines to mathematically design/analyze flip-flops and latches store memory flip-flops and latches are building blocks of sequential logic Sequential logic circuits (aka controllers) combine combinatorial circuits storage elements (e.g. registers) 3

Digital Systems Components analog phenomena electric signal A2D digital data digital data sensors and other inputs Digital System D2A electric signal actuators and other outputs digital data digital data Transducer: sensor + actuator Not all sensors/actuators require A2D/D2A conversion Digital system can be implemented: microprocessor readily available, cheap, easy to program, easy to reprogram custom circuit smaller, faster, consume less power 4

Digital Systems Paths Digital systems have two paths: datapath circuit control circuit Datapath circuit store data manipulate data transfer data from one part to another Control circuit controls the operation of datapath circuit 5

Registers Shifters Adders Comparators Counters/timers Datapath Components Building Block examples Multiplexer/demultiplexers Decoders/encoders ALUs: Arithmetic Logic Units 6

Overview subtract two N-bit numbers E.g.: 2-bit subtractor subtracts two 2-bit numbers 4-bit subtractor subtracts two 4-bit numbers Block diagram: 4-bit subtractor a3 b3 a2 b2 a1 b1 a0 b0 wi a b wi a b wi a b wi a b wi a3 a2 a1 a0 b3 b2 b1 b0 FS FS FS FS 4-bit subtractor wi w o s w o s w o s w o s w o s3 s2 s1 s0 w o s3 s2 s1 s0 7

Subtract Operation Compute sum, add carry to next column Lets add A=1010 and B=0111-1st column 0 1 0 1 10 0 1 1 1-2nd c olumn 0 1 10 1 0 1 0 0 1 1 1-3 r d c olumn 0 1 1 0 1 0 0 1 1 1-4th c olumn 0 1 0 1 0 1 1 minuend 0 1 1 1 subtrahend 1 1 1 0 1 1 0 0 1 1 difference 8

Half-Subtractor Subtracts two bits, generates two output bits Inputs: minuend and subtrahend Outputs: difference and borrow Lets try to design the circuit: 9

Half-Subtractor Subtracts two bits, generates two output bits Inputs: minuend and subtrahend Outputs: difference and borrow Lets try to design the circuit: Next steps? 10

Half-Subtractor Subtracts two bits, generates two output bits Inputs: minuend and subtrahend Outputs: difference and borrow Lets try to design the circuit: Next steps? Capture the function Create equations Implement as a circuit 11

Half-Subtractor Subtracts two bits, generates two output bits Inputs: minuend and subtrahend Outputs: difference and borrow Lets try to design the circuit: Next steps? Capture the function Pay attention: we are doing b a b a D B 0 0 0 0 0 1 1 1 1 0 1 0 1 1 0 0 12

Half-Subtractor Subtracts two bits, generates two output bits Inputs: minuend and subtrahend Outputs: difference and borrow Lets try to design the circuit: Next steps? Create equations D = b a + ba = b a b a D B 0 0 0 0 0 1 1 1 1 0 1 0 1 1 0 0 13

Half-Subtractor Subtracts two bits, generates two output bits Inputs: minuend and subtrahend Outputs: difference and borrow Lets try to design the circuit: Next steps? Create equations D = b a + ba = b a B = b a b a D B 0 0 0 0 0 1 1 1 1 0 1 0 1 1 0 0 14

Half-Subtractor Subtracts two bits, generates two output bits Inputs: minuend and subtrahend Outputs: difference and borrow Lets try to design the circuit: Next steps? Implement as a circuit D = b a + ba = b a B = b a a b a b Halfsubtractor B D B D 15

Comparison Half-Adder vs. Half-Subtractor HA operation: a+b s = a b co = ab HS operation: b a D = a b B = b a a b a b a b a b Half-adder (HA) co s Halfsubtractor B D co s B D 16

Full-Subtractor Subtracts three bits, generates two output bits Inputs: minuend, subtrahend, and borrow in Outputs: difference and borrow out Lets try to design the circuit: 17

Full-Subtractor Subtracts three bits, generates two output bits Inputs: minuend, subtrahend, and borrow in Outputs: difference and borrow out Lets try to design the circuit: Next steps? 18

Full-Subtractor Subtracts three bits, generates two output bits Inputs: minuend, subtrahend, and borrow in Outputs: difference and borrow out Lets try to design the circuit: Next steps? Capture the function Create equations Implement as a circuit 19

Full-Subtractor Subtracts three bits, generates two output bits Inputs: minuend, subtrahend, and borrow in Outputs: difference and borrow out Lets try to design the circuit: Next steps? Capture the function Pay attention: we are doing b a Bi that is the difference (D) Bo=1 if b<(a+bi) b a Bi D Bo 0 0 0 0 0 0 0 1 1 1 0 1 0 1 1 0 1 1 0 1 1 0 0 1 0 1 0 1 0 0 1 1 0 0 0 1 1 1 1 1 20

Full-Subtractor Subtracts three bits, generates two output bits Inputs: minuend, subtrahend, and borrow in Outputs: difference and borrow out Lets try to design the circuit: Next steps? Create equations D=b a Bi+b abi +ba Bi +babi D=b (a Bi+aBi )+b(a Bi +abi) D=b (a Bi)+b(a Bi) D=b a Bi b a Bi D Bo 0 0 0 0 0 0 0 1 1 1 0 1 0 1 1 0 1 1 0 1 1 0 0 1 0 1 0 1 0 0 1 1 0 0 0 1 1 1 1 1 21

Full-Subtractor Subtracts three bits, generates two output bits Inputs: minuend, subtrahend, and borrow in Outputs: difference and borrow out Lets try to design the circuit: Next steps? b a Bi D Bo 0 0 0 0 0 0 0 1 1 1 0 1 0 1 1 Create equations D=b a Bi Bo=b a Bi+b abi +b abi+babi Bo=b (a Bi+aBi )+abi(b +b) Bo=b (a Bi)+aBi 0 1 1 1 1 1 0 0 1 1 1 0 1 0 1 0 1 0 0 1 1 0 0 0 1 22

Full-Subtractor Subtracts three bits, generates two output bits Inputs: minuend, subtrahend, and borrow in Outputs: difference and borrow out Lets try to design the circuit: Next steps? Create equations D=b a Bi Bo=b (a Bi)+aBi b a Bi D Bo 0 0 0 0 0 0 0 1 1 1 0 1 0 1 1 0 1 1 0 1 1 0 0 1 0 1 0 1 0 0 1 1 0 0 0 1 1 1 1 1 23

Full-Subtractor Subtracts three bits, generates two output bits Inputs: minuend, subtrahend, and borrow in Outputs: difference and borrow out Lets try to design the circuit: Next steps? Implement as a circuit D=b a Bi Bo=b (a Bi)+aBi a b (FS) Bi B o D 24

Comparison Full-Adder vs. Full-Subtractor FA operation: a+b+c s = a b c co = ab + ac + bc FS operation: b a Bi D = b a Bi Bo = b (a Bi) + abi a b ci a b Bi Full adder (FA) (FS) c o s B o D 25

Negative Number Representation So far we dealt with positive numbers How do we go on representing negative numbers? 26

Number Systems Representation Type Explanation positive x > 0 negative x < 0 non-negative x 0 non-positive x 0 signed (in computing) represents both negative and positive numbers unsigned (in computing) represents only non-negative numbers 27

LSB: Least Significant Bit right-most bit MSB: Most Significant Bit higher-order bit left-most bit Example: LSB MSB Number Systems Representations 1 0 1 0 1 1 0 1 28

Unsigned numbers: Number Systems Unsigned Numbers all bits represent the magnitude of a number Example: LSB MSB 1 0 1 0 1 1 0 1 magnitude 29

Signed numbers: Number Systems Signed Numbers left most bit represents the sign MSB is shifted one bit to right Example: what is the value? sign bit: 0 for positive numbers, 1 for negative numbers LSB MSB 1 0 1 0 1 1 0 1 sign magnitude 30

Signed numbers: Number Systems Signed Numbers left most bit represents the sign MSB is shifted one bit to right Example: what is the value? 45 sign bit: 0 for positive numbers, 1 for negative numbers LSB MSB 1 0 1 0 1 1 0 1 sign magnitude 31

Number Systems Signed and Magnitude Examples Egemen K. Çetinkaya 0 0 1 0 1 0 1 0 0 0 0 0 1 0 0 0 32

Number Systems Signed and Magnitude Examples Egemen K. Çetinkaya +2 2 +0 0 0 0 1 0 1 0 1 0 0 0 0 0 1 0 0 0 33

Number Representation Range representing signed vs. unsigned numbers? E.g. 4-bit signed-magnitude example? 1 1 1 1 0 1 1 1 E.g. 4-bit unsigned-magnitude example? 0 0 0 0 1 1 1 1 34

Number Representation Range representing signed vs. unsigned numbers? E.g. 4-bit signed-magnitude example? 1 1 1 1 0 1 1 1 Range from (2 n 1 1) to +(2 n 1 1), 7 to +7 E.g. 4-bit unsigned-magnitude example? 0 0 0 0 1 1 1 1 Range from 0 to +(2 n 1) 0 to 15 35

Signed Numbers and Complements There are two types of complements r s complement of N = r n N radix complement or true complement N is the number, r is the base, n is the digits (r 1) s complement of N = r n r m N diminished-radix or radix-minus-one complement N is the number, r is the base, n is the integer digits, m is the fraction digits E.g. for number 22.1 in base 10 10s complement: 10 2 22.1 = 100 22.1 = 77.9 9s complement: 10 2 10 1 22.1 = 100 0.1 22.1 = 77.8 36

Binary Complements Two s complement (2 s complement) r s complement of N = r n N One s complement (1 s complement) (r 1) s complement of N = r n r m N E.g. for number unsigned 101 in base 2 1 s complement: 2 3 2 0 101 = 1000 1 101 = 010 2 s complement: 2 3 101 = 1000 101 = 011 1 s complement is bits flipped of original number 2 s complement is 1 s complement + 1 37

3-bit True and Complement Forms Example Complement representation are for negative numbers Number 011 010 001 000 100 101 110 111 38

3-bit True and Complement Forms Example Complement representation are for negative numbers Number 011 010 001 000 100 101 110 111 Unsigned 39

3-bit True and Complement Forms Example Complement representation are for negative numbers Number 011 3 010 2 001 1 000 0 100 4 101 5 110 6 111 7 Unsigned 40

3-bit True and Complement Forms Example Complement representation are for negative numbers Number Unsigned Signed and magnitude 011 3 010 2 001 1 000 0 100 4 101 5 110 6 111 7 41

3-bit True and Complement Forms Example Complement representation are for negative numbers Number Unsigned Signed and magnitude 011 3 +3 010 2 +2 001 1 +1 000 0 +0 100 4 0 101 5 1 110 6 2 111 7 3 42

3-bit True and Complement Forms Example Complement representation are for negative numbers Number Unsigned Signed and magnitude 011 3 +3 010 2 +2 001 1 +1 000 0 +0 100 4 0 101 5 1 110 6 2 111 7 3 1 s complement (of signed value) 43

3-bit True and Complement Forms Example Complement representation are for negative numbers Number Unsigned Signed and magnitude 1 s complement (of signed value) 011 3 +3 +3 (no change) 010 2 +2 +2 (no change) 001 1 +1 +1 (no change) 000 0 +0 +0 (no change) 100 4 0 0 (111) 101 5 1 1 (110) 110 6 2 2 (101) 111 7 3 3 (100) 44

3-bit True and Complement Forms Example Complement representation are for negative numbers Number Unsigned Signed and magnitude 1 s complement (of signed value) 011 3 +3 +3 (no change) 010 2 +2 +2 (no change) 001 1 +1 +1 (no change) 000 0 +0 +0 (no change) 100 4 0 0 (111) 101 5 1 1 (110) 110 6 2 2 (101) 111 7 3 3 (100) 2 s complement (of signed value) 45

3-bit True and Complement Forms Example Complement representation are for negative numbers Number Unsigned Signed and magnitude 1 s complement (of signed value) 2 s complement (of signed value) 011 3 +3 +3 (no change) +3 (no change) 010 2 +2 +2 (no change) +2 (no change) 001 1 +1 +1 (no change) +1 (no change) 000 0 +0 +0 (no change) +0 (no change) 100 4 0 0 (111) 4 (100) 101 5 1 1 (110) 1 (111) 110 6 2 2 (101) 2 (110) 111 7 3 3 (100) 3 (101) 46

Negating Numbers Using Complements To represent negative value of a positive number 1- you can represent using 1 s complement take the positive value, including the sign bit (which is 0) flip all bits to obtain 1 s complement representation E.g.: represent 6 in 1 s complement using 4-bit 6 is 0110 using 4-bits, 6 is 1001 in 1 s complement form 2- you can represent using 2 s complement once 1s complement is calculated, add 1 to the result E.g.: represent 6 in 2 s complement using 4-bit 6 is 0110 using 4-bits, 6 is 1001 in 1 s complement form 1010 is 2s complement of 6 (added 1 to 1 s complement) 47

Notes About Complements Complement of a complement is original value E.g.: 2 s complement of 101 is 111 E.g.: 2 s complement of 111 is 101 2 s complement of 1000000 0 in decimal will be the number itself: 1000000 0 2 s complement of 0000000 0 in decimal will be the number itself: 0000000 0 2 s complement of 1111111 1 in decimal will be: 1 1 s complement have 2 zero values hard to design a zero-detector using 1 s complement 48

Number Representation Range representing signed vs. unsigned numbers? E.g. 3-bit unsigned-magnitude example? Range: from 0 to +(2 n 1), 0 to 7 E.g. 3-bit signed-magnitude example? 1 s complement range: from (2 n 1 1) to +(2 n 1 1), 3 to +3 0 appears twice 2 s complement range: from (2 n 1 ) to +(2 n 1 1), 4 to +3 0 appears only once 49

Subtraction via 2 s Complements Consider two numbers: N1=11011 and N2=10110 N1: 011011 (27) N2: 110110 (22) D: 101 (5) Values in red representing the sign Instead find 2 s complement of N2=? 50

Subtraction via 2 s Complements Consider two numbers: N1=11011 and N2=10110 N1: 011011 (27) N2: 110110 (22) D: 00101 (5) Instead find 2 s complement of N2=? 1 s complement of N2 is: 110110 101001 2 s complement of N2 is: 101001 + 1 = 101010 51

Subtraction via 2 s Complements N1: 11011 (27) N2: 10110 (22) D: 00101 (5) Instead find 2 s complement of N2 = 01010 Instead of subtracting, add N1 and N2 s complement N1: 11011 (27) N2: 01010 (10) S: 100101 (37 32) Ignoring the end carry, are the results same: D vs S? 52

1 s Complement Addition Example Egemen K. Çetinkaya ( + 5 ) + ( + 2 ) ( + 7 ) 0 1 0 1 + 0 0 1 0 0 1 1 1 ( 5 ) + ( + 2 ) (- 3 ) 1 0 1 0 + 0 0 1 0 1 1 0 0 ( + 5 ) + ( 2 ) ( + 3 ) 0 1 0 1 + 1 1 0 1 10 0 1 0 1 0 0 1 1 ( 5 ) + ( 2 ) ( 7 ) 1 0 1 0 + 1 1 0 1 1 0 1 1 1 1 1 0 0 0 53

2 s Complement Addition Example Egemen K. Çetinkaya + ( + 5 ) ( + 2 ) + 0 1 0 1 0 0 1 0 + ( 5 ) ( + 2 ) + 1 0 1 1 0 0 1 0 ( + 7 ) 0 1 1 1 ( 3 ) 1 1 0 1 ( + 5 ) + ( 2 ) + 0 1 0 1 1 1 1 0 ( 5 ) + ( 2 ) + 1 0 1 1 1 1 1 0 ( + 3 ) 1 0 0 1 1 ( 7 ) 11 0 0 1 ignore ignore 54

Subtraction via 2 s Complements Subtraction via adding 2 s complement A B = A + ( B) A B = A + (2 s complement of B) A B = A + (inverted B + 1) A B N-bit A Adder B cin 1 S 55

Adder/Subtractor Combined Egemen K. Çetinkaya Performs X+Y or X Y depending on value of Add/Sub 56

Logic Gates XOR Gate Output is 1 when both input 1s are odd numbered Symbol: XOR Truth table: x y F 0 0 0 0 1 1 1 0 1 1 1 0 57

Overflow The result of addition or subtraction must fit into: number of allocated bits to represent the resulting number If the result does not fit, then overflow occurs Signed numbers range from (2 n 1 1) to +(2 n 1 1) Unsigned numbers range from 0 to +(2 n 1) Overflow can be determined by: if the sign bits are same but switched in the result if the sign bits are different, there cannot be overflow overflow = c n 1 c n 58

Overflow Examples + ( + 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 c 4 = 0 c 3 = 1 ( 5 ) 1 0 1 1 c 4 = 0 c 3 = 0 ( + 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 c 4 = 1 c 3 = 1 ( 9 ) 10 1 1 1 c 4 = 1 c 3 = 0 59

Half-subtractor: Summary subtracts two bits: minuend and subtrahend generates two output bits: difference and borrow Full-subtractor: subtracts three bits: minuend, subtrahend, and borrow in generates two output bits: difference and borrow out Negative binary numbers can be represented via: 1 s complements: flip all bits including the sign bit 2 s complements: 1s complement + 1 Overflow can be determined by: c n 1 c n 60

References and Further Reading [V2011] Frank Vahid, Digital Design with RTL Design, VHDL, and Verilog, 2nd edition, Wiley, 2011. [BV2009] Stephen Brown and Zvonko Vranesic, Fundamentals of Digital Logic with VHDL Design, 3rd edition, McGraw-Hill, 2009. [G2003] Donald D. Givone, Digital Principles and Design, McGraw-Hill, 2003. 61

End of Foils 62