Chapter 4 Arithmetic

Similar documents
Chapter 3: part 3 Binary Subtraction

Chapter 4 Arithmetic Functions

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

Basic Arithmetic (adding and subtracting)

Computer Architecture and Organization: L04: Micro-operations

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

Binary Adders: Half Adders and Full Adders

Register Transfer Language and Microoperations (Part 2)

ECE/Comp Sci 352 Digital Systems Fundamentals. Charles R. Kime Section 2 Fall Logic and Computer Design Fundamentals

Principles of Computer Architecture. Chapter 3: Arithmetic

Chapter 4. Combinational Logic

Chapter 3 Part 2 Combinational Logic Design

Semester Transition Point. EE 109 Unit 11 Binary Arithmetic. Binary Arithmetic ARITHMETIC

Experiment 7 Arithmetic Circuits Design and Implementation

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

DIGITAL ARITHMETIC: OPERATIONS AND CIRCUITS

CO Computer Architecture and Programming Languages CAPL. Lecture 9

Combinational Circuits

EE 109 Unit 6 Binary Arithmetic

REGISTER TRANSFER LANGUAGE

Chapter 1. Digital Systems and Binary Numbers

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

Number System. Introduction. Decimal Numbers

World Inside a Computer is Binary

Chap.3 3. Chap reduces the complexity required to represent the schematic diagram of a circuit Library

Real Digital Problem Set #6

ECE468 Computer Organization & Architecture. The Design Process & ALU Design

Computer Architecture and Organization

Binary Arithmetic. Daniel Sanchez Computer Science & Artificial Intelligence Lab M.I.T.

60-265: Winter ANSWERS Exercise 4 Combinational Circuit Design

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

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

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

Arithmetic Circuits. Nurul Hazlina Adder 2. Multiplier 3. Arithmetic Logic Unit (ALU) 4. HDL for Arithmetic Circuit

UNIT-III REGISTER TRANSFER LANGUAGE AND DESIGN OF CONTROL UNIT

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

Advanced Computer Architecture-CS501

ECE 274 Digital Logic. Digital Design. Datapath Components Subtractors, Two s Complement, Overflow, ALUs, Register Files Digital Design

LAB #1 BASIC DIGITAL CIRCUIT

Arithmetic Logic Unit. Digital Computer Design

Chapter 10 - Computer Arithmetic

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

Arithmetic Operations on Binary Numbers

Combinational Logic II

ECE 341 Midterm Exam

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

ELEC 326: Class project

Lecture (02) Operations on numbering systems

END-TERM EXAMINATION

BUILDING BLOCKS OF A BASIC MICROPROCESSOR. Part 1 PowerPoint Format of Lecture 3 of Book

Arithmetic Circuits. Design of Digital Circuits 2014 Srdjan Capkun Frank K. Gürkaynak.

REGISTER TRANSFER AND MICROOPERATIONS

QUESTION BANK FOR TEST

Arithmetic-logic units

ECE 30 Introduction to Computer Engineering

Chapter 3 Part 2 Combinational Logic Design

EC2303-COMPUTER ARCHITECTURE AND ORGANIZATION

UNIT IV: DATA PATH DESIGN

II/IV B.Tech (Regular/Supplementary) DEGREE EXAMINATION. Answer ONE question from each unit.

EE292: Fundamentals of ECE

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

(+A) + ( B) + (A B) (B A) + (A B) ( A) + (+ B) (A B) + (B A) + (A B) (+ A) (+ B) + (A - B) (B A) + (A B) ( A) ( B) (A B) + (B A) + (A B)

Let s put together a Manual Processor

Arithmetic and Logical Operations

1. Mark the correct statement(s)

To design a 4-bit ALU To experimentally check the operation of the ALU

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

CARLETON UNIVERSITY. Laboratory 2.0

Combinational Logic. Prof. Wangrok Oh. Dept. of Information Communications Eng. Chungnam National University. Prof. Wangrok Oh(CNU) 1 / 93

CO212 Lecture 10: Arithmetic & Logical Unit

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

Representation of Non Negative Integers

Chapter 1 Review of Number Systems

CSE303 Logic Design II Laboratory 01

Decimal & Binary Representation Systems. Decimal & Binary Representation Systems

EE 8351 Digital Logic Circuits Ms.J.Jayaudhaya, ASP/EEE

Review. Steps to writing (stateless) circuits: Create a logic function (one per output)

Chapter 5 Design and Implementation of a Unified BCD/Binary Adder/Subtractor

COMPUTER ARCHITECTURE AND ORGANIZATION Register Transfer and Micro-operations 1. Introduction A digital system is an interconnection of digital

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

Introduction to Boole algebra. Binary algebra

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

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

REGISTER TRANSFER AND MICROOPERATIONS

COMPUTER ARITHMETIC (Part 1)

6.004 Computation Structures Spring 2009

Chapter 10 Binary Arithmetics

CS 64 Week 1 Lecture 1. Kyle Dewey

COMP 122/L Lecture 2. Kyle Dewey

Henry Lin, Department of Electrical and Computer Engineering, California State University, Bakersfield Lecture 7 (Digital Logic) July 24 th, 2012

LECTURE 4. Logic Design

CSE140 L. Instructor: Thomas Y. P. Lee January 18,2006. CSE140L Course Info

CHAPTER 6 ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS

MGU-BCA-205- Second Sem- Core VI- Fundamentals of Digital Systems- MCQ s. 2. Why the decimal number system is also called as positional number system?

CPE300: Digital System Architecture and Design

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

Code No: R Set No. 1

Register Transfer and Micro-operations

Injntu.com Injntu.com Injntu.com R16

Computer Organization

Transcription:

Computer Eng 1 (ECE290) Chapter 4 Arithmetic Functions and Circuits HOANG Trang Reference: 2008 Pearson Education, Inc. Lecture note of Prof.Donna J.Brown

Overview Binary adders Half and full adders Ripple carry and carry lookahead adders Binary subtraction Binary adder-subtractors Signed binary numbers Signed binary addition and subtraction ti Overflow HOANG Trang Reference: Lecture note of Prof.D.J.Brown & Chapter 4 2

Half-Adder 0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 Simple Binary Addition Zero plus zero equals zero Zero plus one equals one One plus zero equals one 1+1=10 1 10 One plus one equals zero with a carry of one HOANG Trang Reference: Lecture note of Prof.D.J.Brown & Chapter 4 3

Half-Adder HOANG Trang Reference: Lecture note of Prof.D.J.Brown & Chapter 4 4

Five Implementations: Half-Adder We can derive following sets of equations for a half- adder: (a) S X Y X Y C X Y (b) S (X Y) (X Y) C X Y (c) S ( C X Y ) C X Y (d) S (X Y) C C (X Y) (e) S X Y C X Y (a), (b), and (e) are SOP, POS, and XOR implementations i for S. In (c), the C function is used as a term in the AND- NOR implementation of S, and in (d), the C function is used in a POS term for S. HOANG Trang Reference: Lecture note of Prof.D.J.Brown & Chapter 4 5

Implementations: Half-Adder The most common half adder implementation is: X (e) Y S S X Y C X Y C A NAND only implementation is: S (X Y) C C ( ( X Y) ))) X C S CMOS Y HOANG Trang Reference: Lecture note of Prof.D.J.Brown & Chapter 4 6

NAND gate: behaviorial, transistor, layout O <= NOT ( A1 AND B1); Boolean Equation Transistor Mask HOANG Trang Reference: Lecture note of Prof.D.J.Brown & Chapter 4 7

Full-Adder HOANG Trang Reference: Lecture note of Prof.D.J.Brown & Chapter 4 8

Full-Adder Full adder from two half-adder adder circuits HOANG Trang Reference: Lecture note of Prof.D.J.Brown & Chapter 4 9

Adder: behavior, netlist, transistor, layout Behavioral model Structural model 28 transitors for 1 Full Adder HOANG Trang Reference: Lecture note of Prof.D.J.Brown & Chapter 4 10

Parallel Binary Adders Two-bit parallel binary adder HOANG Trang Reference: Lecture note of Prof.D.J.Brown & Chapter 4 11

Parallel Binary Adders Four-bit parallel binary adder iteractive HOANG Trang Reference: Lecture note of Prof.D.J.Brown & Chapter 4 12

4-bit Ripple-Carry Binary Adder A four-bit Ripple Carry Adder made from four 1-bit Full Adders: B 3 A 3 B 2 A 2 B 1 A 1 B 0 A 0 FA C 3 C 2 C 1 FA FA FA C 0 C 4 S 3 S 2 S 1 S 0 HOANG Trang Reference: Lecture note of Prof.D.J.Brown & Chapter 4 13

Unsigned Subtraction Algorithm: M (minuend) N (subtrahend) (n-bit number) M N: no end borrow, and the result is a nonnegative number and correct. N > M: end borrow occurs and the difference M N + 2 n and a minus sign is appended to the result. 0 1 1001 0100 0111 0111 0010 1101 10000 1101 ( ) 0011 Examples: HOANG Trang Reference: Lecture note of Prof.D.J.Brown & Chapter 4 14

Unsigned Subtraction (continued) The subtraction (2 n N): is the 2 s complement of fn To do both unsigned addition and unsigned A subtraction requires: Quite complex! Goal: Shared simpler logic for both addition and subtraction => Introduce complements as an approach Binary adder Subtract/Add Borrow Complement 0 1 S Quadruple 2-to-1 multiplexer B Binary subtractor Selective 2's complementer HOANG Trang Reference: Lecture note of Prof.D.J.Brown & Chapter 4 15 Result

Sign-magnitude representation Leftmost bit is sign bit: 0 positive 1 negative Ex: 6-bit representation (n=6) Example: +13: 001101-13: 101101 Disadvantages of sign-magnitude: 1. Hard to do arithmetic (addition is hard) 2. Two representation of 0: +0 and -0 Largest number: 011111 (+31) (2 n -1) Smallest number: 111111 (-31) -(2 n -1) HOANG Trang Reference: Lecture note of Prof.D.J.Brown & Chapter 4 16

4-bit sign-magnitude representation HOANG Trang Reference: Lecture note of Prof.D.J.Brown & Chapter 4 17

4-bit 2 s complement representation HOANG Trang Reference: Lecture note of Prof.D.J.Brown & Chapter 4 18

4-bit representation Problem: 0: 2 representations NICE HOANG Trang Reference: Lecture note of Prof.D.J.Brown & Chapter 4 19

3-bit representation n=3 Number Sign -Mag. 1's Comp. 2's Comp. +3 011 011 011 +2 010 010 010 +1 001 001 001 +0 000 000 000 0 100 111 1 101 110 111 2 110 101 110 3 111 100 101 4 100 HOANG Trang Reference: Lecture note of Prof.D.J.Brown & Chapter 4 20

2 s Complement Representation: X-> -X? Given: an n-bit number X in 2 s complement form Goal: Representation X in 2 s complement form? Example: n=5; X=01101 (2 s complement form) Method 1: take the 1 s complement of X and ADD 1 X= 01101 +13 10010 + 1 10011-13 HOANG Trang Reference: Lecture note of Prof.D.J.Brown & Chapter 4 21

2 s Complement Representation: X-> -X? Method 2: compute: 2 n -X 100000-01101 10011-13 +13 Method 3: complement all bits to the left of the least significant ifi t1(l (leaving other bits unchanged) X=01101 (+13) => -X=10011 (-13) X=10100 (-12) => -X=01100 (+12) HOANG Trang Reference: Lecture note of Prof.D.J.Brown & Chapter 4 22

2 s Complement Representation: X-> -X? Method 4: The n-bit 2 s complement representation is i ht d d ith l ft tbit f i ht 2 n-1 a weighted code with leftmost bit of weight - 2 X=1010 => X=-8+2=-6 HOANG Trang Reference: Lecture note of Prof.D.J.Brown & Chapter 4 23

2 s Complement Addition/Subtraction Given numbers X and Y in 2 s complement form 1. To ADD : Y+X: do ordinary binary 2. To SUBSTRACT: Y-X: compute (-X) and ADD Y+ (-X) 10110 (-10) - 10011 (-13) 10110 +01101 100011 (3) HOANG Trang Reference: Lecture note of Prof.D.J.Brown & Chapter 4 24

2 s Complement Adder/Subtractor How to design? + before we design, the Adder/Subtractor -> check that: we can design each seperately Design Adder: How to design? Design Substractor Answer: black box: would be like a nice girl. Oh, NO! HOANG Trang Reference: Lecture note of Prof.D.J.Brown & Chapter 4 25

2 s Complement Adder/Subtractor Subtraction can be done by addition of the 2's Complement. 1. Complement each bit (1's Complement.) 2. Add 1 to the result. For k = 1, subtract, the 2 s complement of B is formed by using XORs to form the 1 s comp and adding the 1 applied to C 0. For k = 0, add, B is passed through unchanged C 4 B 3 A 3 B 2 A 2 B 1 A 1 B 0 A 0 C 3 C 2 C 1 C 0 FA FA FA FA S 3 S 2 S 1 S 0 k HOANG Trang Reference: Lecture note of Prof.D.J.Brown & Chapter 4 26

Overflow Detection Overflow occurs if n + 1 bits are required to contain the result from an n-bit addition or subtraction n=5 bit: -16 -> 15 HOANG Trang Reference: Lecture note of Prof.D.J.Brown & Chapter 4 27

Overflow Detection: when it occurs? Intuition (clearly) that: Overflow can occur for: Addition of two operands with the same sign Add 2 positive and get a negative Add 2 negative and get a positive Subtraction of operands with different signs Ideal: simple implementation C n XOR C n-1 = 1 HOANG Trang Reference: Lecture note of Prof.D.J.Brown & Chapter 4 28

Overflow Detection: when it occurs? Consider all possibility overflow C n XOR C n-1 HOANG Trang Reference: Lecture note of Prof.D.J.Brown & Chapter 4 29

Overflow Detection: when it occurs? HOANG Trang Reference: Lecture note of Prof.D.J.Brown & Chapter 4 30

An Arithmetic Unit (AU) HOANG Trang Reference: Lecture note of Prof.D.J.Brown & Chapter 4 31

A Logic Unit (LU) HOANG Trang Reference: Lecture note of Prof.D.J.Brown & Chapter 4 32

An Arithmetic/Logic Unit (ALU) (very popular in micro-controller, computer, processor) HOANG Trang Reference: Lecture note of Prof.D.J.Brown & Chapter 4 33