Morgan Kaufmann Publishers Arithmetic for Computers

Slides:



Advertisements
Similar presentations
A Simple ALU Binary Logic.
Advertisements

B261 Systems Architecture
SE 292 (3:0) High Performance Computing L2: Basic Computer Organization R. Govindarajan
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
CMPT 334 Computer Organization Chapter 3 Arithmetic for Computers [Adapted from Computer Organization and Design 5 th Edition, Patterson & Hennessy, ©
Chapter 3 Arithmetic for Computers. Multiplication More complicated than addition accomplished via shifting and addition More time and more area Let's.
Lecture 9 Sept 28 Chapter 3 Arithmetic for Computers.
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.
1  1998 Morgan Kaufmann Publishers Chapter Four Arithmetic for Computers.
Chapter 3 Arithmetic for Computers. Arithmetic Where we've been: Abstractions: Instruction Set Architecture Assembly Language and Machine Language What's.
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.
Arithmetic for Computers
1 CS/COE0447 Computer Organization & Assembly Language Chapter 3.
Lec 13Systems Architecture1 Systems Architecture Lecture 13: Integer Multiplication and Division Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan.
07/19/2005 Arithmetic / Logic Unit – ALU Design Presentation F CSE : Introduction to Computer Architecture Slides by Gojko Babić.
1 EGRE 426 Fall 08 Chapter Three. 2 Arithmetic What's up ahead: –Implementing the Architecture 32 operation result a b ALU.
1  1998 Morgan Kaufmann Publishers Arithmetic Where we've been: –Performance (seconds, cycles, instructions) –Abstractions: Instruction Set Architecture.
CSF 2009 Arithmetic for Computers Chapter 3. Arithmetic for Computers Operations on integers Addition and subtraction Multiplication and division Dealing.
CSE378 Instr. encoding.1 Instruction encoding The ISA defines –The format of an instruction (syntax) –The meaning of the instruction (semantics) Format.
Chapter 3 Arithmetic for Computers (Integers). Florida A & M University - Department of Computer and Information Sciences Arithmetic for Computers Operations.
Chapter 10 The Assembly Process. What Assemblers Do Translates assembly language into machine code. Assigns addresses to all symbolic labels (variables.
Integer Multiplication and Division ICS 233 Computer Architecture and Assembly Language Dr. Aiman El-Maleh College of Computer Sciences and Engineering.
MIPS ALU. Building from the adder to ALU ALU – Arithmetic Logic Unit, does the major calculations in the computer, including – Add – And – Or – Sub –
Chapter 3 Arithmetic for Computers. Chapter 3 — Arithmetic for Computers — 2 Arithmetic for Computers Operations on integers Addition and subtraction.
1 ELEN 033 Lecture 4 Chapter 4 of Text (COD2E) Chapters 3 and 4 of Goodman and Miller book.
EI 209 Chapter 3.1CSE, 2015 EI 209 Computer Organization Fall 2015 Chapter 3: Arithmetic for Computers Haojin Zhu ( )
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.
MIPS ALU. Exercise – Design a selector? I need a circuit that takes two input bits, a and b, and a selector bit s. The function is that if s=0, f=a. if.
Integer Multiplication and Division COE 301 Computer Organization Dr. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University.
9/23/2004Comp 120 Fall September Chapter 4 – Arithmetic and its implementation Assignments 5,6 and 7 posted to the class web page.
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.
Based on slides from D. Patterson and www-inst.eecs.berkeley.edu/~cs152/ COM 249 – Computer Organization and Assembly Language Chapter 3 Arithmetic For.
Arithmetic for Computers Chapter 3 1. Arithmetic for Computers  Operations on integers  Addition and subtraction  Multiplication and division  Dealing.
Computer System Design Lecture 3
ALU Architecture and ISA Extensions
Integer Multiplication, Division Arithmetic shift
CS 230: Computer Organization and Assembly Language
Computer Architecture & Operations I
Integer Multiplication and Division
Morgan Kaufmann Publishers Arithmetic for Computers
Morgan Kaufmann Publishers Arithmetic for Computers
Morgan Kaufmann Publishers
Morgan Kaufmann Publishers
Ch 3: Computer Arithmetic
CDA 3101 Summer 2007 Introduction to Computer Organization
CS352H: Computer Systems Architecture
Lecture 8: Addition, Multiplication & Division
Lecture 8: Addition, Multiplication & Division
Arithmetic Logical Unit
The University of Adelaide, School of Computer Science
Computer Arithmetic Multiplication, Floating Point
MIPS History MIPS is a computer family
CS/COE0447 Computer Organization & Assembly Language
CS/COE0447 Computer Organization & Assembly Language
MIPS History MIPS is a computer family
COMS 361 Computer Organization
A 1-Bit Arithmetic Logic Unit
Morgan Kaufmann Publishers Arithmetic for Computers
MIPS History MIPS is a computer family
COMS 361 Computer Organization
MIPS Arithmetic and Logic Instructions
MIPS Arithmetic and Logic Instructions
Presentation transcript:

Morgan Kaufmann Publishers Arithmetic for Computers April 1, 2017 CprE 381 Computer Organization and Assembly Level Programming, Fall 2013 Chapter 3 Arithmetic for Computers Zhao Zhang Iowa State University Revised from original slides provided by MKP Chapter 1 — Computer Abstractions and Technology

The University of Adelaide, School of Computer Science 1 April 2017 Announcements Midterm Exam 1 on Friday Oct. 3, 9:00-9:50am 12.5% weight of the overall grade No quizzes homework this week Midterm review 1 on Wednesday §2.8 Supporting Procedures in Computer Hardware Chapter 2 — Instructions: Language of the Computer — 2 Chapter 2 — Instructions: Language of the Computer

Review of Week 5 Bubble sort code FP instructions FP pat of the call convention ARM and x86 ISAs Chapter 1 — Computer Abstractions and Technology — 3

Exam 1 Open book, open notes, calculator are allowed E-book reader is allowed Must be put in airplane mode Coverage Chapter 1, Computer Abstraction and Technology Chapter 2, Instructions: Language of the Computer Some contents from Appendix B MIPS floating-point instructions Chapter 1 — Computer Abstractions and Technology — 4

Exam Question Types Short conceptual questions Calculation: speedup, power saving, CPI, etc. MIPS assembly programming Translate C statements to MIPS (arithmetic, load/store, branch and jump, others) Translate C functions to MIPS (call convention) Among others Suggestions: Review slides and textbook Review homework and quizzes Redo homework questions Chapter 1 — Computer Abstractions and Technology — 5

Arithmetic for Computers Morgan Kaufmann Publishers 1 April, 2017 Arithmetic for Computers §3.1 Introduction Operations on integers Addition and subtraction Multiplication and division Dealing with overflow Floating-point real numbers Representation and operations Chapter 3 — Arithmetic for Computers — 6 Chapter 3 — Arithmetic for Computers

Integer Addition 1-bit adder Inputs: A, B, C (carry input) Output Sum, Cout (carry output) Try drawing the truth table Performance: 3 gate delays 3 gate delays on Sum (three layers of gates) 2 gate delays on Cout Chapter 1 — Computer Abstractions and Technology — 7

Morgan Kaufmann Publishers 1 April, 2017 Integer Addition N-bit Adder example: 7 + 6 This is called ripple-carry adder 32-bit adder has 31×2+3 = 65 gate delays 31×2 for carry ripping, plus 3 for the last Sum Faster design: Carry look-ahead adder (CLA) §3.2 Addition and Subtraction Chapter 3 — Arithmetic for Computers — 8 Chapter 3 — Arithmetic for Computers

Addition Overflow 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 Chapter 1 — Computer Abstractions and Technology — 9

Morgan Kaufmann Publishers 1 April, 2017 Integer Subtraction Add negation of second operand Example: 7 – 6 = 7 + (–6) +7: 0000 0000 … 0000 0111 (+6: 0000 0000 … 0000 0110) –6: 1111 1111 … 1111 1010 +1: 0000 0000 … 0000 0001 An adder can do subtraction, with simple circuit extension Invert every bit of the 2nd operand Set the carry input bit to be 1 Chapter 3 — Arithmetic for Computers — 10 Chapter 3 — Arithmetic for Computers

Overflow in Subtraction 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 Chapter 1 — Computer Abstractions and Technology — 11

Morgan Kaufmann Publishers 1 April, 2017 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 Chapter 3 — Arithmetic for Computers — 12 Chapter 3 — Arithmetic for Computers

Arithmetic for Multimedia Morgan Kaufmann Publishers 1 April, 2017 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 Example: 200 + 300 = 255 for 8-bit addition c.f. 2s-complement modulo arithmetic E.g., clipping in audio, saturation in video Chapter 3 — Arithmetic for Computers — 13 Chapter 3 — Arithmetic for Computers

Morgan Kaufmann Publishers 1 April, 2017 Multiplication §3.3 Multiplication Start with long-multiplication approach multiplicand 1000 × 1001 00001000 00000000 01000000 01001000 multiplier product Length of product is the sum of operand lengths Chapter 3 — Arithmetic for Computers — 14 Chapter 3 — Arithmetic for Computers

Control-Test Unit Design Morgan Kaufmann Publishers 1 April, 2017 Control-Test Unit Design A state machine of N states Each state represents a step State 0 => 1 => 2 => … => N-1 Input m(0): Bit 0 of multiplier Outputs Shift-right control to the multiplier Shift-left control to the multiplicand ALU operation type (select addition) Product register write-enable: Enable if m(0) = ‘1’, disable if m(0) = ‘0” Chapter 3 — Arithmetic for Computers — 15 Chapter 3 — Arithmetic for Computers

Morgan Kaufmann Publishers 1 April, 2017 Optimized Multiplier Perform steps in parallel: add/shift Utilized the unused bits in product to save multiplier Same performance: N additions per multiplication Chapter 3 — Arithmetic for Computers — 16 Chapter 3 — Arithmetic for Computers

Morgan Kaufmann Publishers 1 April, 2017 Faster Multiplier Uses multiple adders Cost/performance tradeoff Use 32-bit adders instead of 64-bit ones Can be pipelined: Several multiplication performed in parallel Chapter 3 — Arithmetic for Computers — 17 Chapter 3 — Arithmetic for Computers

Morgan Kaufmann Publishers 1 April, 2017 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 Chapter 3 — Arithmetic for Computers — 18 Chapter 3 — Arithmetic for Computers