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

Slides:



Advertisements
Similar presentations
Trigonometric Functions
Advertisements

Function Evaluation Using Tables and Small Multipliers CS252A, Spring 2005 Jason Fong.
CSE 246: Computer Arithmetic Algorithms and Hardware Design Instructor: Prof. Chung-Kuan Cheng Fall 2006 Lecture 11 Cordic, Log, Square, Exponential Functions.
ECE 645 – Computer Arithmetic Lecture 11: Advanced Topics and Final Review ECE 645—Computer Arithmetic 4/22/08.
CENG536 Computer Engineering department Çankaya University.
6.6 – TRIG INVERSES AND THEIR GRAPHS
The arc length spanned, or cut off, by an angle is shown next:
Unit 8: Modeling with Trigonometric Functions
Radix Conversion Given a value X represented in source system with radix  s, represent the same number in a destination system with radix  d Consider.
Chapter 1 Trigonometric Functions.
Chapter 3 Arithmetic for Computers. Multiplication More complicated than addition accomplished via shifting and addition More time and more area Let's.
Copyright 2008 Koren ECE666/Koren Part.9b.1 Israel Koren Spring 2008 UNIVERSITY OF MASSACHUSETTS Dept. of Electrical & Computer Engineering Digital Computer.
Hypercomputing With the CORDIC Algorithm
Section 2 Identities: Cofunction, Double-Angle, & Half-Angle
CSE 246: Computer Arithmetic Algorithms and Hardware Design Instructor: Prof. Chung-Kuan Cheng Fall 2006 Lecture 11 Cordic, Log, Square, Exponential Functions.
CSE 246: Computer Arithmetic Algorithms and Hardware Design Instructor: Prof. Chung-Kuan Cheng Winter 2004 Lecture 11 Tuesday, February 24, 2004.
Digital Kommunikationselektronik TNE027 Lecture 3 1 Multiply-Accumulator (MAC) Compute Sum of Product (SOP) Linear convolution y[n] = f[n]*x[n] = Σ f[k]
Spring 2006EE VLSI Design II - © Kia Bazargan 368 EE 5324 – VLSI Design II Kia Bazargan University of Minnesota Part IX: CORDIC Algorithms.
CSE 378 Floating-point1 How to represent real numbers In decimal scientific notation –sign –fraction –base (i.e., 10) to some power Most of the time, usual.
Summer School 2007B. Rossetto1 Trigonometry  Definitions  H.. P O Let OP = OH’ = r > 0, a positive length. Give the definition of: P’. H’. r r.
Unit Circle Definition of Trig Functions. The Unit Circle  A unit circle is the circle with center at the origin and radius equal to 1 (one unit). 
Ch. 21. Square-rootingSlide 1 VI Function Evaluation Topics in This Part Chapter 21 Square-Rooting Methods Chapter 22 The CORDIC Algorithms Chapter 23.
Essential Question: How do we find the non-calculator solution to inverse sin and cosine functions?
The World’s Largest Ferris Wheel
Copyright © 2009 Pearson Education, Inc. CHAPTER 7: Trigonometric Identities, Inverse Functions, and Equations 7.1Identities: Pythagorean and Sum and.
5.5 Circular Functions: Graphs and Properties Mon Nov 10 Do Now Evaluate 1) Sin pi/2 2) Cos 2pi 3) Tan pi/4.
Algebra II TRIG Flashcards
Final Exam Review Questions 3 Days
Solving Trigonometric Equations MATH Precalculus S. Rook.
Identities The set of real numbers for which an equation is defined is called the domain of the equation. If an equation is true for all values in its.
Department of Computer Systems Engineering, N-W.F.P. University of Engineering & Technology. DSP Presentation Computing Multiplication & division using.
Implementation of MAC Assisted CORDIC engine on FPGA EE382N-4 Abhik Bhattacharya Mrinal Deo Raghunandan K R Samir Dutt.
4.2 Day 1 Trigonometric Functions on the Unit Circle Pg. 472 # 6-10 evens, evens, 46, 54, 56, 60 For each question (except the 0 o, 90 o, 180 o,
6.2.2 The Trigonometric Functions. The Functions Squared sin 2 (  ) = sin(  ) 2 = sin(  ) * sin(  ) sin 2 (  ≠ sin (  2 ) = sin (  *  )
07/19/2005 Arithmetic / Logic Unit – ALU Design Presentation F CSE : Introduction to Computer Architecture Slides by Gojko Babić.
Section 4.2 Trigonometric Functions: The Unit Circle
Section 7.5 Unit Circle Approach; Properties of the Trigonometric Functions.
Copyright © Cengage Learning. All rights reserved. 7 Techniques of Integration.
Chapter 4 Trigonometric Functions Inverse Trigonometric Functions Objectives:  Evaluate inverse sine functions.  Evaluate other inverse trigonometric.
June 2007 Computer Arithmetic, Function EvaluationSlide 1 VI Function Evaluation Topics in This Part Chapter 21 Square-Rooting Methods Chapter 22 The CORDIC.
Gradients of Inverse Trig Functions Use the relationship Ex y = sin –1 x This is the same as siny = x ie sin both sides Sox = siny Differentiate this expression.
ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU CORDIC (Coordinate rotation digital computer) Ref: Y. H. Hu, “CORDIC based VLSI architecture.
4.3 Trigonometry Extended: The Circular Functions
CORDIC Algorithm COordinate Rotation DIgital Computer Method for Elementary Function Evaluation (e.g., sin(z), cos(z), tan -1 (y)) Originally Used for.
CORDIC-Based Processor
CORDIC Algorithm COordinate Rotation DIgital Computer
ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU CORDIC (COordinate Rotation DIgital Computer) For Advanced VLSI and VLSI Signal Processing.
CSE477 L21 Multiplier Design.1Irwin&Vijay, PSU, 2002 CSE477 VLSI Digital Circuits Fall 2002 Lecture 21: Multiplier Design Mary Jane Irwin (
SECTION 5.7 HYPERBOLIC FUNCTIONS. P2P25.7 INVERSE FUNCTIONS  Certain combinations of the exponential functions e x and e – x arise so frequently in mathematics.
Computer Graphics Mathematical Fundamentals Lecture 10 Taqdees A. Siddiqi
Trigonometric Functions: The Unit Circle  Identify a unit circle and describe its relationship to real numbers.  Evaluate trigonometric functions.
PreCalculus 89-R 8 – Solving Trig Equations 9 – Trig Identities and Proof Review Problems.
CORDIC (Coordinate rotation digital computer)
Dynamic Circuit Specialization of a CORDIC Processor Eric Keller Nov. 7, 2000 SPIE Photonics East.
CSE 575 Computer Arithmetic Spring 2003 Mary Jane Irwin (www. cse. psu
CORDIC (Coordinate rotation digital computer)
Para-CORDIC: Parallel CORDIC Rotation Algorithm and Architecture
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
CSE 575 Computer Arithmetic Spring 2003 Mary Jane Irwin (www. cse. psu
CSE 575 Computer Arithmetic Spring 2003 Mary Jane Irwin (www. cse. psu
CSE 575 Computer Arithmetic Spring 2005 Mary Jane Irwin (www. cse. psu
CSE 575 Computer Arithmetic Spring 2003 Mary Jane Irwin (www. cse. psu
CSE 575 Computer Arithmetic Spring 2002 Mary Jane Irwin (www. cse. psu
Arithmetic Logical Unit
How to represent real numbers
7 Trigonometric Identities and Equations
UNIVERSITY OF MASSACHUSETTS Dept
CSE 575 Computer Arithmetic Spring 2003 Mary Jane Irwin (www. cse. psu
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)

Cordic Algorithms A convergence method for evaluating trigonometric (and other) functions if a unit-length vector with end point at (X,Y) = (1,0) is rotated by an angle Z, its new end point will be at (X,Y) = (cos Z, sin Z) simple hardware - shifters, adders, lookup table COordinate Rotations DIgital Computer Family of algorithms: rotation, vector mode circular rotations linear rotations hyperbolic rotations

Real Cordic Rotations If vector OEi is rotated about the origin by an angle i, the new vector OEi+1 will have the coordinates Ei+1 (Xi+1, Yi+1) Ei Ri+1 Real rotation: Ei+1 (Xi, Yi) i Xi+1 = Xi cos i - Yi sin i Yi+1 = Yi cos i + Xi sin i Zi+1 = Zi - i Ri O The problem is that the iterations are not simple operations - have two multiply operations in each = 4 multipliers, plus have to store a lot of constants (cos’s alpha i’s and sin’s of alpha i’s) The variable Z allows us to keep track of the total rotation over several steps. If Z0 is the initial rotation goal and if the i angles are selected at each step such that after n iterations Zn tends to 0, then En will be the end point after rotation by angle Z0

Pseudo Cordic Rotations Pseudo rotations increase the vector length to Ri+1 = Ri(1 + tan2i)1/2 E’i+1 (Xi+1, Yi+1) Ri+1 Pseudo rotation: E’i+1 Ei (Xi, Yi) Xi+1 = Xi - Yi tan i Yi+1 = Yi + Xi tan i Zi+1 = Zi - i i Ri O Now have simpler operations - at first glance looks like two multipliers and a table with the tan alpha values. The R term simplifies since the expansion factor is a constant for a constant set of angles - that is the real key. So, if we have a constant set of angles, we know the tan alpha values to store (and they are a relatively small set). Additionally, if we choose the alpha’s correctly, we can simplify the multiplications to shift (and add) operations! (a + tan2a(i))1/2 = 1/cos a(i) Hi,      I downloaded your CSE 757 CORDIC PPS-turned-PDF as guided by Google. It helped me understand CORDIC better. However, there is an error on slide 4, the squared term within the expansion faction K should be alpha[i]^2 without calculating any tangent.    Ernesto (ernestox@blackwater.dynip.com) Expansion factor K = (1 + tan2 i)1/2 depends on the rotation angles 1 ,2 …, n. If we always rotate by the same angles, K is a constant.

Basic Cordic Rotations To simplify pseudo rotations, pick i such that tan i = di 2-i where di  {-1,1}. Then Xi+1 = Xi - di Yi 2-i Yi+1 = Yi + di Xi 2-i Zi+1 = Zi - di tan-12-i Computation of Xi+1 and Yi+1 requires an i-bit right shift and an add/subtract; Zi+1 only requires an add/subtract and one table lookup Precompute and store the function tan-12-i

Choosing the Angles i i = 2-i Ei=tan-12-i di Zi - diEi = Zi+1 1.000 000 45.000000 1 30.00 – 45.00 = -15.00 0.500000 26.565051 -1 -15.00 + 26.57 = 11.57 2 0.250000 14.036243 11.57 – 14.04 = -2.47 3 0.125000 7.125016 -2.47 + 7.13 = 4.66 4 0.062500 3.576334 4.66 – 3.58 = 1.08 5 0.031250 1.789910 1.08 -1.79 = -0.71 6 0.015625 0.895174 -0.71 + 0.90 = 0.19 7 0.007813 0.447614 0.19 - 0.45 = -0.26 8 0.003906 0.223811 -0.26 + 0.22 = -0.04 9 0.001953 0.111906 -0.04 + 0.11 = 0.07 Zi+1  zero

Rotating the Angles Illustration of the first three rotations for a Z of 30 30 O (X0, Y0) for class handout

Rotating the Angles Illustration of the first three rotations for a Z of 30 30 O (X0, Y0) -45 (X1, Y1) (X2, Y2) +26.6 (X3, Y3) -14 for lecture

Circular Rotation Mode Choosing di = sign(Zi)  {-1,1} to force Z to 0 gives the rotation mode Cordic iterations Xi+1 = Xi - di Yi 2-i Yi+1 = Yi + di Xi 2-i Zi+1 = Zi - di Ei where Ei = tan-12-i After n iterations, when Zn is sufficiently close to 0, then we have Z = i and Xn = K(X cos Z - Y sin Z) where K = 1.646 760 258 … Yn = K(Y cos Z + X sin Z) Zn = 0 Rule: Choose di  {-1,1} such that Z  0 Computes cos Z and sin Z by starting with X = 1/K = 0.607 252 935 … and Y = 0 For k bits of precision, run it k iterations since for large i > k, tan-12-i  2-i

Convergence Domain Convergence of Z to 0 happens because each angle is more than half the previous angle. The domain of convergence is 0  Z  99.7 which is the sum of all the angles given in slide 6 Outside this range, we can use trig identities to convert to the range cos (Z  2j) = cos Z sin (Z  2j) = sin Z cos (Z - ) = - cos Z sin (Z - ) = - sin Z transformations are particularly easy if angles are represented and manipulated in multiples of pi radians E.g., z = 0.2pi radian or 36degrees gives a domain of convergences of -1/2 to +1/2

Rotation Example Computing cos 30 (= 0.866 025) and sin 30 (=0.500 000) i di Xi+1  cos Yi+1  sin Zi+1  0 1/K = 0.607 253 0.000 000 30.000 000 1 0.607 253 -15.000 000 -1 0.910 880 0.303 627 11.565 051 2 0.834 973 0.531 347 -2.471 192 3 0.901 391 0.426 975 4.653 824 4 0.874 705 0.483 312 1.077 490 5 0.859 602 0.510 647 -0.712 420 6 0.867 581 0.497 216 0.182 754 7 0.863 697 0.503 994 -0.264 860 8 0.865 666 0.500 620 -0.041 049 . . .

Circular Vector Mode Choosing di = - sign(Xi Yi)  {-1,1} to force Y to 0 gives the vector mode Cordic iterations Xi+1 = Xi - di Yi 2-i Yi+1 = Yi + di Xi 2-i Zi+1 = Zi - di Ei where Ei = tan-12-i After n iterations, when Yn is sufficiently close to 0, then we have tan (i) = -Y/Z Xn = K (X2 + Y2) where K = 1.646 760 258 … Yn = 0 Zn = Z + tan-1 (Y/X) Rule: Choose di  {-1,1} such that Y  0 Computes tan-1 Y by starting with X = 1 and Z = 0 For k bits of precision, run it k iterations since for large i > k, tan-12-i  2-i

Vector Example Computing tan-1 0.414 210 (= 22.499 830) di Xi+1  K(X2 + Y2) Yi+1  0 Zi+1  tan-1 1.000 000 0.414 210 0.000 000 -1 1.414 210 -0.585 790 45.000 000 1 1.707 105 0.121 315 18.434 949 2 1.737 434 -0.305 461 32.471 192 3 1.775 617 -0.088 282 25.346 176 4 1.781 135 0.022 694 21.769 842 5 1.781 844 -0.032 966 23.559 752 6 1.782 359 -0.005 125 22.664 578 7 1.782 399 0.008 800 22.216 964 8 1.782 433 0.000 184 22.440 775 . . . Need to check answers for bugs !!!

Circular Cordic Hardware X  shift Xi+1 = Xi – di Yi 2-i i counter  shift Yi+1 = Yi – di Xi 2-i Y lookup table stores values of tan-1 2-i Z  lookup table Zi+1 = Zi – di Ei values of Ei= tan-12-i di control

Generalized Cordic Generalized Cordic defined as Xi+1 = Xi -  di Yi 2-i Yi+1 = Yi + di Xi 2-i Zi+1 = Zi - di Ei Defining  and Ei gives  = 1 Circular rotations (basic) Ei = tan-12-i  = 0 Linear rotations Ei = 2-i  = -1 Hyperbolic rotations Ei = tanh-12-i

Generalized Rotations 2(area EOF) angle EOF = --------------- (OW)2 2(area AOB) angle AOB = -------------- (OU)2 U A B  = 1 W E F  = -1 O  = 0 V vector OV

Enhanced Cordic Hardware  X X Xi+1 = Xi – di Yi 2-i shift i counter  shift Yi+1 = Yi + di Xi 2-i Y Y Zi+1 = Zi - di Ei Z  Z Ei lookup table (tan-12-i, 2-i, tanh-12-i)  di control

Circular Mode ( = 1) Circular vector mode Circular rotation mode Xn = K(X cos Z - Y sin Z) Yn = K(Y cos Z + X sin Z) Zn = 0 Rule: Choose di  {-1,1} such that Z  0 Circular vector mode Xn = K(X2 + Y2)1/2 Yn = 0 Zn = Z + tan-1 (Y/X) Rule: Choose di  {-1,1} such that Y  0 Computes functions cos Z and sin Z X = 1/K and Y = 0 Computes function tan-1 Y X = 1 and Z = 0

Linear Mode ( = 0) Linear vector mode Linear rotation mode Xn = X Yn = Y + X * Z Zn = 0 Rule: Choose di  {-1,1} such that Z  0 Linear vector mode Yn = 0 Zn = Z + Y/X Rule: Choose di  {-1,1} such that Y  0 Computes functions multiply and multiply-add Y = 0 End point of the vector is kept on the line x = x(0) and the vector length is defined by R(i) = x(i) Hence the true length of OV of the scaling factor is 1 (pseudorotations are true linear rotations) Converges trivially for suitably restricted values of z (rotation) or y (vector) Computes functions divide and divide-add Z = 0

Hyperbolic Mode ( = -1) Hyperbolic vector mode Hyperbolic rotation mode Xn = K’(X cosh Z + Y sinh Z) Yn = K’(Y cosh Z + X sinh Z) Zn = 0 Rule: Choose di  {-1,1} such that Z  0 K’ = 0.828 159 360 … Hyperbolic vector mode Xn = K’(X2 - Y2)1/2 Yn = 0 Zn = Z + tanh-1 (Y/X) Rule: Choose di  {-1,1} such that Y  0 Computes functions hyperbolic sin and cos X = 1/K’ and Y = 0 Vector length actually shrinks because cosh a(i) > 1 More difficult convergence guarantee – for details see book section 22.4 By repeating iterations 4, 13, 40, 121, …, j, 3j+1 (K’ has been computed to take these extra iterations into account) then convergence is guaranteed for |z| < 1.13 (rotation) or |y| < 0.81 (vector) Computes functions hyperbolic tanh-1 y X = 1 and Z = 0

Cordic Computation Unit Rotation mode: di=sign(Zi); Zi0 Vector mode: di= -sign(Xi  Yi); Yi0 Ciclr  = 1 Ei = tan-12-i X K(X cosZ – Y sinZ) Y K(Y cosZ + X sinZ) Z 0 For cos & sin, set X=1/K, Y=0 tanZ=sinZ/cosZ X K (X2 + Y2) Y 0 Z Z + tan-1(Y/X) For tan-1, set X=1, Z=0 cos-1W=tan-1[(1-W2)/W];sin-1W=tan-1[W/(1-W2)] Linear  = 0 Ei = 2-i X X Y Y + X*Z For multiply, set Y=0 X X Y 0 Z Z + Y/X For divide, set Z=0 Hprblc  = -1 tanh-1 2-i X K’(X coshZ – Y sinhZ) Y K’(Y coshZ + X sinhZ) For cosh & sinh, set X=1/K’, Y=0 tanhZ=sinhZ/coshZ; Wt=Et lnW Ez=sinhZ+coshZ X K’ (X2 - Y2) Y 0 Z Z + tanh-1(Y/X) For tanh-1, set X=1, Z=0 cosh-1W=ln[W+(1-W2)];sinh-1W=ln[W+(1+W2)] lnW=2tanh-1|(W-1)/(W+1)|;W=((W+¼)2-(W-¼)2) In executing the iterations for  = -1, steps 4, 13, 40, 121, …, j, 3j+1, … must be repeated. CORDIC CORDIC CORDIC CORDIC CORDIC CORDIC

Cordic Summary Can compute virtually all trig functions of common interest When the number of iterations is fixed, K and K’ are constants Thus, we can not stop computing if Z (or Y) becomes 0 (except when  = 0); we always need k iterations for k digits of precision Cordic can be extended to higher radices (e.g., for base 4, di{-2,-1,1,2} and the number of iterations will be cut in half with essentially the same hardware)

Key References Duprat and Muller, The CORDIC algorithm: New results for fast VLSI implementation, IEEE Trans. on Computers, 42(2):168-178, 1993. Parhami, Computer Arithmetic, Oxford Univ. Press, 1999. Phatak, Double step branching CORDIC, IEEE Trans. on Computers, 47(5)587-603, May 1998. Vachss, The CORDIC magnification function, IEEE Micro, 7(5):83-83, Oct. 1987. Volder, The CORDIC trigonometric computing technique, IRE Trans. Elecronic Computers, Vol 8, pp. 330-335, Sept. 1959. Walther, A unified algorithm for elementary functions, Proc. Spring Joint Computer Conf, pp. 379-385, 1971.