Binary addition by hand. Adding two bits

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

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

14:332:231 DIGITAL LOGIC DESIGN

Binary addition example worked out

Carry Look Ahead Adders

Adders - Subtractors

Combinational Logic Design Arithmetic Functions and Circuits

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

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

Systems I: Computer Organization and Architecture

CS 140 Lecture 14 Standard Combinational Modules

Hardware Design I Chap. 4 Representative combinational logic

Number representation

Chapter 5 Arithmetic Circuits

CMPUT 329. Circuits for binary addition

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

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

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

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

3. Combinational Circuit Design

Class Website:

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

Adders, subtractors comparators, multipliers and other ALU elements

Adders, subtractors comparators, multipliers and other ALU elements

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

EECS150. Arithmetic Circuits

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

Fundamentals of Digital Design

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

CprE 281: Digital Logic

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

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

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

Combinational Logic. By : Ali Mustafa

Latches. October 13, 2003 Latches 1

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

ELCT201: DIGITAL LOGIC DESIGN

ARITHMETIC COMBINATIONAL MODULES AND NETWORKS

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

What s the Deal? MULTIPLICATION. Time to multiply

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

COMBINATIONAL LOGIC FUNCTIONS

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

UNIT II COMBINATIONAL CIRCUITS:

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

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

Hakim Weatherspoon CS 3410 Computer Science Cornell University

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.

Digital Design for Multiplication

EFFICIENT MULTIOUTPUT CARRY LOOK-AHEAD ADDERS

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

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

L8/9: Arithmetic Structures

CprE 281: Digital Logic

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

Solutions for Appendix C Exercises

ECEN 248: INTRODUCTION TO DIGITAL SYSTEMS DESIGN. Week 9 Dr. Srinivas Shakkottai Dept. of Electrical and Computer Engineering

ISSN (PRINT): , (ONLINE): , VOLUME-4, ISSUE-10,

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

Building a Computer Adder

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

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

Review: Additional Boolean operations

Digital System Design Combinational Logic. Assoc. Prof. Pradondet Nilagupta

Lecture 5: Arithmetic

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

EECS150 - Digital Design Lecture 22 - Arithmetic Blocks, Part 1

CS61C : Machine Structures

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

CSEE 3827: Fundamentals of Computer Systems. Combinational Circuits

CHAPTER1: Digital Logic Circuits Combination Circuits

ECE380 Digital Logic. Positional representation

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

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

CS61C : Machine Structures

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

Floating Point Representation and Digital Logic. Lecture 11 CS301

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

ELEN Electronique numérique

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

Chapter 1 CSCI

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

EECS150 - Digital Design Lecture 4 - Boolean Algebra I (Representations of Combinational Logic Circuits)

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

Numbers and Arithmetic

Digital Logic Design ENEE x. Lecture 14

CprE 281: Digital Logic

Outline. EECS150 - Digital Design Lecture 4 - Boolean Algebra I (Representations of Combinational Logic Circuits) Combinational Logic (CL) Defined

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

CS/COE0447: Computer Organization and Assembly Language

Combinational Logic. Course Instructor Mohammed Abdul kader

Adders allow computers to add numbers 2-bit ripple-carry adder

ECE/CS 250 Computer Architecture

20. Combinational Circuits

WORKBOOK. Try Yourself Questions. Electrical Engineering Digital Electronics. Detailed Explanations of

Arithmetic Circuits Didn t I learn how to do addition in the second grade? UNC courses aren t what they used to be...

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

GALOP : A Generalized VLSI Architecture for Ultrafast Carry Originate-Propagate adders

Lecture 12: Adders, Sequential Circuits

Transcription:

Chapter 3 Arithmetic is the most basic thing you can do with a computer We focus on addition, subtraction, multiplication and arithmetic-logic units, or ALUs, which are the heart of CPUs. ALU design Bit slice processors

Binary addition by hand You can add two binary numbers one column at a time starting from the right, just as you add two decimal numbers. But remember that it s binary. For example, + = 0 and you have to carry! The initial carry in is implicitly 0 0 Carry in 0 Augend + 0 Addend 0 0 Sum most significant bit, or MSB least significant bit, or LSB Adding two bits We ll make a hardware adder by copying the human addition algorithm. We start with a half adder, which adds two bits and produces a two-bit result: a sum (the right bit) and a carry out (the left bit). Here are truth tables, equations, circuit and block symbol. X Y C S 0 0 0 0 0 0 0 0 0 0 + 0 = 0 0 + = + 0 = + = 0 C = XY S = X Y + X Y = X Y 2

Adding three bits But what we really need to do is add three bits: the augend and addend, and the carry in from the right. 0 0 + 0 0 0 X Y C in C out S 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 + 0 = 00 0 + 0 + 0 = 0 0 + + 0 = 0 0 + + = 0 + 0 + 0 = 0 + 0 + = 0 + + 0 = 0 + + = Full adder equations A full adder circuit takes three bits of input, and produces a two-bit output consisting of a sum and a carry out. Using Boolean algebra, we get the equations shown here. XOR operations simplify the equations a bit. We used algebra because you can t easily derive XORs from K-maps. X Y C in C out S 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 S = Σm(,2,4,7) = X Y C in + X Y C in + X Y C in + X Y C in = X (Y C in + Y C in ) + X (Y C in + Y C in ) = X (Y C in ) + X (Y C in ) = X Y C in C out = Σm(3,5,6,7) = X Y C in + X Y C in + X Y C in + X Y C in =XC in + YC in + XY 3

Full adder circuit These things are called half adders and full adders because you can build a full adder by putting together two half adders! S = X Y C in C out = XC in + YC in + XY A 4-bit adder Four full adders together make a 4-bit adder. There are nine total inputs: Two 4-bit numbers, A3 A2 A A0 and B3 B2 B B0 An initial carry in, CI The five outputs are: A 4-bit sum, S3 S2 S S0 A carry out, CO Imagine designing a nine-input adder without this hierarchical structure you d have a 52-row truth table with five outputs! 4

An example of 4-bit addition Let s try our initial example: A=0 (eleven), B=0 (fourteen). 0 0 0 0 0 0. Fill in all the inputs, including CI=0 2. The circuit produces C and S0 ( + 0 + 0 = 0) 3. Use C to find C2 and S ( + + 0 = 0) 4. Use C2 to compute C3 and S2 (0 + + = 0) 5. Use C3 to compute CO and S3 ( + + = ) The final answer is 00 (twenty-five). Hierarchical adder design When you add two 4-bit numbers the carry in is always 0, so why does the 4-bit adder have a CI input? One reason is so we can put 4-bit adders together to make even larger adders! This is just like how we put four full adders together to make the 4-bit adder in the first place. Here is an 8-bit adder, for example. CI is also useful for subtraction, as we ll see next week. 5

6 bit full adder Propagation Delay When the input signal of a gate changes, the output signal will not change instantaneously as is shown in Figure below. The propagation delay (or gate delay) of a gate is the time difference between the change of the input and output signals. All logic gates take a non-zero time delay to respond to a change in input. This is the propagation delay of the gate, typically measured in tens of nanoseconds. 6

Delays in the ripple carry adder The diagram below shows a 4-bit adder completely drawn out. This is called a ripple carry adder, because the inputs A 0, B 0 and CI ripple leftwards until CO and S 3 are produced. Ripple carry adders are slow! Our example addition with 4-bit inputs required 5 steps. There is a very long path from A 0, B 0 and CI to CO and S 3. For an n-bit ripple carry adder, the longest path has 2n+ gates. Imagine a 64-bit adder. The longest path would have 29 gates! 9 8 7 6 5 4 3 2 A faster way to compute carry outs Instead of waiting for the carry out from all the previous stages, we could compute it directly with a two-level circuit, thus minimizing the delay. First we define two functions. The generate function g i produces when there must be a carry out from position i (i.e., when A i and B i are both ). g i = A i B i The propagate function p i is true when, if there is an incoming carry, it is propagated (i.e, when A i = or B i =, but not both). p i = A i + B i Then we can rewrite the carry out function: c i+ = g i + p i c i g i A i B i C i C i+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 p i 7

Algebraic carry out hocus-pocus Let s look at the carry out equations for specific bits, using the general equation from the previous page c i+ = g i + p i c i : c = g 0 + p 0 c 0 c 2 = g + p c = g + p (g 0 + p 0 c 0 ) = g + p g 0 + p p 0 c 0 c 3 = g 2 + p 2 c 2 = g 2 + p 2 (g + p g 0 + p p 0 c 0 ) = g 2 + p 2 g + p 2 p g 0 + p 2 p p 0 c 0 c 4 = g 3 + p 3 c 3 = g 3 + p 3 (g 2 + p 2 g + p 2 p g 0 + p 2 p p 0 c 0 ) = g 3 + p 3 g 2 + p 3 p 2 g + p 3 p 2 p g 0 + p 3 p 2 p p 0 c 0 These expressions are all sums of products, so we can use them to make a circuit with only a two-level delay. Carry look ahead adders 8

Basic CLA Cell Ci Gi Pi BA (basic adder) Xi Yi Si Carry lookahead adders This is called a carry lookahead adder. By adding more hardware, we reduced the number of levels in the circuit and sped things up. We can cascade carry lookahead adders, just like ripple carry adders. (We d have to do carry lookahead between the adders too.) How much faster is this? For a 4-bit adder, not much. There are 4 gates in the longest path of a carry lookahead adder, versus 9 gates for a ripple carry adder. But if we do the cascading properly, a 6-bit carry lookahead adder could have only 8 gates in the longest path, as opposed to 33 for a ripple carry adder. Newer CPUs these days use 64-bit adders. That s 2 vs. 29 gates! The delay of a carry lookahead adder grows logarithmically with the size of the adder, while a ripple carry adder s delay grows linearly. The thing to remember about this is the trade-off between complexity and performance. Ripple carry adders are simpler, but slower. Carry lookahead adders are faster but more complex. 9

Carry Look-Ahead Adder Design 4-bit Carry-Look Ahead Adder C i+ = G i + P i.c i G i = A i.b i P i = (A i B i ) Carry Look-Ahead Adder Design 6-bit Carry-Look Ahead Adder using 4-bit Carry-Look-Ahead Adders P G = P 3.P 2.P.P 0 ; G G = G 3 + P 3 G 2 + P 3.P 2.G. + P 3.P 2.P.G 0 0

Subtraction: A-B = A + (-B) Using 2 s complement representation: B = ~B + ~ = bit-wise complement B 0 B B B So let s build an arithmetic unit that does both addition and subtraction. Operation selected by control input: The circuit shown computes A + B and A B: For S =, subtract, the 2 s complement of B is formed by using XORs to form the s comp and adding the applied to C 0. For S = 0, add, B is passed through unchanged B 3 A 3 B 2 A 2 B A B 0 A 0 C 3 C 2 C C 0 FA FA FA FA S C 4 S 3 S 2 S S 0