More Binary Arithmetic - Multiplication

Slides:



Advertisements
Similar presentations
Cosc 2150: Computer Organization Chapter 9, Part 2 Integer multiplication and division.
Advertisements

Integer division Pencil and paper binary division (dividend)(divisor) 1000.
THE ARITHMETIC-LOGIC UNIT. BINARY HALF-ADDER BINARY HALF-ADDER condt Half adder InputOutput XYSC
Binary Addition Rules Adding Binary Numbers = = 1
CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (2)
Lecture 9 Sept 28 Chapter 3 Arithmetic for Computers.
CPSC 321 Computer Architecture ALU Design – Integer Addition, Multiplication & Division Copyright 2002 David H. Albonesi and the University of Rochester.
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
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.
Computer Arithmetic Nizamettin AYDIN
Computer Arithmetic. Instruction Formats Layout of bits in an instruction Includes opcode Includes (implicit or explicit) operand(s) Usually more than.
Computer Architecture Lecture 3: Logical circuits, computer arithmetics Piotr Bilski.
Multiplication of signed-operands
Division Harder Than Multiplication Because Quotient Digit Selection/Estimation Can Have Overflow Condition – Divide by Small Number OR even Worse – Divide.
Chapter 3 Arithmetic for Computers (Integers). Florida A & M University - Department of Computer and Information Sciences Arithmetic for Computers Operations.
Lecture notes Reading: Section 3.4, 3.5, 3.6 Multiplication
Partial Quotient Method In this division algorithm the children record on the right side of the problem. The first thing they do is divide. They ask themselves.
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.
Department of Communication Engineering, NCTU 1 Unit 4 Arithmetic and Logic Units.
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
My Book of Divisibility. THE 2’s Example: 30, 42, 24, 76, 98, Must be an even number Number must end in a 0, 2, 4, 6, or 8.
Integer Operations Computer Organization and Assembly Language: Module 5.
Chapter 8 Computer Arithmetic. 8.1 Unsigned Notation Non-negative notation  It treats every number as either zero or a positive value  Range: 0 to 2.
1 Lecture 5Multiplication and Division ECE 0142 Computer Organization.
Arithmetic for Computers Chapter 3 1. Arithmetic for Computers  Operations on integers  Addition and subtraction  Multiplication and division  Dealing.
Chapter 9 Computer Arithmetic
William Stallings Computer Organization and Architecture 8th Edition
Computer System Design Lecture 3
COMPUTER ARITHMETIC Arithmetic with Signed-2's Complement Numbers
Computer Architecture & Operations I
Multiplication and Division basics
Computer Architecture & Operations I
Integer Multiplication and Division
Integer Division.
Morgan Kaufmann Publishers Arithmetic for Computers
Negative Numbers.
COMPUTING FUNDAMENTALS
Morgan Kaufmann Publishers
Morgan Kaufmann Publishers
Lecture 16 Arithmetic Circuits
Arithmetic and Logic Units
CDA 3101 Summer 2007 Introduction to Computer Organization
William Stallings Computer Organization and Architecture 7th Edition
Computer Organization and ASSEMBLY LANGUAGE
King Fahd University of Petroleum and Minerals
CSCE 350 Computer Architecture
Topic 3c Integer Multiply and Divide
Computer Organization and Design
Computation in Other Bases
ECEG-3202 Computer Architecture and Organization
Logical Operations Boy who sow wild oats better hope for crop failure.
Computer Architecture
Reading: Study Chapter (including Booth coding)
October 15 Chapter 4 – Multiplication/Division Go to the State Fair!
Chapter 8 Computer Arithmetic
Montek Singh Mon, Mar 28, 2011 Lecture 11
Arithmetic Logic Unit A.R. Hurson Electrical and Computer Engineering Missouri University of Science & Technology A.R. Hurson.
Logical Operations Boy who sow wild oats better hope for crop failure.
1 Lecture 5Multiplication and Division ECE 0142 Computer Organization.
Presentation transcript:

More Binary Arithmetic - Multiplication (unsigned example ) multiplying two 32-bit values gives up to a 64-bit product we go from right to left across the multiplier digits in generating partial products we could use a double-length product register, and at each step we could shift the multiplicand into the correct place for adding or not (just like the normal paper and pencil approach)

More Binary Arithmetic - Multiplication (unsigned example ) e.g., 1111 4-bit multiplicand x 0101 4-bit multiplier ....1111 ...0000. (. is a placeholder, equal to 0) ..1111.. .0000... 01001011 since one column is completely determined on the right at each step, we could instead arrange to shift the partial sum to the right after each add - this means we only need a 4- bit wide adder need 8-bit adder

More Binary Arithmetic - Multiplication initially: carry 0 accumulator 0 mq multiplier mdr multiplicand

More Binary Arithmetic - Multiplication for( i = 1; i <= n; i++ ) { /* step i */ if( mq_bit[0] == 1 ) (carry:accumulator) accumulator + mdr } shift (carry:accumulator:mq) right one place results: high bits of product in accumulator low bits of product in mq

e.g., 1111 4-bit multiplicand x 0101 4-bit multiplier ------ initially: C ACC MQ 0 0000 0101 MDR 1111 ----------------------------------------- step 1: 0 0000 0101 + 1111 ^ add based on lsb=1 ------- 0 1111 0101 >> shift right 0 0111 1010 step 2: 0 0111 1010 + 0000 ^ no add based on lsb=0 0 0111 1010 >> shift right 0 0011 1101

----------------------------------------- step 3: 0 0011 1101 + 1111 ^ add based on lsb=1 ------- 1 0010 1101 >> shift right 0 1001 0110 step 4: 0 1001 0110 + 0000 ^ no add based on lsb=0 0 0100 1011 There are faster forms of multiplication hardware; a current processor may only require 3-5 cycles for an integer multiply  

More Binary Arithmetic - Division Instead of add-then-shift, division is implemented by shift- then-subtract double-length dividend divided by single-length divisor yields single-length quotient and single-length remainder we work from left to right in generating the quotient

More Binary Arithmetic - Division initially: carry 0 accumulator high bits of dividend (0s if dividend is single length) mq low bits of dividend mdr divisor

More Binary Arithmetic - Division if( mdr == 0 ) { raise( DIVIDE_BY_ZERO__SIGNAL ); } if( mdr <= accumulator ){ raise( QUOTIENT_OVERFLOW_SIGNAL ); } for( i = 1; i <= n; i++ ) { /* step i */ shift (carry:accumulator:mq) left one place (carry:accumulator) (carry:accumulator) - mdr /* subtract */ if( (carry:accumulator) is negative ) { mq_bit[0] 0 (carry:accumulator) (carry:accumulator) + mdr /* restore */ } else { mq_bit[0] 1 results: quotient in mq remainder in accumulator

More Binary Arithmetic - Division this is called restoring division, since the C:ACC must be restored to its previous value if the result of a subtraction is negative when the dividend is double-length, there is a special check (the value in the MDR should be greater than the value in the ACC) to make sure that the quotient won't overflow (e.g., consider 11111111 / 1) when dividend is single-length, it is placed in the MQ and the ACC is set to zero

e.g., 11001001 8-bit dividend / 1111 4-bit divisor -------- initially: C ACC MQ 0 1100 1001 MDR 1111 (step 0: ( MDR != 0 ) and ( MDR > ACC ) so no exceptions) -------------------------------------------- step 1: 0 1100 1001 << shift left 1 1001 001. - 1111 subtract (== add 1 0001) ----- 0 1010 0011 ^ set to 1 since subtract successful --------------------------------------------- step 2: 0 1010 0011 1 0100 011. - 1111 subtract (== add 1 0001) ---- 0 0101 0111

--------------------------------------------- step 3: 0 0101 0111 << shift left 0 1010 111. - 1111 subtract (== add 1 0001) ------ 1 1011 1110 ^ set to 0 since subtract unsuccessful + 1111 restoring add 0 1010 1110 ----------------------------------------------- step 4: 0 1010 1110 << shift left 1 0101 110. - 1111 subtract (== add 1 0001) 0 0110 1101 ^ set to 1 since subtract successful remainder quotient is in ACC is in MQ 0110 1101 (there are faster forms of division, e.g., non-restoring)