What is the CORDIC Algorithm and How Does it Work?

  • Thread starter Thread starter Greg Bernhardt
  • Start date Start date
  • Tags Tags
    Algorithm Method
Click For Summary
SUMMARY

The CORDIC (COordinate Rotation DIgital Computer) algorithm, introduced by Jack E. Volder in 1959, efficiently computes hyperbolic and trigonometric functions using only addition, subtraction, bit shifts, and table lookups, making it ideal for systems without hardware multipliers. The algorithm operates by rotating a vector in a complex plane to determine sine and cosine values, utilizing precomputed angles and a scaling factor. With approximately 40 iterations, CORDIC achieves results accurate to the 10th decimal place, significantly simplifying the computation of trigonometric functions in digital circuits.

PREREQUISITES
  • Understanding of basic trigonometric functions
  • Familiarity with binary arithmetic and bit manipulation
  • Knowledge of fixed-point representation
  • Basic concepts of digital circuit design
NEXT STEPS
  • Explore the implementation of CORDIC in hardware using FPGA or ASIC designs
  • Study the mathematical derivation of the CORDIC rotation matrix
  • Learn about fixed-point arithmetic and its applications in embedded systems
  • Investigate performance comparisons between CORDIC and traditional multiplication methods
USEFUL FOR

Engineers, computer scientists, and developers focused on digital signal processing, embedded systems, and anyone interested in efficient computation of trigonometric functions without hardware multipliers.

Messages
19,852
Reaction score
10,829
Definition/Summary

CORDIC (digit-by-digit method, Volder's algorithm) (stands for COordinate Rotation DIgital Computer) is a simple and efficient algorithm to calculate hyperbolic and trigonometric functions. It is commonly used when no hardware multiplier is available as the only operations it requires are addition, subtraction, bitshift and table lookup.

Equations



Extended explanation

CORDIC revolves around the idea of "rotating" the phase of a complex number, by multiplying it by a succession of constant values. However, the multiplies can all be powers of 2, so in binary arithmetic they can be done using just shifts and adds; no actual multiplier is needed.

This explanation shows how to use CORDIC in rotation mode to calculate sine and cosine of an angle, and assumes the desired angle is given in radians and represented in a fixed point format. To determine the sine or cosine for an angle β, the y or x coordinate of a point on the unit circle corresponding to the desired angle must be found. Using CORDIC, we would start with the vector v0:

v_0 = \left(\begin{array}{c} 1 \\ 0 \end{array}\right)

In the first iteration, this vector would be rotated 45° counterclockwise to get the vector v1. Successive iterations will rotate the vector in one or the other direction by size decreasing steps, until the desired angle has been achieved. Step i size is Artg(1/(2(i-1))) where i 1,2,3,….
An illustration of the CORDIC algorithm in progress.

More formally, every iteration calculates a rotation, which is performed by multiplying the vector vi − 1 with the rotation matrix Ri:
<br /> v_{i} = R_{i}v_{i-1}\ <br />
The rotation matrix R is given by:
<br /> R_{i} = \left( \begin{array}{rr} \cos \gamma_{i} &amp; -\sin \gamma_{i} \\ \sin \gamma_{i} &amp; \cos \gamma _{i}\end{array} \right) <br />
Using the following two trigonometric identities
<br /> \begin{align} \cos \alpha &amp; = &amp; {1 \over \sqrt{1 + \tan^2 \alpha}} \\ \sin \alpha &amp; = &amp; {{\tan \alpha} \over \sqrt{1 + \tan^2 \alpha}} \end{align} <br />
the rotation matrix becomes:
<br /> R_{i} = {1 \over \sqrt{1 + \tan^2 \gamma_{i}}} \begin{pmatrix} 1 &amp; -\tan \gamma_{i} \\ \tan \gamma_{i} &amp; 1 \end{pmatrix} <br />
The expression for the rotated vector vi = Rivi − 1 then becomes:
<br /> v_{i} = {1 \over \sqrt{1 + \tan^2 \gamma_{i}}} \begin{pmatrix} x_{i-1} &amp;-&amp; y_{i-1} \tan \gamma_{i} \\ x_{i-1} \tan \gamma_{i} &amp;+&amp; y_{i-1} \end{pmatrix} <br />
where xi − 1 and yi − 1 are the components of vi − 1. Restricting the angles γi so that tanγi takes on the values \pm 2^{-i} the multiplication with the tangent can be replaced by a division by a power of two, which is efficiently done in digital computer hardware using a bit shift. The expression then becomes:

v_{i} = K_{i}\begin{pmatrix} x_{i-1} &amp;-&amp; \sigma_{i} 2^{-i} y_{i-1} \\ \sigma_{i} 2^{-i} x_{i-1} &amp;+&amp; y_{i-1} \end{pmatrix} <br />
where
<br /> K_i = {1 \over \sqrt{1 + 2^{-2i}}} <br />
and σi can have the values of −1 or 1 and is used to determine the direction of the rotation: if the angle βi is positive then σi is 1, otherwise it is −1.

We can ignore Ki in the iterative process and then apply it afterward by a scaling factor:
<br /> K(n) = \prod_{i=0}^{n-1} K_i = \prod_{i=0}^{n-1} 1/\sqrt{1 + 2^{-2i}} <br />
which is calculated in advance and stored in a table, or as a single constant if the number of iterations is fixed. This correction could also be made in advance, by scaling v0 and hence saving a multiplication. Additionally it can be noted that

K = \lim_{n \to \infty}K(n) \approx 0.6072529350088812561694 [3]<br />
to allow further reduction of the algorithm's complexity. After a sufficient number of iterations, the vector's angle will be close to the wanted angle β. For most ordinary purposes, 40 iterations (n = 40) is sufficient to obtain the correct result to the 10th decimal place.

The only task left is to determine if the rotation should be clockwise or counterclockwise at every iteration (choosing the value of σ). This is done by keeping track of how much we rotated at every iteration and subtracting that from the wanted angle, and then checking if βn + 1 is positive and we need to rotate clockwise or if it is negative we must rotate counterclockwise in order to get closer to the wanted angle β.

\beta_{i} = \beta_{i-1} - \sigma_i \gamma_i. \quad \gamma_i = \arctan 2^{-i},<br />
The values of γn must also be precomputed and stored. But for small angles, arctan(γn) = γn in fixed point representation, reducing table size.

As can be seen in the illustration above, the sine of the angle β is the y coordinate of the final vector vn, while the x coordinate is the cosine value.

* This entry is from our old Library feature. If you know who wrote it, please let us know so we can attribute a writer. Thanks!
 
Mathematics news on Phys.org
The CORDIC algorithm was presented in 1959 by Jack E. Volder. In the original version, it was thus possible to form trigonometric functions such as sine, cosine and tangent as well as the multiplication and division of numbers solely by the additions and shift operations (shift-and-add operations) which can be easily implemented in digital circuits. Shift operations to the numerical base 2 are very easy to implement in digital circuits by appropriate interconnection.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 8 ·
Replies
8
Views
1K
  • · Replies 30 ·
2
Replies
30
Views
2K
Replies
8
Views
3K