1 / 22

CSE 575 Computer Arithmetic Spring 2003 Mary Jane Irwin (www.cse.psu.edu/~mji)

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

len
Download Presentation

CSE 575 Computer Arithmetic Spring 2003 Mary Jane Irwin (www.cse.psu.edu/~mji)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSE 575Computer ArithmeticSpring 2003Mary Jane Irwin (www.cse.psu.edu/~mji)

  2. 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 • Family of algorithms: rotation, vector mode • circular rotations • linear rotations • hyperbolic rotations

  3. Real Cordic Rotations If vector OEiis rotated about the origin by an angle i, the new vector OEi+1will 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= Yicos i + Xisin i Zi+1= Zi -i Ri O 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

  4. Pseudo Cordic Rotations 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. 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+ Xitan i Zi+1= Zi -i i Ri O

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

  6. Zi+1 zero Choosing the Angles

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

  8. Circular Rotation Mode • Choosing di = sign(Zi) {-1,1}to force Z to 0 gives the rotation mode Cordic iterations Xi+1 = Xi- di Yi2-i Yi+1 = Yi+ di Xi 2-i Zi+1= Zi- di Eiwhere Ei= tan-12-i • After n iterations, when Znis 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

  9. 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

  10. Rotation Example Computing cos 30 (= 0.866 025) and sin 30 (=0.500 000)

  11. 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 Yi2-i Yi+1= Yi+ di Xi2-i Zi+1= Zi- di Eiwhere Ei= tan-12-i • After n iterations, when Ynis 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

  12. Vector Example Computing tan-1 0.414 210 (= 22.499 830)

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

  14. Generalized Cordic • Generalized Cordic defined as Xi+1= Xi-  di Yi2-i Yi+1= Yi+ di Xi2-i Zi+1= Zi - di Ei • Defining  and Eigives  = 1 Circular rotations (basic)Ei= tan-12-i  = 0 Linear rotations Ei= 2-i  = -1 Hyperbolic rotationsEi = tanh-12-i

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

  16.   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

  17. Computes functions cos Z and sin Z X = 1/K and Y = 0 Computes function tan-1 Y X = 1 and Z = 0 Circular Mode ( = 1) • 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

  18. Computes functions multiply and multiply-add Y = 0 Computes functions divide and divide-add Z = 0 Linear Mode ( = 0) • Linear rotation mode Xn= X Yn= Y + X * Z Zn= 0 Rule: Choose di  {-1,1} such that Z  0 • Linear vector mode Xn= X Yn= 0 Zn= Z + Y/X Rule: Choose di  {-1,1} such that Y  0

  19. Computes functions hyperbolic sin and cos X = 1/K’ and Y = 0 Computes functions hyperbolic tanh-1 y X = 1 and Z = 0 Hyperbolic Mode ( = -1) • 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

  20. CORDIC CORDIC CORDIC CORDIC CORDIC CORDIC Cordic Computation Unit

  21. 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)

  22. 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.

More Related