CDA 3101 Summer 2007 Introduction to Computer Organization

Slides:



Advertisements
Similar presentations
Chapter 3 Arithmetic for Computers. Exam 1 CSCE
Advertisements

Datorteknik IntegerMulDiv bild 1 MIPS mul/div instructions Multiply: mult $2,$3Hi, Lo = $2 x $3;64-bit signed product Multiply unsigned: multu$2,$3Hi,
CMPE 325 Computer Architecture II
Cosc 2150: Computer Organization Chapter 9, Part 2 Integer multiplication and division.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Lecture 8 - Multiplication.
Integer division Pencil and paper binary division (dividend)(divisor) 1000.
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.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3: IT Students.
CML CML CS 230: Computer Organization and Assembly Language Aviral Shrivastava Department of Computer Science and Engineering School of Computing and Informatics.
Integer Multiplication and DivisionICS 233 – KFUPM © Muhamed Mudawar slide 1 Multiplicand and HI are sign-extended  Sign is the sign of the result Signed.
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.
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.
Computer Organization Multiplication and Division Feb 2005 Reading: Portions of these slides are derived from: Textbook figures © 1998 Morgan Kaufmann.
Integer Multiplication and Division
1 Lecture 8: Binary Multiplication & Division Today’s topics:  Addition/Subtraction  Multiplication  Division Reminder: get started early on assignment.
1 Lecture 4: Arithmetic for Computers (Part 5) CS 447 Jason Bakos.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 6: Logic/Shift Instructions Partially adapted from Computer Organization and Design, 4.
Lecture Objectives: 1)Explain the relationship between addition and subtraction with twos complement numbering systems 2)Explain the concept of numeric.
1 Arithmetic and Logical Operations - Part II. Unsigned Numbers Addition in unsigned numbers is the same regardless of the base. Given a pair of bit sequences.
Lec 13Systems Architecture1 Systems Architecture Lecture 13: Integer Multiplication and Division Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan.
King Fahd University of Petroleum and Minerals King Fahd University of Petroleum and Minerals Computer Engineering Department Computer Engineering Department.
July 2005Computer Architecture, The Arithmetic/Logic UnitSlide 1 Part III The Arithmetic/Logic Unit.
Lecture 6: Multiply, Shift, and Divide
Chapter 3 Arithmetic for Computers (Integers). Florida A & M University - Department of Computer and Information Sciences Arithmetic for Computers Operations.
Conversion to Larger Number of Bits Ex: Immediate Field (signed 16 bit) to 32 bit Positive numbers have implied 0’s to the left. So, put 16 bit number.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
05/03/2009CA&O Lecture 8,9,10 By Engr. Umbreen sabir1 Computer Arithmetic Computer Engineering Department.
Integer Multiplication and Division
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
Mohamed Younis CMCS 411, Computer Architecture 1 CMSC Computer Architecture Lecture 11 Performing Division March 5,
EI 209 Chapter 3.1CSE, 2015 EI 209 Computer Organization Fall 2015 Chapter 3: Arithmetic for Computers Haojin Zhu ( )
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.
CMPUT Computer Organization and Architecture I1 CMPUT229 - Fall 2003 Topic6: Logic, Multiply and Divide Operations José Nelson Amaral.
Integer Multiplication and Division COE 301 Computer Organization Dr. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University.
Integer Operations Computer Organization and Assembly Language: Module 5.
Integer Multiplication and Division ICS 233 Computer Architecture & Assembly Language Prof. Muhamed Mudawar College of Computer Sciences and Engineering.
1 Lecture 5Multiplication and Division ECE 0142 Computer Organization.
More Binary Arithmetic - Multiplication
Computer Architecture & Operations I
Integer Multiplication, Division Arithmetic shift
Multiplication and Division basics
Computer Architecture & Operations I
Integer Multiplication and Division
MIPS mul/div instructions
Morgan Kaufmann Publishers
Morgan Kaufmann Publishers
Lecture 8: Binary Multiplication & Division
Multiplication & Division
CDA 3101 Spring 2016 Introduction to Computer Organization
CS352H: Computer Systems Architecture
Lecture 8: Addition, Multiplication & Division
Lecture 8: Addition, Multiplication & Division
CSCI206 - Computer Organization & Programming
Topic 3c Integer Multiply and Divide
Systems Architecture I
CDA 3101 Summer 2007 Introduction to Computer Organization
Computer Architecture
Morgan Kaufmann Publishers Arithmetic for Computers
Number Representation
1 Lecture 5Multiplication and Division ECE 0142 Computer Organization.
Presentation transcript:

CDA 3101 Summer 2007 Introduction to Computer Organization Division 14 June 2007

Review Multiplication can be implemented using simple shift and add hardware Algorithm is similar to the grade-school method Booth’s algorithm for two’s complement Handles all cases of positive/negative operands More efficient than conventional algorithm 2n + 2n-1 + 2n-2 + … + 2k = 2n+1 - 2k Further optimization is possible MIPS multiply instructions ignore overflow Multu: Hi = 0 Mult: Hi = replicated sign of Lo

Dividend = Quotient x Divisor + Remainder Division Long division of unsigned binary integers 0 0 0 0 1 1 0 1 1 0 1 1 1 0 0 1 0 0 1 1 1 0 1 1 0 0 1 1 1 0 0 0 1 1 1 1 1 0 0 Quotient Dividend Divisor Partial remainders Remainder Dividend = Quotient x Divisor + Remainder

Unsigned Division M Divisor Q Dividend Count n, A 0 START Shift left: A, Q A A - M No Yes A < 0? Q0 0 A A + M Q0 1 Count Count - 1 No Yes Quotient in Q Remainder in A Count = 0 ? END

Division Hardware Divisor M31 . . . M0 32-bit ALU 4’ Add 2 Subtract 4’ write 0 Control 4 write 1 1 SLL 3 A31 . . . A0 Q31 . . . Q0 Dividend

Examples A Q 0000 0111 0000 1110 1101 1110 0001 1100 1110 1100 0011 1000 0000 1000 0000 1001 0001 0010 1110 0010 M = 0011 7 / 3 : Initial values Shift A = A - M A = A + M 1 Shift A = A - M A = A + M 2 Shift A = A - M Q0 = 1 3 Shift A = A - M A = A + M 4

Signed Division Simplest solution Negate the quotient if the signs of divisor and dividend disagree Remainder and dividend must have the same signs Remainder = (Dividend – Quotient * Divisor) (+7) / (+3): Q = 2; R = 1 (-7) / (+3): Q = -2; R = -1 (+7) / (-3): Q = -2; R = 1 (-7) / (-3): Q = 2; R = -1

Signed Division Algorithm A, Q Dividend M Divisor, Count n START Shift left: A, Q S A31, Count Count - 1 No Yes A A + M M31 = A31? A A - M No Yes S = A31? Yes No A=0 and Q=0 ? Q0 1 Restore A Yes Quotient in Q Remainder in A No Count = 0 ? END

Examples (1/2) A Q 0000 0111 0000 1110 1101 0001 1100 1110 0011 1000 0000 0000 1001 0001 0010 M = 0011 A Q 0000 0111 0000 1110 1101 0001 1100 1110 0011 1000 0000 0000 1001 0001 0010 M = 1101 Initial values Initial values Shift Subtract Restore Shift Add Restore 1 1 Shift Subtract Restore Shift Add Restore 2 2 Shift Subtract Q0 = 1 Shift Add Q0 = 1 3 3 Shift Subtract Restore Shift Add Restore 4 4 (7) / (3) (7) / (-3)

Examples (2/2) A Q 1111 1001 1111 0010 0010 1110 0100 0001 1100 1000 1111 M = 0011 A Q 1111 1001 1111 0010 0010 1110 0100 0001 1100 1000 1111 M = 1101 Initial values Initial values Shift Add Restore Shift Subtract Restore 1 1 Shift Add Restore Shift Subtract Restore 2 2 Shift Add Q0 = 1 Shift Subtract Q0 = 1 3 3 Shift Add Restore Shift Subtract Restore 4 4 (-7) / (3) (-7) / (-3)

MIPS Multiply and divide use existing hardware ALU and shifter Extra hardware: 64-bit register able to SLL/SRA Hi contains the remainder (mfhi) Lo contains the quotient (mflo) Instructions Div: signed divide Divu: unsigned divide MIPS ignores overflow ? Division by 0 must be checked in software

MIPS Processor ALU Sign extend Zero Overflow Registers Memory address IR: Control Unit 0 1 Sign extend 16 32 ALU Zero Overflow Registers Memory address 0 1 2 Sub Operation M Lo Hi SLL/SRA

Have a Great Weekend!!