Binary Adders: Half Adders and Full Adders

Similar documents
Chapter 3: part 3 Binary Subtraction

A complement number system is used to represent positive and negative integers. A complement number system is based on a fixed length representation

Chapter 4 Arithmetic Functions

Number System. Introduction. Decimal Numbers

ECE 30 Introduction to Computer Engineering

Register Transfer Language and Microoperations (Part 2)

THE LOGIC OF COMPOUND STATEMENTS

60-265: Winter ANSWERS Exercise 4 Combinational Circuit Design

LECTURE 4. Logic Design

Advanced Computer Architecture-CS501

Chapter 3 Arithmetic for Computers

Basic Arithmetic (adding and subtracting)

Chapter 4. Combinational Logic

ECE 2030D Computer Engineering Spring problems, 5 pages Exam Two 8 March 2012

Representation of Non Negative Integers

8/27/2016. ECE 120: Introduction to Computing. Graphical Illustration of Modular Arithmetic. Representations Must be Unambiguous

ECE 2030B 1:00pm Computer Engineering Spring problems, 5 pages Exam Two 10 March 2010

Microcomputers. Outline. Number Systems and Digital Logic Review

Binary Values. CSE 410 Lecture 02

CS/COE 0447 Example Problems for Exam 2 Spring 2011

4. Write a sum-of-products representation of the following circuit. Y = (A + B + C) (A + B + C)

EE292: Fundamentals of ECE

CARLETON UNIVERSITY. Laboratory 2.0

Lecture 6: Signed Numbers & Arithmetic Circuits. BCD (Binary Coded Decimal) Points Addressed in this Lecture

Principles of Computer Architecture. Chapter 3: Arithmetic

Number Systems. Readings: , Problem: Implement simple pocket calculator Need: Display, adders & subtractors, inputs

CSE303 Logic Design II Laboratory 01

Experiment 7 Arithmetic Circuits Design and Implementation

Real Digital Problem Set #6

Arithmetic-logic units

DIGITAL ARITHMETIC: OPERATIONS AND CIRCUITS

Chapter 3 Data Representation

Addition and multiplication

Binary Addition. Add the binary numbers and and show the equivalent decimal addition.

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two Solutions 26 February 2014

Number Systems and Computer Arithmetic

CO Computer Architecture and Programming Languages CAPL. Lecture 9

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

Chapter 4 Arithmetic

UC Berkeley College of Engineering, EECS Department CS61C: Combinational Logic Blocks

UC Berkeley College of Engineering, EECS Department CS61C: Combinational Logic Blocks

Chapter 4. Operations on Data

Digital Fundamentals. Lab 6 2 s Complement / Digital Calculator

Arithmetic Logic Unit (ALU)

COSC 243. Data Representation 3. Lecture 3 - Data Representation 3 1. COSC 243 (Computer Architecture)

Experimental Methods I

CS 31: Introduction to Computer Systems. 03: Binary Arithmetic January 29

Introduction to Computer Science. Homework 1

How a Digital Binary Adder Operates

Introduction to Computers and Programming. Numeric Values

Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates. Invitation to Computer Science, C++ Version, Third Edition

T02 Tutorial Slides for Week 2

Digital Logic Design (3)

Ripple Counters. Lecture 30 1

CS 31: Intro to Systems Binary Arithmetic. Kevin Webb Swarthmore College January 26, 2016

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two 26 February 2014

Student Number: UTORid: Question 0. [1 mark] Read and follow all instructions on this page, and fill in all fields.

ECEN 468 Advanced Logic Design

IA Digital Electronics - Supervision I

Computer Organization and Levels of Abstraction

Lecture Topics. Announcements. Today: Integer Arithmetic (P&H ) Next: continued. Consulting hours. Introduction to Sim. Milestone #1 (due 1/26)

CPE 335 Computer Organization. MIPS Arithmetic Part I. Content from Chapter 3 and Appendix B

Combinational Circuits

Basic Definition INTEGER DATA. Unsigned Binary and Binary-Coded Decimal. BCD: Binary-Coded Decimal

Computer Organization and Levels of Abstraction

Logic, Words, and Integers

Week 7: Assignment Solutions

Bawar Abid Abdalla. Assistant Lecturer Software Engineering Department Koya University

Standard Boolean Forms

COMP 122/L Lecture 2. Kyle Dewey

ECE 341 Midterm Exam

Lecture #21 March 31, 2004 Introduction to Gates and Circuits

Integer Multiplication and Division

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-2700: Digital Logic Design Winter Notes - Unit 4. hundreds.

CS 64 Week 1 Lecture 1. Kyle Dewey

Computer Architecture and Organization: L04: Micro-operations

COMP combinational logic 1 Jan. 18, 2016

ECE 550D Fundamentals of Computer Systems and Engineering. Fall 2017

Digital Systems. John SUM Institute of Technology Management National Chung Hsing University Taichung, ROC. December 6, 2012

LOGIC CIRCUITS. Kirti P_Didital Design 1

COMBINATIONAL LOGIC CIRCUITS

Computer Architecture and Organization

4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning

DLD VIDYA SAGAR P. potharajuvidyasagar.wordpress.com. Vignana Bharathi Institute of Technology UNIT 3 DLD P VIDYA SAGAR

Revision: August 31, E Main Suite D Pullman, WA (509) Voice and Fax

Combinational and sequential circuits (learned in Chapters 1 and 2) can be used to create simple digital systems.

CS Computer Architecture. 1. Explain Carry Look Ahead adders in detail

CHAPTER 4: Register Transfer Language and Microoperations

Injntu.com Injntu.com Injntu.com R16

EECS150 - Digital Design Lecture 13 - Combinational Logic & Arithmetic Circuits Part 3

Integer Encoding and Manipulation

Computer Architecture Set Four. Arithmetic

Computer Sc. & IT. Digital Logic. Computer Sciencee & Information Technology. 20 Rank under AIR 100. Postal Correspondence

REGISTER TRANSFER AND MICROOPERATIONS

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-278: Digital Logic Design Fall Notes - Unit 4. hundreds.

1. Mark the correct statement(s)

Data Representation Type of Data Representation Integers Bits Unsigned 2 s Comp Excess 7 Excess 8


Lecture 10: Combinational Circuits


Transcription:

Binary Adders: Half Adders and Full Adders In this set of slides, we present the two basic types of adders: 1. Half adders, and 2. Full adders. Each type of adder functions to add two binary bits. In order to understand the functioning of either of these circuits, we must speak of arithmetic in terms that I learned in the second grade. In the first grade, I learned by plus tables, specifically the sum of adding any two one digit numbers: 2 + 2 = 4, 2 + 3 = 5, etc. In the second grade, I learned how to add numbers that had more than one digit each: 23 + 34 = 57, but 23 + 38 = 61. This adaptation of addition to multiple digit numbers gives rise to the full adder. Page 1 of 32 September 6, 2012

Some Sample Sums, with Comments We begin with two simple sums, each involving only single digits. 2 + 2 = 4, and 5 + 5 = 10. If these are so, why do we write the following sum 25 + 25 as 25 + 25 = 50, and not as 25 + 25 = 4 10? What digit is written in the unit s column of the sum? The reason that we do not do this is the idea of a carry from the unit s column to the ten s column. In the language of the second grade, we describe the addition as follows: 1. 5 + 5 is 0, with a carry out of 1, which goes into the ten s column. 2. 2 + 2 is 4, but we have a carry in of 1 from the unit s column, so we say 2 + 2 + 1 = 5. The sum digit in this column is a 5. Page 2 of 32 September 6, 2012

Positional Notation in Arithmetic In standard decimal arithmetic, the number 25 is read as twenty five, and represents 2 10 + 5 1: two tens plus five ones. Remember that the only digits used in binary numbers are 0 and 1. In binary arithmetic, the number 10 is read as one zero, avoiding the names we use for decimal numbers. It represents 1 2 + 0 1. In binary arithmetic, the number 101 represents 1 2 2 + 0 2 1 + 1 1, or 1 4 + 0 2 + 1 1 = 4 + 1 = 5. In all arithmetics: 0 + 0 = 0, 0 + 1 = 1, and 1 + 0 = 1. In decimal arithmetic: 1 + 1 = 2. In binary arithmetic what is 1 + 1? Page 3 of 32 September 6, 2012

The Sum 1 + 1 in Binary Arithmetic We have just noted that the decimal number 2 is represented in binary as 10. It must be the case that, in binary addition, we have the sum as 1 + 1 = 10 This reads as the addition 1 + 1 results in a sum of 0 and a carry out of 1. Recall the decimal sum 25 + 25. 1 2 5 2 5 5 0 The 1 written above the numbers in the ten s column shows the carry out from the unit s column as a carry in to the ten s column. Page 4 of 32 September 6, 2012

The Half Adder The half adder takes two single bit binary numbers and produces a sum and a carry out, called carry. Here is the truth table description of a half adder. We denote the sum A + B. A B Sum Carry 0 0 0 0 0 1 1 0 1 0 1 0 1 1 0 1 Written as a standard sum, the last row represents the following: 01 + 01 10 The sum column indicates the number to be written in the unit s column, immediately below the two 1 s. We write a 0 and carry a 1. Page 5 of 32 September 6, 2012

The Half Adder and the Full Adder In all versions of arithmetic, including binary and decimal, the half adder represents what we do for the unit s column when we add integers. There is no possibility of a carry in for the unit s column, so we do not design for such. Another way is to say that there is a carry in; it is always 0. The full adder in decimal arithmetic would be used for the other columns: the ten s column, the hundred s column, and so on. For these columns, a non zero carry in is a distinct possibility Considered this way, we might write our sums table as follows. 2 + 2 = 4, if the carry in is 0, and 2 + 2 = 5, when the carry in is 1. Admittedly, the complexities of decimal arithmetic suggest another way, just add the values as three numbers, here 2 + 2 + 1 = 5. Page 6 of 32 September 6, 2012

Implementing the Half Adder Here again is the truth table for the half adder. A B Sum Carry 0 0 0 0 0 1 1 0 1 0 1 0 1 1 0 1 We need equations for each of the Sum and Carry. Because we have used a truth table to specify these functions, we consider Boolean expressions. Note that the carry is the logical AND of the two inputs: Carry = A B. The sum can be given in two equivalent expressions. The simplest expression uses the exclusive OR function: Sum = A B. An equivalent expression in terms of the basic AND, OR, and NOT is: Page 7 of 32 September 6, 2012

Circuits for the Half Adder Here are two slightly different circuit implementations of the half adder. The circuit on the left implements the sum function as Sum = A B. The circuit on the right implements the sum function as Page 8 of 32 September 6, 2012

Implementing the Full Adder Here we show the truth table for the sum of A and B, with carry in of C. A B C Sum Carry 0 0 0 0 0 0 0 1 1 0 0 1 0 1 0 0 1 1 0 1 1 0 0 1 0 1 0 1 0 1 1 1 0 0 1 1 1 1 1 1 To read this as decimal, pretend that the Sum is Sum_Bit and read as the Decimal_Sum = Carry 2 + Sum_Bit. So 1 + 1 + 0 = 1 2 + 0 = 2 (decimal), and 1 + 1 + 1 = 1 2 + 1 = 3 (decimal). Page 9 of 32 September 6, 2012

One Circuit for the Full Adder Here is the traditional AND/OR implementation of the full adder. Page 10 of 32 September 6, 2012

Another Circuit for the Full Adder The slide above gave the standard design of a full adder with a grouping of AND gates followed by an OR gate. Here is another implementation of the SUM function using exclusive OR. A B C (A B) (A B) C 0 0 0 0 0 0 0 1 0 1 0 1 0 1 1 0 1 1 1 0 1 0 0 1 1 1 0 1 1 0 1 1 0 0 0 1 1 1 0 1 Page 11 of 32 September 6, 2012

The Full Adder with C = 0 The circuit above implements the following two expressions, where C is the carry in to the full adder. Sum = A B C + A B C + A B C + A B C Carry = A B + A C + B C Suppose we let the carry in C = 0. Then C = 1. What we have then is as follows. Sum Carry = A B 0 + A B 1 + A B 1 + A B 0 = A B + A B = A B + A 0 + B 0 = A B As expected, a full adder with carry in set to zero acts like a half adder. Page 12 of 32 September 6, 2012

The Full Adder and Half Adder as Circuit Elements When we build circuits with full adders or half adders, it is important to focus on the functionality and not on the implementation details. For this reason, we denote each circuit as a simple box with inputs and outputs. The figure on the left depicts a full adder with carry in as an input. The figure on the right depicts a half adder with no carry in as input. The figure in the middle depicts a full adder acting as a half adder. Page 13 of 32 September 6, 2012

A Four Bit Full Adder Here is a depiction of a four bit full adder to add two binary numbers, depicted as A 3 A 2 A 1 A 0 and B 3 B 2 B 1 B 0. Note that the carry out from the unit s stage is carried into the two s stage. In general, the carry is propagated from right to left, in the same manner as we see in manual decimal addition. This is called a ripple carry adder. Here is an example of its output. The 4 bit sum is truncated to 1001. 1110 + 1011 11001 Note that the unit s adder is implemented using a full adder. Page 14 of 32 September 6, 2012

Propagating the Carry Bits Just as in standard arithmetic, when done by hand, the carry of one stage is propagated as a carry in to the next higher stage. Page 15 of 32 September 6, 2012

Addition and Subtraction In order to convert a ripple carry adder into a subtractor, we employ the standard algebra trick: A B is the same as A + ( B). In order to subtract B from A, it is necessary to negate B to produce B, and then to add that number to A. We now have to develop a circuit that will negate a binary value. In order to do this, we must stipulate the method used to represent signed integers. As in earlier lecture, we use two s complement notation. In this method, in order to negate a binary integer, it is necessary to produce the two s complement of that value. 1. First, take the one s complement of the binary integer, and then 2. Add 1 to that value. We have to develop a circuit to create the one s complement of a binary integer. We shall develop two circuits to do this. Page 16 of 32 September 6, 2012

The One s Complement of a Binary Integer In order to take the one s complement of an integer in binary form, just change every 0 to a 1, and every 1 to a 0. Here are some examples. Original value 0110 0111 1010 0011 One s complement 1001 1000 0101 1100 The circuit that does this conversion is the NOT gate. The circuit below would be used for four bit integers. If the input is B 3 B 2 B 1 B 0 = 0110, the output is Y 3 Y 2 Y 1 Y 0 = 1001. This circuit can be extended to any number of bits required. Page 17 of 32 September 6, 2012

The XOR Gate as a NOT Gate In order to make an adder/subtractor, it is necessary to use a gate that can either pass the value through or generate its one s complement. The exclusive OR gate, XOR, is exactly what we need. This is controlled by a single binary signal: Neg. Let B = 1011. If Neg = 0, then Y = 1011. If Neg = 1, then Y = 0100. Page 18 of 32 September 6, 2012

Some Notation for Bit Wise Operations Taking the one s complement of a binary integer involves taking the one s complement of each of its bits. We use the NOT notation to denote the one s complement of the entire integer. If B = B 3 B 2 B 1 B 0 is a four bit binary number, its one s complement is. Remember that to get the two s complement, one takes the one s complement and adds one. In two s complement arithmetic we have:. This suggests the use of an adder to produce the negative. For B = B 3 B 2 B 1 B 0, we take the one s complement to start the negation process. The addition of 1, necessary to take the two s complement, is achieved by setting the carry in of the unit s full adder to 1. This is the reason for using a full adder in the unit s position. We can alternate between an adder and subtractor. More on this a bit later. Page 19 of 32 September 6, 2012

The Negator Circuit Here is the circuit to produce the negative of a 4 bit number B = B 3 B 2 B 1 B 0. If Neg = 0, then the XOR gates pass the values B 3 B 2 B 1 B 0 unchanged and the ripple carry adder adds 0 to that. The result is Y = B. If Neg = 1, then the XOR gates cause the one s complement of B = B 3 B 2 B 1 B 0 to be computed. Note that the carry in of the full adder is set to 1, so that it adds 1 to the one s complement, thus producing the negative: Y = B. Page 20 of 32 September 6, 2012

The Full Adder/Subtractor We now have the circuit that either adds or subtracts. This is a 4 bit circuit that produces either (A + B) or (A B). This notation is used for a two valued control signal. When the value is 0, the circuit is to add, when it is 1 the circuit is to subtract. This adder/subtractor can be extended to any number of binary bits. Page 21 of 32 September 6, 2012

Overflow: Busting the Arithmetic The range of 16 bit two s complement arithmetic is 32,768 to 32,767 Consider the following addition problem: 24576 + 24576. Now + 24,576 (binary 0110 0000 0000 0000) is well within the range. 0110 0000 0000 0000 24576 0110 0000 0000 0000 24576 1100 0000 0000 0000 16384 What happened? We had a carry into the sign bit. This is overflow. The binary representation being used cannot handle the result. NOTE: This works as unsigned arithmetic. 24,576 + 24,576 = 49,152 = 32768 + 16384. Page 22 of 32 September 6, 2012

Detecting Overflow For addition, overflow occurs in only two situations: 1) Two positive integers are added and the result is negative. 2) Two negative integers are added and the result is positive. Consider the 16 bit examples shown above. Remember that the bits are numbered left to right as 15 down to 0, with bit 15 being the sign bit for signed representations. Look at the full adder responsible for adding the sign bit for two integers: A and B. The overflow condition is now: A 15 == 0, B 15 == 0, and S 15 ==1, or A 15 == 1, B 15 == 1, and S 15 ==0. Page 23 of 32 September 6, 2012

Implementing the Detector Here we show the truth table for the sign bit. A 15 B 15 C 15 S 15 C 16 0 0 0 0 0 0 0 1 1 0 0 1 0 1 0 0 1 1 0 1 1 0 0 1 0 1 0 1 0 1 1 1 0 0 1 1 1 1 1 1 Rows 1 and 6 are the only two rows in which overflow occurs. These two rows share one interesting property: C 15 C 16, or C 15 C 16 = 1. The use of this property allows overflow to be detected efficiently. Page 24 of 32 September 6, 2012

Gate Delays Consider three gates, each of which has input that has not changed for some time. The output of each gate correctly implements its Boolean function. We now consider what happens as the input to each gate is changed suddenly. Note that the output does not change at the same time as the input. For a short time, called a hazard, the output of the gate is not that of the Boolean function supposedly implemented. Page 25 of 32 September 6, 2012

Gate Delays (More) For the time duration of one gate delay, the outputs do not match the inputs. After one gate delay (about 2 to 10 nanoseconds) the output is correct. Page 26 of 32 September 6, 2012

Full Adder with Gate Delays (Before Input Changes) Assume the inputs have been stable for some time. Page 27 of 32 September 6, 2012

Full Adder with Gate Delays (Input Changes at T = 0) At this point, no outputs are correct. Page 28 of 32 September 6, 2012

Full Adder with Gate Delays (T = 1) Some output is correct, but the upper AND gates are reacting to input at T = 0. Page 29 of 32 September 6, 2012

Full Adder with Gate Delays (T = 2) The carry out is correct, but the sum out is reacting to input at T = 1. Page 30 of 32 September 6, 2012

Full Adder with Gate Delays (T = 3) At T = 3 (and later), all output is correct. Page 31 of 32 September 6, 2012

The Ripple Carry Adder Carry in to stage K (bit K) is valid at T = 2 K. Carry out from stage K is valid at T = 2 K + 2. Sum from stage K is valid at T = 2 K + 3. 32 bit sum valid after stage 31 finishes (65 gate delays) This circuit is not used in commercial computers. Page 32 of 32 September 6, 2012