Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
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 tan–1 functions
Rotation by an arbitrary angle is difficult, so we perform psuedorotations
Use special angles to synthesize a desired angle z
z = (1) + (2) + . . . + (m)
CORDIC Algorithm
Key Ideas
Rotate the vector OE (i) with end point at (x (i), y (i)) by (i)
x (i+1) = x (i)cos (i)– y (i) sin (i) = (x (i) – y (i) tan (i))/(1 + tan2(i))1/2
y (i+1) = y (i) cos (i) + x (i) sin (i) = (y (i) + x (i) tan (i))/(1 + tan2(i) ) 1/2
z (i+1) = z (i) – (i)
Goal: eliminate the divisions by (1 + tan2(i)) 1/2 and choose (i) so that
tan (i) is a power of 2
Elimination of Division by (1 + tan2(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 + tan2(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 (i)
y (i+1) = y (i) + x (i) tan (i) [Pseudorotation]
z (i+1) = z (i) – (i)
Elimination of Division by (1 + tan2(i))1/2

Assuming x(0) = x, y (0) = y, and z (0) = z, after m real


rotations by the angles (1), (2), . . . , (m), we have:
x(m) = x cos((i))– y sin((i))
y(m) = y cos((i)) + x sin((i))
z(m) = z – ((i))
After m pseudorotations by the angles (1), (2), . . . , (m):
x(m) = K(x cos((i))– y sin((i)))
y(m) = K(y cos((i)) + x sin((i))) [*]
z(m) = z – ((i))
where K = (1 + tan2(i))1/2
Basic CORDIC Iterations
Pick (i) such that tan (i) = di 2 –i, di {–1, 1}
x(i+1) = x(i) – di y(i)2–i
e (i) = tan –1 2-i
y (i+1)
=y (i)
+ di x(i)2 [CORDIC iteration]
–i

z (i+1) = z (i) – di 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
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 di={-1,+1} as Bit Values {0,1}

• Example: -1 Represented by 0 and +1 Represented by 1

• LSb Represents d0

• 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,  – Initialized in Angle Accumulator


• Vector Initialized to Lie on x-axis
• Each Iteration di Chosen by Sign of Angle
• Attempt to Bring Angle to Zero
• Result is x Register Contains ~cos
• Result is y Register Contains ~sin
• Also Polar to Rectangular if x Register Initialized to
Magnitude
Review - CORDIC - Vector Mode

• Input is (Pre-scaled) Vector in (x,y) Registers


• Angle,  – Initialized to Zero
• Each Iteration di 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 and cos-1
• Also Rectangular to Polar Conversion
• Magnitude in x Register
CORDIC – Rotation/Vector Modes
xn  An  x0 cos z0  y0 sin z0 
• Rotation Mode: yn  An  y0 cos z0  x0 sin z0 
zn  0
xi 1  xi  yi  d i  2  i n

i An   1  2 2i
yi 1  yi  xi  d i  2 i 0

1 i  1, zi  0
zi 1  zi  d i  tan (2 ) di  
 1, otherwise

• Vector Mode:
2 2
xn  An x0  y0
yn  0
xi 1  xi  yi  d i  2  i
i
zn  z0  tan  1  x
y0
0
yi 1  yi  xi  d i  2 n
An   1  2 2i
zi 1  zi  d i  tan 1 (2  i ) i 0

 1, yi  0
di  
 1, otherwise
Rotation Angle Limits
• Rotation/Vector Algorithms Limited to 90
• Due to Use of  = tan(20) 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
x '  d  y
y'  d x
z'  z  d    2
 1, y  0
di  
 1, otherwise
CORDIC Uses

OPERATION MODE INITIALIZE DIRECTION


Sine, Cosine Rotation x=1/An, y=0, z= Reduce z to Zero
Polar to Rect. Rotation x=(1/An)Xmag, y=0, z=Xphase Reduce z to Zero
General Rotation Rotation x=(1/An)x0, y=(1/An)y0, z= Reduce z to Zero
Arctangent Vector x=(1/An)x0, y=(1/An)y0, z=0 Reduce y to Zero
Vector Magnitude Vector x=(1/An)x0, y=(1/An)y0, z=0 Reduce y to Zero
Rect. to Polar Vector x=(1/An)x0, y=(1/An)y0, z=0 Reduce y to Zero
Arcsine, Arccosine Vector x=(1/An), y=0, Reduce y to Value
arg=sin  or cos 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, FPGA’98
Bit-serial CORDIC Structure*

*Taken from “A Survey of CORDIC Algorithms for FPGA


Based Computers”, R. Andraka, FPGA’98

You might also like