CSE 575 Computer Arithmetic Spring 2003 Mary Jane Irwin (www. cse. psu

Slides:



Advertisements
Similar presentations
Lecture 15: Computer Arithmetic Today’s topic –Division 1.
Advertisements

Lecture Objectives: 1)Perform binary division of two numbers. 2)Define dividend, divisor, quotient, and remainder. 3)Explain how division is accomplished.
UNIVERSITY OF MASSACHUSETTS Dept
EE 382 Processor DesignWinter 98/99Michael Flynn 1 AT Arithmetic Most concern has gone into creating fast implementation of (especially) FP Arith. Under.
Spring 2006EE VLSI Design II - © Kia Bazargan 299 EE 5324 – VLSI Design II Kia Bazargan University of Minnesota Part VII: Floating Point Arithmetic.
UNIVERSITY OF MASSACHUSETTS Dept
CSE 246: Computer Arithmetic Algorithms and Hardware Design Instructor: Prof. Chung-Kuan Cheng Fall 2006 Lecture 8: Division.
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 Arithmetic Integers: signed / unsigned (can overflow) Fixed point (can overflow) Floating point (can overflow, underflow) (Boolean / Character)
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.
Data Representation – Binary Numbers
Computer Arithmetic II Instructor: Mozafar Bag-Mohammadi Spring 2006 University of Ilam.
Integer Conversion Between Decimal and Binary Bases Conversion of decimal to binary more complicated Task accomplished by –Repeated division of decimal.
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.
July 2005Computer Architecture, The Arithmetic/Logic UnitSlide 1 Part III The Arithmetic/Logic Unit.
1 Binary Coded Decimal Presented By Chung Wai Chow.
ECE 8053 Introduction to Computer Arithmetic (Website: Course & Text Content: Part 1: Number Representation.
Computer Arithmetic II Instructor: Mozafar Bag-Mohammadi Ilam University.
June 2007 Computer Arithmetic, Function EvaluationSlide 1 VI Function Evaluation Topics in This Part Chapter 21 Square-Rooting Methods Chapter 22 The CORDIC.
Division Harder Than Multiplication Because Quotient Digit Selection/Estimation Can Have Overflow Condition – Divide by Small Number OR even Worse – Divide.
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.
Lecture 11 Advanced Dividers.
Copyright 2008 Koren ECE666/Koren Part.7b.1 Israel Koren Spring 2008 UNIVERSITY OF MASSACHUSETTS Dept. of Electrical & Computer Engineering Digital Computer.
1 Basic Dividers Lecture 9. Required Reading Chapter 13, Basic Division Schemes 13.1, Shift/Subtract Division Algorithms 13.3, Restoring Hardware Dividers.
ECE/CS 552: Integer Dividers
CSE 246: Computer Arithmetic Algorithms and Hardware Design Instructor: Prof. Chung-Kuan Cheng Fall 2006 Lecture 7 Division.
CSE 8351 Computer Arithmetic Fall 2005 Instructors: Peter-Michael Seidel.
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.
CSE 575 Computer Arithmetic Spring 2003 Mary Jane Irwin (www. cse. psu
William Stallings Computer Organization and Architecture 8th Edition
COMPUTER ARITHMETIC Arithmetic with Signed-2's Complement Numbers
CHAPTER 18 Circuits for Arithmetic Operations
CSE 575 Computer Arithmetic Spring 2003 Mary Jane Irwin (www. cse. psu
CSE 575 Computer Arithmetic Spring 2005 Mary Jane Irwin (www. cse. psu
Integer Multiplication and Division
CSE 575 Computer Arithmetic Spring 2003 Mary Jane Irwin (www. cse. psu
Integer Division.
UNIVERSITY OF MASSACHUSETTS Dept
CSE 575 Computer Arithmetic Spring 2003 Mary Jane Irwin (www. cse. psu
CSE 575 Computer Arithmetic Spring 2003 Mary Jane Irwin (www. cse. psu
Multiplication & Division
Digital Systems Section 14 Registers. Digital Systems Section 14 Registers.
CSE 575 Computer Arithmetic Spring 2005 Mary Jane Irwin (www. cse. psu
Lecture 9 Basic Dividers.
CSE 575 Computer Arithmetic Spring 2003 Mary Jane Irwin (www. cse. psu
CSE 575 Computer Arithmetic Spring 2002 Mary Jane Irwin (www. cse. psu
Radix 2 Sequential Multipliers
CSCI206 - Computer Organization & Programming
ECEG-3202 Computer Architecture and Organization
12/7/
Montek Singh Mon, Mar 28, 2011 Lecture 11
UNIVERSITY OF MASSACHUSETTS Dept
CHAPTER 18 Circuits for Arithmetic Operations
UNIVERSITY OF MASSACHUSETTS Dept
Arithmetic Logic Unit A.R. Hurson Electrical and Computer Engineering Missouri University of Science & Technology A.R. Hurson.
Appendix J Authors: John Hennessy & David Patterson.
UNIVERSITY OF MASSACHUSETTS Dept
Lecture 9 Basic Dividers.
CSE 575 Computer Arithmetic Spring 2003 Mary Jane Irwin (www. cse. psu
Dr. Clincy Professor of CS
Presentation transcript:

CSE 575 Computer Arithmetic Spring 2003 Mary Jane Irwin (www. cse. psu CSE 575 Computer Arithmetic Spring 2003 Mary Jane Irwin (www.cse.psu.edu/~mji) This set of slides needs more work as well.

A Binary Square Root Algorithm Q square root Q0 = 0 0 1 1 1 0 1 1 0 Z radicand = 11810 0 1 q3 = 1 Q1 = 01  101 ? No so choose 0 0 0 1 1 q2 = 0 0 0 0 Q2 = 010  1001 ? Yes so choose 1 0 1 1 0 1 choose radicand digit so that (4Qi + new radicand digit) does not exceed the partial remainder 10^2 + 18 = 118 (base 10) 1 0 0 1 q1 = 1 Q3 = 0101  10101 ? No so choose 0 0 1 0 0 1 0 0 0 0 0 0 q0 = 0 Q4 = 01010 = 1010 1 0 0 1 0 S remainder = 1810

Shift/Subtract Square Root Square root as repeated shifts & subtracts . Q square root . Z fixed point radicand 1  Z < 4 partial remainder array S scaled remainder (Z - Q2)

Restoring Square Root Recursion Notation Z radicand z1z0 . z-1z-2 … z-l (1  Z < 4) Q square root 1 . q-1q-2 … q-l (1  Q < 2) S scaled rem s1s0 . s-1s-2 … s-l (0  S < 4) Basic recurrence S0 = Z – 1, Q0 = 1, Sl = S and Ql = Q Sj = 2Sj-1 – q-j(2Qj-1 + 2-jq-j) where q-j  (0,1) (Qj-1 =  2-kq-k for k=0 to j-1) Qj-1 is the partially developed root up to its –j-1th digit S1 = 2S0 – q-1(2Q0 + 2-1q-1) = 2(Z-1) – q-1 (2*1 + 2-1q-1) The amount subtracted from 2Si-1 is either 2Qj-1 + 2-j if q-j is 1 or 0 if q-j is 0 Write highlighted iteration on the board for reference in later slides

Square Root Digit Selection First perform the trial subtraction STj = 2Sj-1 – (2Qj-1 + 2-j) 0 if STj < 0  Sj = 2Sj-1 q-j = 1 if STj  0  Sj = STj stop when Sj = 0 or after l iterations Really doing if STj < 0 then q-j= 0 & Sj = STj + (2Qj-1 + 2-j) if STj  0 then q-j= 1 & Sj = STj restore op average number of operations in binary n subtracts (one per digit) n/2 add (restores) on average n one bit left shifts 3n/2 add/subtract cycles NO WAY TO PARALLELIZE since quotient digits are formed serially

Binary Square Root Example Z radicand 0 1. 1 1 0 1 1 0 0 0. 1 1 0 1 1 0 S0 = Z-1 q0 = 1 Q0 = 1. 0 1. 1 0 1 1 0 0 1 0. 1 -(2*(1.)+2-1) 1 1. 0 0 1 1 0 0 q-1 = 0 Q1 = 1.0 restore 0 1. 1 0 1 1 0 0 S1 = S0 1 1. 0 1 1 0 0 0 For lecture 1 0. 0 1 -(2*(1.0)+2-2) 0 1. 0 0 1 0 0 0 q-2 = 1 Q2 = 1.01 S2 1 0. 0 1 0 0 0 0 1 0. 1 0 1 -(2*(1.01)+2-3) 1 1. 1 0 1 0 0 0 q-3 = 0 Q3 = 1.010 restore 1 0. 0 1 0 0 0 0 S3 = S2 . . .

Left Shift Serial Square Root Shift left radicand square root Z or S Z or Q scaled remainder q-j 2Qj-1 n bit adder n bits Control sequencer and root select logic  2-jq-j Add/subt sign

Nonrestoring Square Root Can develop in a similar way a nonrestoring square root algorithm where q-j  (-1,1) and the resulting root can be converted on-the-fly to a binary format Expand this next time!

Higher Radix Square Root To speed up square root can use a similar higher radix approach as used in (SRT) division Sj = rSj-1 – q-j(2Qj-1 + r-jq-j) The problem is, as expected, square root digit selection (a table lookup process). With proper care the same lookup table can be used for QDS and RDS (example for base 4) Division: Sj = 4 Sj-1 – q-jD SqRoot: Sj = 4 Sj-1 – q-j(2Qj-1 + 4-jq-j) with q-j=[-2,2] Expand this next time!

Square Root by Convergence Newton-Raphson method f(X) = X2 –Z that has a root at X = Z Basic iteration of Xi+1 = 0.5(Xi + Z/Xi) Requires a division, an addition, a bit right shift Initial guess of X0 = 2 Xi will remain in range 1  Xi <2 Better initial guesses give faster convergence Quadratic convergence from above Many other schemes Find reciprocal of Z and then multiply by Z to obtain Z using f(X) = 1/X2 – Z that has a root at X = 1/Z

Decimal Example Find Z where Z = 2.410 (Z = 1.549 193 . . .) X0 = (read from table) = 1.5 0  10-1 X1 = 0.5(X0 + 2.4/X0) = 1.550 000 000 1  10-2 X2 = 0.5(X1 + 2.4/X1) = 1.549 193 548 2  10-4 For lecture X3 = 0.5(X2 + 2.4/X2) = 1.549 193 338 2  10-8

Nonrestoring Array Square-Rooter z-1 z-2 1 1 xor z-3 z-4 q-1 1 FA z-5 z-6 q-2 1 derived directly from the dot notation for nonrestoring square root the controlled add/subtract cell depend on the sign of the preceding partial remainder z-7 z-8 q-3 1 q-4 s-1 s-2 s-3 s-4 s-5 s-6 s-7 s-8

Key References Agrawal, High-speed arithmetic arrays, IEEE Trans. on Computers, 28(3):215-224, 1979. Ercegovac and Lang, Division and Square Root: Digit Recurrence Algorithms and Implementations, Kluwer, 1994. Montuschi and Mezzalama, A survey of square rooting algorithms, Proc. IEEE, Vol 137, pp. 31-40, 1990. Parhami, Computer Arithmetic, Oxford Univ. Press, 1999. Schwartz and Flynn, Hardware starting approximation methods and its application to the square root operation, IEEE Trans. on Computers, 45(12):1356-1369, 1996. Zurawski and Gosling, Design of a high-speed square root, multiply and divide unit, IEEE Trans. on Computers, 36(1):13-23, 1987.