Basic Dividers Lecture 10. Required Reading Chapter 13, Basic Division Schemes 13.1, Shift/Subtract Division Algorithms 13.3, Restoring Hardware Dividers.

Slides:



Advertisements
Similar presentations
Division Circuits Jan 2013 Shmuel Wimer Bar Ilan University, Engineering Faculty Technion, EE Faculty 1.
Advertisements

Integer division Pencil and paper binary division (dividend)(divisor) 1000.
Lecture 15: Computer Arithmetic Today’s topic –Division 1.
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.
Computer ArchitectureFall 2007 © September 5, 2007 Karem Sakallah CS 447 – Computer Architecture.
Booth’s Algorithm.
May 2007Computer Arithmetic, DivisionSlide 1 Part IV Division.
COE 308: Computer Architecture (T041) Dr. Marwan Abu-Amara Integer & Floating-Point Arithmetic (Appendix A, Computer Architecture: A Quantitative Approach,
CSE 246: Computer Arithmetic Algorithms and Hardware Design Instructor: Prof. Chung-Kuan Cheng Winter 2004 Lecture 7.
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
Computer ArchitectureFall 2008 © August 27, CS 447 – Computer Architecture Lecture 4 Computer Arithmetic (2)
Ch. 21. Square-rootingSlide 1 VI Function Evaluation Topics in This Part Chapter 21 Square-Rooting Methods Chapter 22 The CORDIC Algorithms Chapter 23.
ECE 645 – Computer Arithmetic Lecture 10: Fast Dividers ECE 645—Computer Arithmetic 4/15/08.
Lecture 10 Fast Dividers.
ECE 645 – Computer Arithmetic Lecture 9: Basic Dividers ECE 645—Computer Arithmetic 4/1/08.
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.
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION.
CH09 Computer Arithmetic  CPU combines of ALU and Control Unit, this chapter discusses ALU The Arithmetic and Logic Unit (ALU) Number Systems Integer.
Oct. 18, 2007SYSC 2001* - Fall SYSC2001-Ch9.ppt1 See Stallings Chapter 9 Computer Arithmetic.
Multiplication of signed-operands
Digital Kommunikationselektronik TNE027 Lecture 2 1 FA x n –1 c n c n1- y n1– s n1– FA x 1 c 2 y 1 s 1 c 1 x 0 y 0 s 0 c 0 MSB positionLSB position Ripple-Carry.
Figure 1.1 Block diagram of a digital computer. Functional Units.
Division Harder Than Multiplication Because Quotient Digit Selection/Estimation Can Have Overflow Condition – Divide by Small Number OR even Worse – Divide.
1 Dividers Lecture 10. Required Reading Chapter 13, Basic Division Schemes 13.1, Shift/Subtract Division Algorithms 13.3, Restoring Hardware Dividers.
1 Basic Dividers Lecture 10. Required Reading Chapter 13, Basic Division Schemes 13.1, Shift/Subtract Division Algorithms 13.3, Restoring Hardware Dividers.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Lecture notes Reading: Section 3.4, 3.5, 3.6 Multiplication
Advanced Dividers Lecture 10. Required Reading Chapter 13, Basic Division Schemes 13.4, Non-Restoring and Signed Division Chapter 15 Variation in Dividers.
CEC 220 Digital Circuit Design Binary Arithmetic & Negative Numbers Monday, January 13 CEC 220 Digital Circuit Design Slide 1 of 14.
COE 308: Computer Architecture (T032) Dr. Marwan Abu-Amara Integer & Floating-Point Arithmetic (Appendix A, Computer Architecture: A Quantitative Approach,
CEC 220 Digital Circuit Design Binary Arithmetic & Negative Numbers Fri, Aug 28 CEC 220 Digital Circuit Design Slide 1 of 14.
Dr Mohamed Menacer College of Computer Science and Engineering Taibah University CE-321: Computer.
Lecture 11 Advanced Dividers.
1 Basic Dividers Lecture 9. Required Reading Chapter 13, Basic Division Schemes 13.1, Shift/Subtract Division Algorithms 13.3, Restoring Hardware Dividers.
CDA 3101 Spring 2016 Introduction to Computer Organization
CSE 246: Computer Arithmetic Algorithms and Hardware Design Instructor: Prof. Chung-Kuan Cheng Fall 2006 Lecture 7 Division.
Integer Operations Computer Organization and Assembly Language: Module 5.
Ch. 4 Computer Arithmetic
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. Copyright  2005 by Oxford University Press, Inc. Computer Architecture Parhami2 Figure 11.1 Multiplication of 4-bit numbers in dot notation.
Chapter 9 Computer Arithmetic
William Stallings Computer Organization and Architecture 8th Edition
More Binary Arithmetic - Multiplication
Part III The Arithmetic/Logic Unit
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
Morgan Kaufmann Publishers
CDA 3101 Summer 2007 Introduction to Computer Organization
William Stallings Computer Organization and Architecture 7th Edition
Computer Organization and ASSEMBLY LANGUAGE
Lecture 9 Basic Dividers.
Radix 2 Sequential Multipliers
CSCI206 - Computer Organization & Programming
ECEG-3202 Computer Architecture and Organization
12/7/
Chapter 8 Computer Arithmetic
Lecture 9 Basic Dividers.
Radix –Two Division Most complex of the four arithmetic operations (addition, subtraction, multiplication and division). Requires the most in terms of.
Presentation transcript:

Basic Dividers Lecture 10

Required Reading Chapter 13, Basic Division Schemes 13.1, Shift/Subtract Division Algorithms 13.3, Restoring Hardware Dividers 13.4, Non-Restoring and Signed Division Chapter 15 Variation in Dividers 15.6, Combined Multiply/Divide Units Behrooz Parhami, Computer Arithmetic: Algorithms and Hardware Design

Notation and Basic Equations

4 Notation z Dividend z 2k-1 z 2k-2... z 2 z 1 z 0 d Divisor d k-1 d k-2... d 1 d 0 q Quotient q k-1 q k-2... q 1 q 0 s Remainder s k-1 s k-2... s 1 s 0 (s = z - dq)

5 Basic Equations of Division z = d q + s sign(s) = sign(z) | s | < | d | z > 0 0  s < | d | z < 0 - | d | < s  0

6 Unsigned Integer Division Overflow z = z H 2 k + z L < d 2 k Condition for no overflow (i.e. q fits in k bits): z = q d + s < (2 k -1) d + d = d 2 k z H < d Must check overflow because obviously the quotient q can also be 2k bits. For example, if the divisor d is 1, then the quotient q is the dividend z, which is 2k bits

7 Sequential Integer Division Basic Equations s (0) = z s (j) = 2 s (j-1) - q k-j (2 k d) for j=1..k s (k) = 2 k s

8 Sequential Integer Division Justification s (1) = 2 z - q k-1 (2 k d) s (2) = 2(2 z - q k-1 (2 k d)) - q k-2 (2 k d) s (3) = 2(2(2 z - q k-1 (2 k d)) - q k-2 (2 k d)) - q k-3 (2 k d)... s (k) = 2(... 2(2(2 z - q k-1 (2 k d)) - q k-2 (2 k d)) - q k-3 (2 k d)... - q 0 (2 k d) = = 2 k z - (2 k d) (q k-1 2 k-1 + q k-2 2 k-2 + q k-3 2 k-3 + … + q ) = = 2 k z - (2 k d) q = 2 k (z - d q) = 2 k s

9 Fig Examples of sequential division with integer and fractional operands.

Fractional Division

11 Unsigned Fractional Division z frac Dividend.z -1 z z -(2k-1) z -2k d frac Divisor.d -1 d d -(k-1) d -k q frac Quotient.q -1 q q -(k-1) q -k s frac Remainder.000…0s -(k+1)... s -(2k-1) s -2k k bits

12 Integer vs. Fractional Division For Integers: z = q d + s  2 -2k z 2 -2k = (q 2 -k ) (d 2 -k ) + s (2 -2k ) z frac = q frac d frac + s frac For Fractions: where z frac = z 2 -2k d frac = d 2 -k q frac = q 2 -k s frac = s 2 -2k

13 Unsigned Fractional Division Overflow Condition for no overflow: z frac < d frac

14 Sequential Fractional Division Basic Equations s (0) = z frac s (j) = 2 s (j-1) - q -j d frac for j=1..k 2 k · s frac = s (k) s frac = 2 -k · s (k)

15 Sequential Fractional Division Justification s (1) = 2 z frac - q -1 d frac s (2) = 2(2 z frac - q -1 d frac ) - q -2 d frac s (3) = 2(2(2 z frac - q -1 d frac ) - q -2 d frac ) - q -3 d frac... s (k) = 2(... 2(2(2 z frac - q -1 d frac ) - q -2 d frac ) - q -3 d frac... - q -k d frac = = 2 k z frac - d frac (q -1 2 k-1 + q -2 2 k-2 + q -3 2 k-3 + … + q -k 2 0 ) = = 2 k z frac - d frac 2 k (q q q … + q -k 2 -k ) = = 2 k z frac - (2 k d frac ) q frac = 2 k (z frac - d frac q frac ) = 2 k s frac

Restoring Unsigned Integer Division

17 Restoring Unsigned Integer Division s (0) = z for j = 1 to k if 2 s (j-1) - 2 k d > 0 q k-j = 1 s (j) = 2 s (j-1) - 2 k d else q k-j = 0 s (j) = 2 s (j-1) end for

18 Fig Example of restoring unsigned division.

19 Fig Shift/subtract sequential restoring divider.

Non-Restoring Unsigned Integer Division

s (0) = z s (1) = 2 s (0) - 2 k d for j = 2 to k if s (j-1)  0 q k-(j-1) = 1 s (j) = 2 s (j-1) - 2 k d else q k-(j-1) = 0 s (j) = 2 s (j-1) + 2 k d end for if s (k)  0 q 0 = 1 else q 0 = 0 Correction step

22 Non-Restoring Unsigned Integer Division Correction step z = q d + s z = (q-1) d + (s+d) z = q’ d + s’ z, q, d ≥ 0 s<0 s = 2 -k · s (k)

23 Example of nonrestoring unsigned division

24 Partial remainder variations for restoring and nonrestoring division

25 s (j) = 2 s (j-1) s (j+1) = 2 s (j) - 2 k d = = 4 s (j-1) - 2 k d s (j) = 2 s (j-1) - 2 k d s (j+1) = 2 s (j) + 2 k d = = 2 (2 s (j-1) - 2 k d) + 2 k d = = 4 s (j-1) - 2 k d Restoring division Non-Restoring division Non-Restoring Unsigned Integer Division Justification s (j-1) ≥ 0 2 s (j-1) - 2 k d < 0 2 (2 s (j-1) ) - 2 k d ≥ 0

May 2012Computer Arithmetic, DivisionSlide 26 Convergence of the Partial Quotient to q In restoring division, the partial quotient converges to q from below Example ( ) two / ( ) two (117) ten /(10) ten = (11) ten = (1011) two In nonrestoring division, the partial quotient may overshoot q, but converges to it after some oscillations

Signed Integer Division

28 Signed Integer Division z d | z || d |sign(z)sign(d) | q || s | sign(s) = sign(z) sign(q) = + - Unsigned division sign(z) = sign(d) sign(z)  sign(d) qs

29 Examples of division with signed operands z = 5d = 3  q = 1s = 2 z = 5d = –3  q = –1s = 2 z = –5d = 3  q = –1s = –2 z = –5d = –3  q = 1s = –2 Magnitudes of q and s are unaffected by input signs Signs of q and s are derivable from signs of z and d Examples of Signed Integer Division

Non-Restoring Signed Integer Division

31 Non-Restoring Signed Integer Division s (0) = z for j = 1 to k if sign(s (j-1) ) == sign(d) q k-j = 1 s (j) = 2 s (j-1) - 2 k d = 2 s (j-1) - q k-j (2 k d) else q k-j = -1 s (j) = 2 s (j-1) + 2 k d = 2 s (j-1) - q k-j (2 k d) end for q = BSD_2’s_comp_conversion(q) Correction_step

32 Non-Restoring Signed Integer Division Correction step z = q d + s z = (q-1) d + (s+d) z = q’ d + s’ z = (q+1) d + (s-d) z = q” d + s” s = 2 -k · s (k) sign(s) = sign(z)

33 Example of nonrestoring signed division ======================== z d –2 4 d ======================== s (0) s (0) sign(s (0) )  sign(d), +2 4 d so set q 3 =  1 and add –––––––––––––––––––––––– s (1) s (1) sign(s (1) ) = sign(d), +(–2 4 d) so set q 2 = 1 and subtract –––––––––––––––––––––––– s (2) s (2) sign(s (2) )  sign(d), +2 4 d so set q 1 =  1 and add –––––––––––––––––––––––– s (3) s (3) sign(s (3) ) = sign(d), +(–2 4 d) so set q 0 = 1 and subtract –––––––––––––––––––––––– s (4) sign(s (4) )  sign(z), +(–2 4 d) so perform corrective subtraction –––––––––––––––––––––––– s (4) s q  1 1  1 1 ======================== p = Shift, compl MSB Add 1 to correct Check: 33/(  7) =  4

34 BSD  2’s Complement Conversion q = (q k-1 q k-2... q 1 q 0 ) BSD = = (p k-1 p k-2... p 1 p 0 1) 2’s complement where pipi qiqi Example: q BSD p q 2’scomp = no overflow if p k-2 = p k-1 (q k-1  q k-2 )

May 2012Computer Arithmetic, DivisionSlide 35 Nonrestoring Hardware Divider

36 Multiply/Divide Unit

37 The control unit proceeds through necessary steps for multiplication or division (including using the appropriate shift direction) Fig Sequential radix-2 multiply/divide unit. The slight speed penalty owing to a more complex control unit is insignificant Multiply-Divide Unit