ECE/CS 552: Integer Multipliers

Slides:



Advertisements
Similar presentations
Multipliers Multipliers Booth’s Multiplier Floating Point Arithmetic.
Advertisements

Lab 10 : Arithmetic Systems : Adder System Layout: Slide #2 Slide #3 Slide #4 Slide #5 Arithmetic Overflow: 2’s Complement Conversions: 8 Bit Adder/Subtractor.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Lecture 8 - Multiplication.
King Fahd University of Petroleum and Minerals
Computer ArchitectureFall 2008 © August 25, CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (1)
ECE 331 – Digital System Design
ECE 301 – Digital Electronics
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
1 Lecture 4: Arithmetic for Computers (Part 4) CS 447 Jason Bakos.
Computer ArchitectureFall 2007 © August 29, 2007 Karem Sakallah CS 447 – Computer Architecture.
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.
1 Bits are just bits (no inherent meaning) — conventions define relationship between bits and numbers Binary numbers (base 2)
ECE 4110– Sequential Logic Design
Computer Architecture Lecture 3: Logical circuits, computer arithmetics Piotr Bilski.
Binary Arithmetic Stephen Boyd March 14, Two's Complement Most significant bit represents sign. 0 = positive 1 = negative Positive numbers behave.
ECE232: Hardware Organization and Design
Copyright 1995 by Coherence LTD., all rights reserved (Revised: Oct 97 by Rafi Lohev, Oct 99 by Yair Wiseman, Sep 04 Oren Kapah) IBM י ב מ 10-1 The ALU.
CSE 241 Computer Organization Lecture # 9 Ch. 4 Computer Arithmetic Dr. Tamer Samy Gaafar Dept. of Computer & Systems Engineering.
Computer Arithmetic II Instructor: Mozafar Bag-Mohammadi Spring 2006 University of Ilam.
 Recall grade school trick ◦ When multiplying by 9:  Multiply by 10 (easy, just shift digits left)  Subtract once ◦ E.g.  x 9 = x (10.
King Fahd University of Petroleum and Minerals King Fahd University of Petroleum and Minerals Computer Engineering Department Computer Engineering Department.
Multiplication of signed-operands
Computer Arithmetic II Instructor: Mozafar Bag-Mohammadi Ilam University.
ECE 2110: Introduction to Digital Systems Signed Addition/Subtraction.
1 Arithmetic and Logic Operations Patt and Patel Ch. 2 & 3.
IT253: Computer Organization
ECE/CS 552: Integer Dividers
ECE/CS 552: Arithmetic I Instructor:Mikko H Lipasti Fall 2010 University of Wisconsin-Madison Lecture notes partially based on set created by Mark Hill.
Integer Operations Computer Organization and Assembly Language: Module 5.
1 Lecture 5Multiplication and Division ECE 0142 Computer Organization.
William Stallings Computer Organization and Architecture 8th Edition
Computer System Design Lecture 3
More Binary Arithmetic - Multiplication
CDA3101 Recitation Section 5
Chapter Contents 3.1 Overview 3.2 Fixed Point Addition and Subtraction
Addition and Subtraction
Integer Multiplication and Division
Addition and multiplication
Multiplication & Division
Principles & Applications
Wakerly Section 2.4 and further
Computer Organization and ASSEMBLY LANGUAGE
ECE/CS 552: Carry Lookahead
CDA 3101 Spring 2016 Introduction to Computer Organization
Lecture 8: Addition, Multiplication & Division
ECE/CS 552: Arithmetic and Logic
ECE/CS 552: Floating Point
Lecture 8: Addition, Multiplication & Division
CSCE 350 Computer Architecture
CDA 3101 Summer 2007 Introduction to Computer Organization
King Fahd University of Petroleum and Minerals
Computer Organization and Design
Arithmetic Logical Unit
Subtraction The arithmetic we did so far was limited to unsigned (positive) integers. Today we’ll consider negative numbers and subtraction. The main problem.
EE207: Digital Systems I, Semester I 2003/2004
Computer Arithmetic Multiplication, Floating Point
ECEG-3202 Computer Architecture and Organization
12/7/
CS 140 Lecture 14 Standard Combinational Modules
مظفر بگ محمدی دانشگاه ایلام
CSE 140 Lecture 14 Standard Combinational Modules
Addition and multiplication
Chapter 8 Computer Arithmetic
Addition and multiplication
ECE 352 Digital System Fundamentals
2's Complement Arithmetic
GCSE COMPUTER SCIENCE Topic 3 - Data 3.3 Logical and Arithmetic Shifts.
1 Lecture 5Multiplication and Division ECE 0142 Computer Organization.
Presentation transcript:

ECE/CS 552: Integer Multipliers © Prof. Mikko Lipasti Lecture notes based in part on slides created by Mark Hill, David Wood, Guri Sohi, John Shen and Jim Smith

Basic Arithmetic and the ALU Earlier in the semester Number representations, 2’s complement, unsigned Addition/Subtraction Add/Sub ALU Full adder, ripple carry, subtraction Carry-lookahead addition Logical operations and, or, xor, nor, shifts Overflow

Basic Arithmetic and the ALU Now Integer multiplication Booth’s algorithm This is not crucial for the project

Multiplication 1 x Flashback to 3rd grade Base 10: 8 x 9 = 72 Multiplier Multiplicand Partial products Final sum Base 10: 8 x 9 = 72 PP: 8 + 0 + 0 + 64 = 72 How wide is the result? log(n x m) = log(n) + log(m) 32b x 32b = 64b result 1 x

Array Multiplier 1 x Adding all partial products simultaneously using an array of basic cells Sin Cin Ai Bj Ai ,Bj Full Adder Cout Sout

16-bit Array Multiplier Conceptually straightforward [Source: J. Hayes, Univ. of Michigan] Conceptually straightforward Fairly expensive hardware, integer multiplies relatively rare Most used in array address calc: replace with shifts

Instead: Multicycle Multipliers Combinational multipliers Very hardware-intensive Integer multiply relatively rare Not the right place to spend resources Multicycle multipliers Iterate through bits of multiplier Conditionally add shifted multiplicand

Multiplier 1 x

Multiplier 1 x

Multiplier Improvements Do we really need a 64-bit adder? No, since low-order bits are not involved Hence, just use a 32-bit adder Shift product register right on every step Do we really need a separate multiplier register? No, since low-order bits of 64-bit product are initially unused Hence, just store multiplier there initially

Multiplier 1 x

Multiplier 1 x

Signed Multiplication Recall For p = a x b, if a<0 or b<0, then p < 0 If a<0 and b<0, then p > 0 Hence sign(p) = sign(a) xor sign(b) Hence Convert multiplier, multiplicand to positive number with (n-1) bits Multiply positive numbers Compute sign, convert product accordingly Or, Perform sign-extension on shifts for prev. design Right answer falls out

Booth’s Encoding Recall grade school trick When multiplying by 9: Multiply by 10 (easy, just shift digits left) Subtract once E.g. 123454 x 9 = 123454 x (10 – 1) = 1234540 – 123454 Converts addition of six partial products to one shift and one subtraction Booth’s algorithm applies same principle Except no ‘9’ in binary, just ‘1’ and ‘0’ So, it’s actually easier!

Booth’s Encoding Search for a run of ‘1’ bits in the multiplier E.g. ‘0110’ has a run of 2 ‘1’ bits in the middle Multiplying by ‘0110’ (6 in decimal) is equivalent to multiplying by 8 and subtracting twice, since 6 x m = (8 – 2) x m = 8m – 2m Hence, iterate right to left and: Subtract multiplicand from product at first ‘1’ Add multiplicand to product after last ‘1’ Don’t do either for ‘1’ bits in the middle

Booth’s Algorithm Current bit Bit to right Explanation Example Operation 1 Begins run of ‘1’ 00001111000 Subtract Middle of run of ‘1’ Nothing End of a run of ‘1’ Add Middle of a run of ‘0’

Booth’s Encoding Really just a new way to encode numbers Normally positionally weighted as 2n With Booth, each position has a sign bit Can be extended to multiple bits 1 Binary +1 -1 1-bit Booth +2 -2 2-bit Booth

2-bits/cycle Booth Multiplier For every pair of multiplier bits If Booth’s encoding is ‘-2’ Shift multiplicand left by 1, then subtract If Booth’s encoding is ‘-1’ Subtract If Booth’s encoding is ‘0’ Do nothing If Booth’s encoding is ‘1’ Add If Booth’s encoding is ‘2’ Shift multiplicand left by 1, then add

2 bits/cycle Booth’s Current Previous Operation Explanation 00 1 bit Booth 00 +0 01 +M; 10 -M; 11 Current Previous Operation Explanation 00 +0;shift 2 [00] => +0, [00] => +0; 2x(+0)+(+0)=+0 1 +M; shift 2 [00] => +0, [01] => +M; 2x(+0)+(+M)=+M 01 [01] => +M, [10] => -M; 2x(+M)+(-M)=+M +2M; shift 2 [01] => +M, [11] => +0; 2x(+M)+(+0)=+2M 10 -2M; shift 2 [10] => -M, [00] => +0; 2x(-M)+(+0)=-2M -M; shift 2 [10] => -M, [01] => +M; 2x(-M)+(+M)=-M 11 [11] => +0, [10] => -M; 2x(+0)+(-M)=-M +0; shift 2 [11] => +0, [11] => +0; 2x(+0)+(+0)=+0

Booth’s Example Negative multiplicand: -6 x 6 = -36 1010 x 0110, 0110 in Booth’s encoding is +0-0 Hence: 1111 1010 x 0 0000 0000 1111 0100 x –1 0000 1100 1110 1000 1101 0000 x +1 Final Sum: 1101 1100 (-36)

Booth’s Example Negative multiplier: -6 x -2 = 12 1010 x 1110, 1110 in Booth’s encoding is 00-0 Hence: 1111 1010 x 0 0000 0000 1111 0100 x –1 0000 1100 1110 1000 1101 0000 Final Sum: 0000 1100 (12)

Summary Integer multiply Combinational Multicycle Booth’s algorithm