Lecture 9 Basic Dividers.

Slides:



Advertisements
Similar presentations
ECE 645 – Computer Arithmetic Lecture 11: Advanced Topics and Final Review ECE 645—Computer Arithmetic 4/22/08.
Advertisements

Integer division Pencil and paper binary division (dividend)(divisor) 1000.
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.
1 Lecture 4: Arithmetic for Computers (Part 5) CS 447 Jason Bakos.
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)
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. 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.
Number Systems. Today Decimal Hexadecimal Binary –Unsigned Binary –1’s Complement Binary –2’s Complement Binary.
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.
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.
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:
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.
Basic Dividers Lecture 10. Required Reading Chapter 13, Basic Division Schemes 13.1, Shift/Subtract Division Algorithms 13.3, Restoring Hardware 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.
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.
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
Computer Architecture & Operations I
Carry-Lookahead & Carry-Select Adders
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
Sequential Multipliers
Number Representation
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
Tree and Array Multipliers
ECEG-3202 Computer Architecture and Organization
12/7/
Unit 1. Day 8..
Chapter 8 Computer Arithmetic
Tree and Array Multipliers
UNIVERSITY OF MASSACHUSETTS Dept
UNIVERSITY OF MASSACHUSETTS Dept
Radix –Two Division Most complex of the four arithmetic operations (addition, subtraction, multiplication and division). Requires the most in terms of.
Presentation transcript:

Lecture 9 Basic Dividers

Computer Arithmetic: Algorithms and Hardware Design Required Reading Behrooz Parhami, Computer Arithmetic: Algorithms and Hardware Design Chapter 13, Basic Division Schemes 13.1, Shift/Subtract Division Algorithms 13.3, Restoring Hardware Dividers 13.4, Non-Restoring and Signed Division Note errata at: http://www.ece.ucsb.edu/~parhami/text_comp_arit_1ed.htm#errors

Recommended Reading J-P. Deschamps, G. Bioul, G. Sutter, Synthesis of Arithmetic Circuits: FPGA, ASIC and Embedded Systems Chapter 6, Arithmetic Operations: Division 6.1, Natural Numbers 6.2.1, General Algorithm 6.2.2, Restoring Division Algorithm 6.2.3, Base-2 Non-Restoring Division Algorithm

Notation and Basic Equations

Notation z Dividend z2k-1z2k-2 . . . z2 z1 z0 d Divisor dk-1dk-2 . . . d1 d0 q Quotient qk-1qk-2 . . . q1 q0 s Remainder sk-1sk-2 . . . s1 s0 (s = z - dq)

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

Unsigned Integer Division Overflow 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 Condition for no overflow (i.e. q fits in k bits): z = q d + s < (2k-1) d + d = d 2k z = zH 2k + zL < d 2k zH < d

Sequential Integer Division Basic Equations s(0) = z s(j) = 2 s(j-1) - qk-j (2k d) s(k) = 2k s

Sequential Integer Division Justification s(1) = 2 z - qk-1 (2k d) s(2) = 2(2 z - qk-1 (2k d)) - qk-2 (2k d) s(3) = 2(2(2 z - qk-1 (2k d)) - qk-2 (2k d)) - qk-3 (2k d) . . . . . . s(k) = 2(. . . 2(2(2 z - qk-1 (2k d)) - qk-2 (2k d)) - qk-3 (2k d) . . . - q0 (2k d) = = 2k z - (2k d) (qk-1 2k-1 + qk-2 2k-2 + qk-3 2k-3 + … + q020) = = 2k z - (2k d) q = 2k (z - d q) = 2k s

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

Fractional Division

Unsigned Fractional Division zfrac Dividend .z-1z-2 . . . z-(2k-1)z-2k dfrac Divisor .d-1d-2 . . . d-(k-1) d-k qfrac Quotient .q-1q-2 . . . q-(k-1) q-k sfrac Remainder .000…0s-(k+1) . . . s-(2k-1) s-2k k bits

Integer vs. Fractional Division For Integers: z = q d + s  2-2k z 2-2k = (q 2-k) (d 2-k) + s (2-2k) For Fractions: zfrac = qfrac dfrac + sfrac where zfrac = z 2-2k dfrac = d 2-k qfrac = q 2-k sfrac = s 2-2k

Unsigned Fractional Division Overflow Condition for no overflow: zfrac < dfrac

Sequential Fractional Division Basic Equations s(0) = zfrac s(j) = 2 s(j-1) - q-j dfrac 2k · sfrac = s(k) sfrac = 2-k · s(k)

Sequential Fractional Division Justification s(1) = 2 zfrac - q-1 dfrac s(2) = 2(2 zfrac - q-1 dfrac) - q-2 dfrac s(3) = 2(2(2 zfrac - q-1 dfrac) - q-2 dfrac) - q-3 dfrac . . . . . . s(k) = 2(. . . 2(2(2 zfrac - q-1 dfrac) - q-2 dfrac) - q-3 dfrac . . . - q-k dfrac = = 2k zfrac - dfrac (q-1 2k-1 + q-2 2k-2 + q-3 2k-3 + … + q-k20) = = 2k zfrac - dfrac 2k (q-1 2-1 + q-2 2-2 + q-3 2-3 + … + q-k2-k) = = 2k zfrac - (2k dfrac) qfrac = 2k (zfrac - dfrac qfrac) = 2k sfrac

Restoring Unsigned Integer Division

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

Fig. 13.6 Example of restoring unsigned division.

Fig. 13.5 Shift/subtract sequential restoring divider.

Non-Restoring Unsigned Integer Division

Non-Restoring Unsigned Integer Division s(1) = 2 z - 2k d for j = 2 to k if s(j-1)  0 qk-(j-1) = 1 s(j) = 2 s(j-1) - 2k d else qk-(j-1) = 0 s(j) = 2 s(j-1) + 2k d end for if s(k)  0 q0 = 1 q0 = 0 Correction step

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

Fig. 13.7 Example of nonrestoring unsigned division.

Fig. 13.8 Partial remainder variations for restoring and nonrestoring division.

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

Signed Integer Division

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

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

Non-Restoring Signed Integer Division

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

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

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

BSD  2’s Complement Conversion q = (qk-1 qk-2 . . . q1 q0)BSD = = (pk-1 pk-2 . . . p1 p0 1)2’s complement where Example: qBSD 1 -1 1 1 qi pi -1 p 1 0 1 1 1 1 q2’scomp 0 0 1 1 1 = 0 1 1 1 no overflow if pk-2 = pk-1 (qk-1  qk-2)

Fig. 13.10 Shift-subtract sequential nonrestoring divider. NOTE: qk-j and add/subtract control determined by both divisor sign and sign of new partial remainder (via an XOR operation). Divisor sign is 0 for unsigned division. 2. note that cout is the complement of the sign of the new partial remainder, i.e. if new partial remainder = 0, then cout = 1; if new partial remainder = 1, then cout=0