Number representation

Similar documents
Binary addition by hand. Adding two bits

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

Chapter 5 Arithmetic Circuits

CprE 281: Digital Logic

Adders, subtractors comparators, multipliers and other ALU elements

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

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

ARITHMETIC COMBINATIONAL MODULES AND NETWORKS

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

CS 140 Lecture 14 Standard Combinational Modules

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

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

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

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

Carry Look Ahead Adders

CMP 334: Seventh Class

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

Combinational Logic. By : Ali Mustafa

Hardware Design I Chap. 4 Representative combinational logic

ELCT201: DIGITAL LOGIC DESIGN

Combinational Logic Design Arithmetic Functions and Circuits

Systems I: Computer Organization and Architecture

14:332:231 DIGITAL LOGIC DESIGN

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

Fundamentals of Digital Design

Computer Architecture 10. Fast Adders

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

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

ECE380 Digital Logic. Positional representation

COMBINATIONAL LOGIC FUNCTIONS

Ex code

CprE 281: Digital Logic

EECS150. Arithmetic Circuits

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

Hakim Weatherspoon CS 3410 Computer Science Cornell University

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

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

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

UNIT II COMBINATIONAL CIRCUITS:

Lecture 5: Arithmetic

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

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

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

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

Floating Point Representation and Digital Logic. Lecture 11 CS301

Adders - Subtractors

Design of Sequential Circuits

CMPUT 329. Circuits for binary addition

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

Class Website:

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

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

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

Sample Test Paper - I

Review for Test 1 : Ch1 5

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

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

UNIVERSITI TENAGA NASIONAL. College of Information Technology

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

ELEN Electronique numérique

Menu. 7-Segment LED. Misc. 7-Segment LED MSI Components >MUX >Adders Memory Devices >D-FF, RAM, ROM Computer/Microprocessor >GCPU

Numbers and Arithmetic

CMPEN 411 VLSI Digital Circuits Spring Lecture 19: Adder Design

COMPUTERS ORGANIZATION 2ND YEAR COMPUTE SCIENCE MANAGEMENT ENGINEERING UNIT 3 - ARITMETHIC-LOGIC UNIT JOSÉ GARCÍA RODRÍGUEZ JOSÉ ANTONIO SERRA PÉREZ

Boolean Algebra and Digital Logic 2009, University of Colombo School of Computing

UNIT 4 MINTERM AND MAXTERM EXPANSIONS

Chapter 7 Logic Circuits

Cs302 Quiz for MID TERM Exam Solved

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

CHAPTER1: Digital Logic Circuits Combination Circuits

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

Latches. October 13, 2003 Latches 1

CS/COE0447: Computer Organization and Assembly Language

CSE140: Components and Design Techniques for Digital Systems. Logic minimization algorithm summary. Instructor: Mohsen Imani UC San Diego

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

VLSI Design. [Adapted from Rabaey s Digital Integrated Circuits, 2002, J. Rabaey et al.] ECE 4121 VLSI DEsign.1

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

ECE/CS 552: Introduction To Computer Architecture 1. Instructor:Mikko H Lipasti. Fall 2010 University i of Wisconsin-Madison

ALUs and Data Paths. Subtitle: How to design the data path of a processor. 1/8/ L3 Data Path Design Copyright Joanne DeGroat, ECE, OSU 1

Chap 2. Combinational Logic Circuits

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

Additional Gates COE 202. Digital Logic Design. Dr. Muhamed Mudawar King Fahd University of Petroleum and Minerals

Arithmetic in Integer Rings and Prime Fields

Looking at a two binary digit sum shows what we need to extend addition to multiple binary digits.

CprE 281: Digital Logic

Lecture 7: Logic design. Combinational logic circuits

XI STANDARD [ COMPUTER SCIENCE ] 5 MARKS STUDY MATERIAL.

L8/9: Arithmetic Structures

CprE 281: Digital Logic

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

Digital Integrated Circuits A Design Perspective. Arithmetic Circuits. Jan M. Rabaey Anantha Chandrakasan Borivoje Nikolic.

Computer Architecture. ESE 345 Computer Architecture. Design Process. CA: Design process

Lecture 8: Sequential Multipliers

Part II Addition / Subtraction

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

( c) Give logic symbol, Truth table and circuit diagram for a clocked SR flip-flop. A combinational circuit is defined by the function

EECS150 - Digital Design Lecture 24 - Arithmetic Blocks, Part 2 + Shifters

Chapter 2: Switching Algebra and Logic Circuits

Transcription:

Number representation A number can be represented in binary in many ways. The most common number types to be represented are: Integers, positive integers one-complement, two-complement, sign-magnitude Decimal real numbers with a fixed range fixed-point Decimal real numbers floating-point

Integers Positive integers: 2 6 2 5 2 4 2 3 2 2 2 1 2 0 1 1 0 1 1 0 1 = 1 2 6 + 1 2 5 + 1 2 3 + 1 2 2 + 1 2 0 = 109 But how to represent negative numbers???

Sign-magnitude Integer: S 2 5 2 4 2 3 2 2 2 1 2 0 1 1 0 1 1 0 1 = - (1 2 5 + 1 2 3 + 1 2 2 + 1 2 0 ) = - 45 The magnitude of the number Sign-bit Drawback: 1 0 0 0 0 0 0 two representations 0 0 0 0 0 0 0 of zero (+/-) 0

1-complement The negative numbers are the complement of the positive numbers. Bit for bit in the positive number is inverted to get the corresponding negative. B=b N-1 b N-2...b 1 b 0 där b i {0,1} b N-1 b N-2... b 1 b 0 Sign Bit Drawbacks: Two zeroes (+/-) 0. At some additions adjusting is required.

2-complement Representation with 2-complement B=b N-1 b N-2...b 1 b 0 där b i {0,1} b N-1 b N-2... b 1 b 0 Sign Bit Decimalvalue: D(B)= - b N-1 2 N-1 +b N-2 2 N-2 +...+b 1 2 1 +b 0 2 0 This is the most common representation of signed integers.

2-complement Conversion example: B=b N-1 b N-2...b 1 b 0 där b i {0,1} 1 1 1 1 1 1 1 1 Sign Bit Decimalvalue: D(B)= - b N-1 2 N-1 +b N-2 2 N-2 +...+b 1 2 1 +b 0 2 0 = -128 + 127 = -1 It s alwais the biggest number that corresponds to -1.

Number conversion positive number to negative The Twocomplement methood 01111 +15 10000 invert 10001 add one 10001-15

Number conversion negative number to positive Twocomplement methood 10001-15 01110 invert 01111 add one 01111 +15 The same procedure in both directions!

2-complement 000 Computer registers are "rings". The figure shows a three-bit register. When you count with signed numbers the negative numbers, are the left half of the ring. 110 111-2 -1 0 001-3 3 101-4 011 100 1 2 010

2-complement fast conversion In order to easily produce 2's complement of a binary number, you can use the following procedure: Start fron the right side Copy all bits from the binary number that is 0 and the first bit that is 1. Invert Invert the rest of the bits. Copy Exemple: 2-complement from 110 is 010

Sign-extension In calculations the computers often need to increase the number of digits (bits) before any calculation - how do you do it with negative numbers? Integer: -2 6 2 5 2 4 2 3 2 2 2 1 2 0 1 1 0 1 1 0 1 = -1 2 6 + 1 2 5 +1 2 3 + 1 2 2 + 1 2 0 = - 45 Sign bit has a negative weight -2 n-1 2 n-2 1 1 2 7 1 2 6 2 5 2 4 2 3 2 2 2 1 2 0 1 1 0 1 1 0 1 If you want to extend the number of digits you need to copy the sign bit to all extended bits!

Addition (BV: page 264) (+5) + (+2) (+7) 0101 + 0010 0111

Addition (BV: page 264) ignore (+5) + (-2) (+3) 1 1 0101 + 1110 1 0011 Carry-bit could be ignored!

Addition (BV: page 264) ignore (-5) + (-2) (-7) 1 11 1011 + 1110 1 1001 Carry-bit could be ignored!

Overflow Overflow the sign bit is not consistent with the input numbers (+5) + (+5) (-6) 1 1 0101 + 0101 1010

Overflow 2 ignore Overflow the sign bit is not consistent with the input numbers (-5) + (-5) (+6) 1 11 1011 + 1011 1 0110 Carry-bit could be ignored!

Subtraction (BV: page 265) Borrow one (+5) - (+2) (+3) 10 0101-0010???? How do you do the subtraction in an easy way?

Subtraction (BV: page 265) ignore (+5) - (+2) 0101-0010 1 1 0101 + 1110 (+3)???? 1 0011 Making an addition of 2's complement instead! Carry-bit could be ignored!

Subtraction (BV: page 265) ignore (-5) - (+2) 1011-0010 111 1011 + 1110 (-7)???? 1 1001 Carry-bit could be ignored!

Subtraction (BV: page 265) (+5) - (-2) (+7) 1011-1110???? 0101 + 0010 0111

Subtraction (BV: page 265) (-5) - (-2) (-3) 1011-1110???? 1 1011 + 0010 1101

2-complement summary Range: -2 N-1 up to 2 N-1-1 Negation: Invert every bit (the boolean complement), and add 1. Expansion of bit-length: Extend with bits at the left of the number with the same value as the sign bit. Overflow-rule: If two numbers with the same sign are added, it has become overflow if the result has the opposite sign. Subtraction rule: To subtract B from A, take the two complement of B and add to A.

Alternative way to detect overflow (BV: page 271) c 4 =0 c 3 =1 (+7) + (+2) (-7) 0 1 1 0111 + 0010 1001 Overflow because c 4 and c 3 are different!

Alternative way to detect overflow (BV: page 271) c 4 =0 c 3 =0 (-7) + (+2) (-5) 0 0 1001 + 0010 1011 Not Overflow because c 4 and c 3 are the same!

Alternative way to detect overflow (BV: page 271) ignore (+7) + (-2) (+5) c 4 =1 c 3 =1 1 1 1 0111 + 1110 1 0101 Not Overflow because c 4 and c 3 are the same! Carry-bit could be ignored!

Alternative way to detect overflow (BV: page 271) ignore (-7) + (-2) (+7) c 4 =1 c 3 =0 1 0 1001 + 1110 1 0111 Overflow because c 4 and c 3 are different! Carry-bit could be ignored!

Logic to detect overflow XOR For 4-bit-number Overflow if c 3 och c 4 are different Otherwise, it is not overflow Overflow = c 3 c 4 + c 3 c 4 = c 3 c 4 For n-bit-number Overflow = c n 1 c n

Quickie Question The number +5 is represented by 0101 if we use 4 bits. What number is equivalent to -5 if we use 8-bit two's complement representation? a: 1111 1011 b: 1111 1010 c: 1000 0101

Hardware for arithmetic

Half adder a b HA s c a b c s 0 0 0 0 0 1 0 1 1 0 0 1 1 1 1 0 a b 0 1 0 1 0 0 0 1 a b 0 1 0 1 0 1 1 0 c = a b s = a b a b s c

Full adder a b c in FA s c ut a b c in c ut s 0 0 0 0 0 0 0 1 0 1 0 1 0 0 1 0 1 1 1 0 1 0 0 0 1 1 0 1 1 0 1 1 0 1 0 1 1 1 1 1 a b c in s c ut c in c in 0 1 ab 00 01 11 10 0 1 0 1 1 0 1 0 s = a b c in 00 01 11 10 0 0 0 1 0 1 0 1 1 1 c ut = a b + c in a + c in b

The sum function? c in 00 01 11 10 0 1 0 1 1 0 0 1 1 0 s = a b c in

c ab 0 1 0 1 1 0 Sum = Odd parity The Full Adder sum function is the "odd" parity function. This is the XOR function s natural extension to more variables than two. Odd parity is when the number of 1 s on the inputs is an odd number. Odd parity 00 01 11 10 0 1 1 0 b 0 1 a XOR 0 1 0 1 1 0 Odd parity a b a b c Odd parity

Carry function? 00 01 11 10 0 1 0 0 0 1 1 0 1 1 Majority function. Output assumes same value 1/0 as a majority of the inputs. M

Full-adder with two ½ -adders We may also construct a full-adder with two half-adders and an OR gate. a b c in FA s c ut a b c in HA HA s cut Decomposition means that you see the circuit as composed of building blocks. Such known building blocks could be used to build build entirely new systems, Composition.

a b c in c ut s 0 0 0 0 0 0 0 1 0 1 0 1 0 0 1 0 1 1 1 0 1 0 0 0 1 1 0 1 1 0 1 1 0 1 0 1 1 1 1 1 Full-adder ½+ ½ = 1 c in a b c in a b HA (a b) can be shared for both s and c ut! HA s cut s c ut c in c in ab a b 00 01 11 10 0 0 0 1 0 1 0 1 1 1 (a b) c in c ut = (a b) c in + a b ab 00 01 11 10 0 0 1 0 1 1 1 0 1 0 s = a b c in

Popular tattoo? Tattoos are forever! Unfortunately this is not the "best" adder, not if you want fast computers. Exciting continuation of adder circuits follow...

( Parityfunction Three-way light control) c in 0 1 00 01 11 10 0 1 0 1 1 0 1 0 Odd parity. s = a b c in

Three-way light control - revisited Brown/Vranesic: 2.8.1 Suppose that we need to be able to turn on / off the light from three different places. x 3 x 2 f Parityfunction x 1 x 2 x 3 Odd parity f x 1

XOR or NAND? x 1 x 2 x 3 Udda paritet f The former solution was based on NAND gates. XOR gates will be much more effective than NAND gates! x 1 x 2 x 3 f x x 2 x 3 1 00 01 11 10 f 0 1 0 1 1 0 0 1 1 0

Simpler with XOR gates With XOR-gates: x 1 x 2 x 3 f 7486 ( With NAND-gates: )

( Parity check ) With parity function we can check whether data has been disturbed or not. Disturbance! Data transmitted always have even parity! ALARM!? A bit modified!? Data has been disturbed! 0 1 P U P U? 1 0 1 0 0 1 0 1 0 0 1 1 1 0 1 1 1 0 Data - orginal Paritybit is added Parity Check Checks if an odd number of "1s is recived error!

More composition composition can be used to construct the n-bit adder One need n full-adders for constructing an n-bit adder?

Ripple-Carry Adder (RCA) a 1 b 1 a 0 b 0 c ut1 FA c in1 c ut0 FA c in0 s 1 s 0 + c ut1 c ut0 b 1 a 1 s 1 c in0 b 0 a 0 s 0

Ripple-Carry Adder (RCA) a n-1 b n-1 a 1 b 1 a 0 b 0 c utn-1 FA c inn-1 FA c in1 c ut0 FA c in0 s n-1 s 1 s 0 a n-1 b n-1... a 0 b 0 A FA area for a Fulladder t FA delay trough a Fulladder c utn-1 n-bit ADD s n-1... s 0 c in0 Timedelay from c in0 to c outn-1 is total of n t FA Total area is n A FA

Ripple-Carry Adder (RCA) a0 b0 c in0 s0 Critical path a1 b1 s1

Fulladder Carry-function & AND-OR A AND-OR = 20 MOS T AND-OR = 5T NAND & NAND-NAND & >1 & & & A NAND-NAND = 14 MOS T NAND-NAND = 3T NAND &

XOR with NAND & & & & a b b a b a ab ab b a b b a a b a b b a a = + = = + + + = = + ) ( ) ( ) ( ) ( Area: A XOR =16 MOS Delay: T XOR =3T NAND

Can we construct a faster adder? The delay of a ripple adder grows proportionally with the number of bits For 32 bits, the delay becomes very large

generate- och propagate- funktionerna p i = x i + y i p i = x Works also! The Carry-chain can be described by two functions: Generate g i ( carry-out c i+1 = 1 if g i = 1 ) Propagate p i ( carry-out c i+1 = 1 if c i = 1 and x i = 1 or y i = 1 ) i y i 0 0 g i = x i y i 1 c = g + i+1 i p i c i c i c i x i y i 0 c = 0 1 c i+ 1 x 00 01 11 10 0 1 i x i y i = y i x i 0 0 0 1 y i + c i 1 0 1 1 + c ( x i i x + 00 01 11 10 = x y 1 0 1 1 + c i + c y ( x i ) i y y i+ 1 i i i i i i )

Carry-look-ahead function Carry-bit c 0 g i = x i y i c 1 = g 0 + p 0 c 0 Carry-bit c 1 c 2 = g 1 + p 1 c 1 = g 1 + p 1 (g 0 + p 0 c 0 ) Propagate function from previous bits can be generated in parallel p i = x i + y i = g 1 + p 1 g 0 + p 1 p 0 c 0 Only two logic levels is needed

Carry-chain in ripple-adder #1 ½ + ½ c 0 OR or XOR can be used for the p function! p 0 g 0 p 1 g 1 #2 #3 #4 c1 c 2 #5 p 2 #6 g 2 6 gate levels c 3

Quicker implementation of the Carry-chain Distributive theorem: (a+b)c = ac+bc c 0 p 0 g 0 c 1 p 1 g 1 c 2 c 1 = g 0 +p 0 c 0 c 2 = g 1 +p 1 g 0 +p 1 p 0 c 0 Two- logic levels

(n=8) and two logic levels c 1 =g 0 +p 0 c 0 c 2 =g 1 +p 1 g 0 +p 1 p 0 c 0.... Fast, but cumbersome with so many inputs! 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 Ooops!

Carry-lookahead adder (CLA) 8-bit adder c s s s s s s = a a a a a a + b 8 7 6 5 4 3 2s1s0 7 6 5 4 3 2a1a0 7 6 5 4 3 2b1b 0 b b b b b a 7 b 7 a 6 b 6 a 5 b 5 a 4 b 4 a 3 b 3 a 2 b 2 a 1 b 1 a 0 b 0 1-bit Full Adder 1-bit Full Adder 1-bit Full Adder 1-bit Full Adder 1-bit Full Adder 1-bit Full Adder 1-bit Full Adder 1-bit Full Adder c 0 s 7 s 6 s 5 s 4 s 3 s 2 s 1 s 0 c 8 p 7 g 7 c 7 p 6 g 6 c 6 p 5 g 5 c 5 p 4 g 4 c 4 p 3 g 3 Carry look ahead unit c 3 p 2 g 2 c 2 p 1 g 1 c 1 p 0 g 0 P 0 G 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

Hierarchical expansion (BV page 277) a 31-24 b 31-24 a 23-16 b 23-16 32-bit adder a 15-8 b 15-8 a 7-0 b 7-0 32-bit adder. Each block consists of a 8-bit CLA. Block 3 CLA Block 2 CLA Block 1 CLA Block 0 CLA G 3 P 3 S 31-24 G 2 P 2 S 23-16 G 1 P 1 S 15-8 G 0 P 0 S 7-0 c 8 c 0 First level four 8-bit adders with Carry lookahead c 32 P G P G 3 3 2 2PG 1 1P0 G0 c 0 c 24 P G 2 2PG 1 1P0 G0 c 16 c 0 PG P 1 1 0G0 c 0 P 0 G 0 c 0 Second level four Carry lookahead units

Hierarchical expansion C 8 = G 0 +P 0 c 0 C 16 = 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 etc. More gates in sequential steps, but gates with fewer inputs can be used.

(Carry look ahead three level hierarchy) 16-bit LCU 64-bit adder 64-bit LCU

Carry-Select-Adder (CSA) Idea One divides an adder in two stages with the same number of bits To speed up the process so you calculate the results of the second step in advance for the two cases Carry-in = 0 Carry-in = 1 When the calculation of the carry bit is clear for the first step, then we choose the result of the second step depending on carry the bit value!

8-bit Carry-Select-Adder c 8-high b[7:4] a[7:4] a[3:0] b[3:0] 1 0 Add Add Add c 8-low c 0 a b a+b = s Mux c c 8 Mux c c 4 s[7:4] s[3:0] s

Ripple-Carry Adder Comparision T(n)= n*2.5*t NAND, A = n*12.5t NAND +T XOR T(4)= 14T NAND, A(4) = 50 A NAND Carry-Lookahead Adder (4bits) T(4)= ~8T NAND, A(4)= 43A NAND +4*4*A NAND = ~60A NAND Carry-Select Adder (8 bits) T(8)= ~(8+4)T NAND, A(8)= ~(120+20)A NAND

Which is the best adder? There is no clear answer! Ripple adder takes a minimum of space but is slow Carry-look-ahead adder take much space but it is fast Carry-select adder is a compromise One must make a trade-off between Area and speed

Subtraction Subtraction can be made by the addition of the two complement Invert all bits of the second operand and add one

Add/sub-unit y n 1 y 1 y 0 Add/Sub = 0: Addition Add/Sub = 1: Subtraction Add Sub control x n 1 x 1 x 0 c n n -bit adder c 0 s n 1 s 1 s 0

Arithmetic Logic Unit (ALU) Function selection f 0 f 1 AU LU A/L MUX f 0 f 1 A/L x ALU y c in Processors use to have an ALU, not only an adder. A/L f1 f0 Function 0 0 0 x+y 0 0 1 x+y+c in 0 1 0 x-y 0 1 1 x-y-c in 1 0 0 x or y 1 0 1 x and y 1 1 0 x xor y 1 1 1 inv x

Comparator Comparator is implemented as a subtractioncircuit???

Comparator Comparator is implemented as a subtractioncircuit

Summary Addition and subtraction of integers Two-complement Subtraction of a number is implemented as addition of it s two-complement Trade-Off: Area against Speed Different Adder-structures Ripple-Carry Adder (RCA) Carry-Lookahead Adder (CLA) Carry-Select Adder (CSA)