Lecture 9 Sept 28 Chapter 3 Arithmetic for Computers.

Slides:



Advertisements
Similar presentations
Morgan Kaufmann Publishers Arithmetic for Computers
Advertisements

Chapter 3 Arithmetic for Computers. Chapter 3 — Arithmetic for Computers — 2 Arithmetic for Computers Operations on integers Addition and subtraction.
CS/ECE 3330 Computer Architecture Chapter 3 Arithmetic.
Chapter 3 Arithmetic for Computers. Exam 1 CSCE
Lecture 15: Computer Arithmetic Today’s topic –Division 1.
CMPT 334 Computer Organization Chapter 3 Arithmetic for Computers [Adapted from Computer Organization and Design 5 th Edition, Patterson & Hennessy, ©
Lecture Objectives: 1)Perform binary division of two numbers. 2)Define dividend, divisor, quotient, and remainder. 3)Explain how division is accomplished.
Chapter 3 Arithmetic for Computers. Multiplication More complicated than addition accomplished via shifting and addition More time and more area Let's.
361 div.1 Computer Architecture ECE 361 Lecture 7: ALU Design : Division.
Chapter 3 Arithmetic for Computers. Chapter 3 — Arithmetic for Computers — 2 Arithmetic for Computers Operations on integers Addition and subtraction.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 4: Arithmetic / Data Transfer Instructions Partially adapted from Computer Organization.
Integer Multiplication and Division ICS 233 Computer Architecture and Assembly Language Dr. Aiman El-Maleh College of Computer Sciences and Engineering.
1 Lecture 8: Binary Multiplication & Division Today’s topics:  Addition/Subtraction  Multiplication  Division Reminder: get started early on assignment.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 6: Logic/Shift Instructions Partially adapted from Computer Organization and Design, 4.
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Hao Ji.
ALU Architecture and ISA Extensions Lecture notes from MKP, H. H. Lee and S. Yalamanchili.
Lecture Objectives: 1)Explain the relationship between addition and subtraction with twos complement numbering systems 2)Explain the concept of numeric.
Lecture 12: Computer Arithmetic Today’s topic –Numerical representations –Addition / Subtraction –Multiplication / Division 1.
Chapter 3 -Arithmetic for Computers Operations on integers – Addition and subtraction – Multiplication and division – Dealing with overflow Floating-point.
Lecture 7: Multiplication and Floating Point EEN 312: Processors: Hardware, Software, and Interfacing Department of Electrical and Computer Engineering.
Lec 13Systems Architecture1 Systems Architecture Lecture 13: Integer Multiplication and Division Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan.
July 2005Computer Architecture, The Arithmetic/Logic UnitSlide 1 Part III The Arithmetic/Logic Unit.
Chapter 3 Arithmetic for Computers. Chapter 3 — Arithmetic for Computers — 2 Arithmetic for Computers Operations on integers Addition and subtraction.
CSF 2009 Arithmetic for Computers Chapter 3. Arithmetic for Computers Operations on integers Addition and subtraction Multiplication and division Dealing.
1 CPSC3850 Adders and Simple ALUs Simple Adders Figures 10.1/10.2 Binary half-adder (HA) and full-adder (FA). Digit-set interpretation: {0, 1}
July 2005Computer Architecture, The Arithmetic/Logic UnitSlide 1 Part III The Arithmetic/Logic Unit.
Computer Architecture, The Arithmetic/Logic UnitSlide 1 Part III The Arithmetic/Logic Unit.
Chapter 3 Arithmetic for Computers (Integers). Florida A & M University - Department of Computer and Information Sciences Arithmetic for Computers Operations.
Chapter 3 Arithmetic for Computers. Chapter 3 — Arithmetic for Computers — 2 Arithmetic for Computers Operations on integers Addition and subtraction.
Integer Multiplication and Division ICS 233 Computer Architecture and Assembly Language Dr. Aiman El-Maleh College of Computer Sciences and Engineering.
Csci 136 Computer Architecture II – Multiplication and Division
Chapter 3 Arithmetic for Computers. Chapter 3 — Arithmetic for Computers — 2 Arithmetic for Computers Operations on integers Addition and subtraction.
EI 209 Chapter 3.1CSE, 2015 EI 209 Computer Organization Fall 2015 Chapter 3: Arithmetic for Computers Haojin Zhu ( )
C OMPUTER O RGANIZATION AND D ESIGN The Hardware/Software Interface 5 th Edition Chapter 3 Arithmetic for Computers.
Chapter 3 Arithmetic for Computers. Chapter 3 — Arithmetic for Computers — 2 Arithmetic for Computers Operations on integers Addition and subtraction.
Division Check for 0 divisor Long division approach – If divisor ≤ dividend bits 1 bit in quotient, subtract – Otherwise 0 bit in quotient, bring down.
CDA 3101 Spring 2016 Introduction to Computer Organization
Integer Multiplication, Division Arithmetic shift Twice the number of places MIPS multiply unit. mult, multu Significant bits Mfhi, mflo, div, divu Arithmetic.
Morgan Kaufmann Publishers Arithmetic for Computers
Integer Multiplication and Division COE 301 Computer Organization Dr. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University.
By Wannarat Computer System Design Lecture 3 Wannarat Suntiamorntut.
Integer Multiplication and Division ICS 233 Computer Architecture & Assembly Language Prof. Muhamed Mudawar College of Computer Sciences and Engineering.
Chapter 3 — Arithmetic for Computers — 1 Arithmetic for Computers Operations on integers Addition and subtraction Multiplication and division Dealing with.
Arithmetic for Computers Chapter 3 1. Arithmetic for Computers  Operations on integers  Addition and subtraction  Multiplication and division  Dealing.
Computer System Design Lecture 3
More Binary Arithmetic - Multiplication
Morgan Kaufmann Publishers Arithmetic for Computers
Computer Architecture & Operations I
ALU Architecture and ISA Extensions
Integer Multiplication, Division Arithmetic shift
Computer Architecture & Operations I
Morgan Kaufmann Publishers Arithmetic for Computers
Integer Multiplication and Division
Morgan Kaufmann Publishers Arithmetic for Computers
CS 314 Computer Organization Fall Chapter 3: Arithmetic for Computers
Morgan Kaufmann Publishers Arithmetic for Computers
Morgan Kaufmann Publishers
/ Computer Architecture and Design
Morgan Kaufmann Publishers
Ch 3: Computer Arithmetic
Lecture 8: Binary Multiplication & Division
CDA 3101 Summer 2007 Introduction to Computer Organization
CS352H: Computer Systems Architecture
Lecture 8: Addition, Multiplication & Division
Lecture 8: Addition, Multiplication & Division
Computer Architecture Computer Science & Engineering
Morgan Kaufmann Publishers Arithmetic for Computers
Number Representation
Presentation transcript:

Lecture 9 Sept 28 Chapter 3 Arithmetic for Computers

Operations on integers Addition and subtraction Multiplication and division Dealing with overflow Floating-point real numbers Representation and operations §3.1 Introduction

Integer Addition Example: §3.2 Addition and Subtraction Overflow if result out of range Adding +ve and –ve operands, no overflow Adding two +ve operands Overflow if result sign is 1 Adding two –ve operands Overflow if result sign is 0

Integer Subtraction Add negation of second operand Example: 7 – 6 = 7 + (–6) +7: … –6: … : … Overflow if result out of range Subtracting two +ve or two –ve operands, no overflow Subtracting +ve from –ve operand Overflow if result sign is 0 Subtracting –ve from +ve operand Overflow if result sign is 1

Dealing with Overflow Some languages (e.g., C) ignore overflow Use MIPS addu, addui, subu instructions Other languages (e.g., Ada, Fortran) require raising an exception Use MIPS add, addi, sub instructions On overflow, invoke exception handler Save PC in exception program counter (EPC) register Jump to predefined handler address mfc0 (move from coprocessor reg) instruction can retrieve EPC value, to return after corrective action

Two’s-Complement Addition and Subtraction Binary adder used as 2’s-complement adder/subtractor.

Simple Adders Binary half-adder (HA) and full-adder (FA). Digit-set interpretation: {0, 1} + {0, 1} = {0, 2} + {0, 1} Digit-set interpretation: {0, 1} + {0, 1} + {0, 1} = {0, 2} + {0, 1}

Full-Adder Implementations Full adder implemented with two half-adders, by means of two 4- input multiplexers, and as two-level gate network.

Ripple-Carry Adder: Slow But Simple Ripple-carry binary adder with 32-bit inputs and output. Critical path

Carry Propagation Networks The main part of an adder is the carry network. The rest is just a set of gates to produce the g and p signals and the sum bits. g i = x i y i p i = x i  y i

Carry-Lookahead Logic with 4-Bit Block Blocks needed in the design of carry-lookahead adders with four-way grouping of bits.

Another Speed-Up Method: Carry Select Carry-select addition circuit Allows doubling of adder width with a single-mux additional delay

Arithmetic for Multimedia Graphics and media processing operates on vectors of 8-bit and 16-bit data Use 64-bit adder, with partitioned carry chain Operate on 8×8-bit, 4×16-bit, or 2×32-bit vectors SIMD (single-instruction, multiple-data) Saturating operations On overflow, result is largest representable value c.f. 2’s-complement modulo arithmetic E.g., clipping in audio, saturation in video

Shift-Add Multiplication Multiplication of 4-bit numbers in dot notation z (j+1) = (z (j) + y j x 2 k ) 2 –1 with z (0) = 0 and z (k) = z |––– add –––| |–– shift right ––|

Multiplication Start with long-multiplication approach 1000 × Length of product is the sum of operand lengths multiplicand multiplier product §3.3 Multiplication

Multiplication Hardware Initially 0

Optimized Multiplier Perform steps in parallel: add/shift One cycle per partial-product addition That’s ok, if frequency of multiplications is low

Faster Multiplier Uses multiple adders Cost/performance tradeoff Can be pipelined Several multiplications performed in parallel

MIPS Multiplication Two 32-bit registers for product HI: most-significant 32 bits LO: least-significant 32-bits Instructions mult rs, rt / multu rs, rt 64-bit product in HI/LO mfhi rd / mflo rd Move from HI/LO to rd Can test HI value to see if product overflows 32 bits mul rd, rs, rt Least-significant 32 bits of product –> rd

Division Check for 0 divisor Long division approach If divisor ≤ dividend bits 1 bit in quotient, subtract Otherwise 0 bit in quotient, bring down next dividend bit Restoring division Do the subtract, and if remainder goes < 0, add divisor back Signed division Divide using absolute values Adjust sign of quotient and remainder as required n-bit operands yield n-bit quotient and remainder quotient dividend remainde r divisor

Division Hardware Initially dividend Initially divisor in left half

Optimized Divider One cycle per partial-remainder subtraction Looks a lot like a multiplier! Same hardware can be used for both

MIPS Division Use HI/LO registers for result HI: 32-bit remainder LO: 32-bit quotient Instructions div rs, rt / divu rs, rt No overflow or divide-by-0 checking Software must perform checks if required Use mfhi, mflo to access result

Binary and Decimal Multiplication Step-by-step multiplication examples for 4-digit unsigned numbers. Position Position ========================= x x y y ========================= z (0) y 0 x y 0 x –––––––––––––––––––––––––– 2z (1) z (1) z (1) z (1) y 1 x y 1 x –––––––––––––––––––––––––– 2z (2) z (2) z (2) z (2) y 2 x y 2 x –––––––––––––––––––––––––– 2z (3) z (3) z (3) z (3) y 3 x y 3 x –––––––––––––––––––––––––– 2z (4) z (4) z (4) z (4) =========================