You are on page 1of 22

CORDIC Algorithm

COordinate Rotation DIgital Computer


Method for Elementary Function Evaluation (e.g.,
sin(z), cos(z), tan
-1
(y))
Originally Used for Real-time Navigation (Volder
1956)
Idea is to Rotate a Vector in Cartesion Plane by
Some Angle
Complexity Comparable to Division
CORDIC Algorithm
Key Ideas
If we have a computationally efficient way of rotating a vector, we can
evaluate cos, sin, and tan1 functions
Rotation by an arbitrary angle is difficult, so we perform psuedorotations
Use special angles to synthesize a desired angle z
z = o
(1)
+ o
(2)
+ . . . + o
(m)
CORDIC Algorithm
Key Ideas
Rotate the vector OE
(i)
with end point at (x
(i)
, y
(i)
) by o
(i)
x
(i+1)
= x
(i)
cos o
(i)
y
(i)
sin o
(i)
= (x
(i)
y
(i)
tan o
(i)
)/(1 + tan
2
o
(i)
)
1/2
y
(i+1)
= y
(i)
cos o
(i)
+ x
(i)
sin o
(i)
= (y
(i)
+ x
(i)
tan o
(i)
)/(1 + tan
2
o
(i)
)
1/2
z
(i+1)
= z
(i)
o
(i)
Goal: eliminate the divisions by (1 + tan2o
(i)
)
1/2
and choose o
(i)
so that
tan o
(i)
is a power of 2
Elimination of Division by (1 + tan2o
(i)
)
1/2

Whereas a real rotation does not change the length R(i) of
the vector, a pseudorotation step increases its length to:
R
(i+1)
= R
(i)
(1 + tan
2
o
(i)
)
1/2
The coordinates of the new end point E'
(I+1)
after
pseudorotation is derived by multiplying the coordinates of
E
(i+1)
by the expansion factor
x
(i+1)
= x
(i)
y
(i)
tan o
(i)

y
(i+1)
= y
(i)
+ x
(i)
tan o
(i)
[Pseudorotation]
z
(i+1)
= z
(i)
o
(i)


Elimination of Division by (1 + tan2o
(i)
)
1/2

Assuming x
(0)
= x, y
(0)
= y, and z
(0)
= z, after m real
rotations by the angles o
(1)
, o
(2)
, . . . , o
(m)
, we have:
x
(m)
= x cos(o
(i)
) y sin(o
(i)
)
y
(m)
= y cos(o
(i)
) + x sin(o
(i)
)
z
(m)
= z (o
(i)
)
After m pseudorotations by the angles o
(1)
, o
(2)
, . . . , o
(m)
:
x
(m)
= K(x cos(o
(i)
) y sin(o
(i)
))
y
(m)
= K(y cos(o
(i)
) + x sin(o
(i)
)) [*]
z
(m)
= z (o
(i)
)
where K = H(1 + tan
2
o
(i)
)
1/2
Basic CORDIC Iterations
Pick o
(i)
such that tan o
(i)
= d
i
2
i
, d
i
e {1, 1}
x
(i+1)
= x
(i)
d
i
y(i)2
i
y
(i+1)
= y
(i)
+ d
i
x(i)2
i
[CORDIC iteration]
z
(i+1)
= z
(i)
d
i
tan
1
2
i
If we always pseudorotate by the same set of angles (with
+ or signs), then the expansion factor K is a constant
that can be precomputed
Example: pseudorotation for 30 degrees
30.0 ~ 45.0 26.6 + 14.0 7.1 + 3.6 + 1.8 0.9
+ 0.4 0.2 + 0.1 = 30.1
e
(i)
= tan
1
2
-i
Basic CORDIC Iteration
CORDIC Rotation Mode
CORDIC Rotation Mode
CORDIC Vectoring Mode
CORDIC Vectoring Mode
CORDIC Hardware
Generalized CORDIC
Rotation Modes
Binary Angular Measurement - BAM
Angle Accumulator can Represent Angles as BAM
Encode d
i
={-1,+1} as Bit Values {0,1}
Example: -1 Represented by 0 and +1 Represented by 1
LSb Represents d
0
Content z=01011
z=+45 +26.6 -14.0 +7.1 -3.6 =61.1
Can Simplify CORDIC Circuitry for Some Modes
May Need BAM encode/decode Can Use Lookup Table
Review - CORDIC - Rotation Mode
Input is Angle, o Initialized in Angle Accumulator
Vector Initialized to Lie on x-axis
Each Iteration d
i
Chosen by Sign of Angle
Attempt to Bring Angle to Zero
Result is x Register Contains ~coso
Result is y Register Contains ~sino
Also Polar to Rectangular if x Register Initialized to
Magnitude
Review - CORDIC - Vector Mode
Input is (Pre-scaled) Vector in (x,y) Registers
Angle, o Initialized to Zero
Each Iteration d
i
Chosen to Move Vector to Lie Along
Positive x-axis (Want to Reduce y Register to Zero)
Result is Original Vector Angle in Angle Accumulator
Can be Used for sin
-1
o and cos
-1
o
Also Rectangular to Polar Conversion
Magnitude in x Register
CORDIC Rotation/Vector Modes
Rotation Mode:
1
1
1
1
2
2
tan(2)
i
i i i i
i
i i i i
i
i i i
x x y d
y y x d
z z d

+

+
=
= +
=
| |
| |
0 0 0 0
0 0 0 0
2
0
cos sin
cos sin
0
1 2
1, 0
1, otherwise
n n
n n
n
n
i
n
i
i
i
x A x z y z
y A y z x z
z
A
z
d

=
=
= +
=
= +
<

=

+

[
Vector Mode:
1
1
1
1
2
2
tan(2)
i
i i i i
i
i i i i
i
i i i
x x y d
y y x d
z z d

+

+
=
= +
=
( )
2 2
0 0
0
0
0
2
0
0
t a n 1
1 2
1, 0
1, o t h e r w i s e
n n
n
n
n
i
n
i
i
i
x A x y
y
y
z z
x
A
y
d

=
= +
=
= +
= +
+ <

[
Rotation Angle Limits
Rotation/Vector Algorithms Limited to 90
Due to Use of o = tan(2
0
) for First Iteration
Several Ways to Extend Range
Can use trig identities to covert the problem to one that is within
the domain of convergence
One Way is to Use Additional Rotation for Angles Outside Range
This Rotation is Initial 90 Rotation
( )
'
'
'
2
1, 0
1, otherwise
i
x d y
y d x
z z d
y
d
t
=
=
= +
+ <

CORDIC Uses
OPERATION MODE INITIALIZE DIRECTION
Sine, Cosine Rotation
x=1/A
n
, y=0, z=o
Reduce z to Zero
Polar to Rect. Rotation x=(1/A
n
)X
mag
, y=0, z=X
phase
Reduce z to Zero
General Rotation Rotation
x=(1/A
n
)x
0
, y=(1/A
n
)y
0
, z=o
Reduce z to Zero
Arctangent Vector x=(1/A
n
)x
0
, y=(1/A
n
)y
0
, z=0 Reduce y to Zero
Vector Magnitude Vector x=(1/A
n
)x
0
, y=(1/A
n
)y
0
, z=0 Reduce y to Zero
Rect. to Polar Vector x=(1/A
n
)x
0
, y=(1/A
n
)y
0
, z=0 Reduce y to Zero
Arcsine, Arccosine Vector x=(1/A
n
), y=0,
arg=sino or coso
Reduce y to Value
in arg Register

Can Use CORDIC For Others Also:
Linear Functions
Hyperbolic Functions
Square Rooting
Logarithms, Exponentials
Iterative CORDIC Structure*
*Taken from A Survey of CORDIC Algorithms for FPGA
Based Computers, R. Andraka, FPGA98
Bit-serial CORDIC Structure*
*Taken from A Survey of CORDIC Algorithms for FPGA
Based Computers, R. Andraka, FPGA98

You might also like