General CORDIC Description (1A)
Copyright (c) 2010, 2011, 2012 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License". Please send corrections (or suggestions) to youngwlim@hotmail.com. This document was produced by using OpenOffice and Octave.
CORDIC Background 1. CORDIC FAQ, G. R. Griffin, www.dspguru.com/info/faqs/cordic2.htm 1A General 3
Complex Multiplication Given Complex Value Rotation Value Rotated Complex Value C = R = I r j Q r C ' = ' ' C ' = C R ' ' = I r j Q r = I r Q c Q r I r Q r I r j Q r C = r c ϕ c R = r r ϕ r C' = r c r r (ϕ c +ϕ c ) 1A General 4
Adding / Subtracting Phase To add R' phase to C C ' = C R ' ' = I r j Q r = I r Q c Q r I r Q r I r j Q r To sub R' phase to C C ' = C R ' ' = I r j Q r = I r Q c Q r I r Q r I r j Q r 1A General 5
Adding / Subtracting 90 Degrees To add R' phase to C C ' = C ( + j ) ' ' = 0 j = Q c j 0 j To sub R' phase to C C ' = C ( j ) ' ' = 0 j = Q c j 0 j 1A General 6
Elementary Angle: tan -1 (k l ) tan θ l = 1 2 l = k l θ l = tan 1 (2 l ) = tan 1 (k l ) j magnitude l = 0 1 j 2 0 θ 0 = tan 1 (2 0 ) = 45.00000 1+k l 2 = 1+2 2 l l = 1 1 j 2 1 θ 1 = tan 1 (2 1 ) = 26.56505 l = 2 l = 3 l = 4 1 1 j 2 2 1 j 2 3 1 j 2 4 θ 2 θ 3 θ 4 = tan 1 (2 2 ) = 14.03624 = tan 1 (2 3 ) = 7.12502 = tan 1 (2 4 ) = 3.57633 Represent arbitrary angle θ in terms of ±θ 0, ±θ 1, ±θ 2, ±θ 3,, ±θ l, ( k l = tan θ l = 1 2 l, l = 0,1, 2, ) 1A General 7
Adding / Subtracting tan -1 (k l ) To add R' phase to C C ' = C (1 + j k l ) 1 j k ' ' = (1 + j k l ) = ( k l Q c ) + j (Q c + k l ) = ( 2 l Q c ) + j (Q c + 2 l ) To sub R' phase to C C ' = C (1 j k l ) 1 j k ' ' = (1 j k l ) = ( + k l Q c ) + j (Q c k l ) = ( + 2 l Q c ) + j (Q c 2 l ) θ l = tan 1 (k l ) = tan 1 (2 l ) k l = 1 2 l, l = 0,1,2, 1A General 8
Phase and Magnitude of 1 + jk l (1) Cumulative Magnitude L k = 1 2 l R = 1 + j k Phase of R Magnitude of R CORDIC Gain 0 1.0 1 + j1.0 45º 1.41421356 1.414213562 1 0.5 1 + j0.5 26.56505º 1.11803399 1.581138830 2 0.25 1 + j0.25 14.03624º 1.03077641 1.629800601 3 0.125 1 + j0.125 7.12502º 1.00778222 1.642484066 4 0.0625 1 + j0.0625 3.57633º 1.00195122 1.645688916 5 0.03125 1 + j0.03125 1.78991º 1.00048816 1.646492279 6 0.015625 1 + j0.015625 0.89517º 1.00012206 1.646693254 7 0.007813 1 + j0.007813 0.44761º 1.00003052 1.646743507 1.647 R = 1 + j k l k l = 1/2 l l = 0,1, 2, R = 1 2 + k l 2 = 1+2 2 l > 1.0 1A General 9
Phase and Magnitude of 1 + jk l (2) Represent arbitrary angle θ in terms of ±θ 0, ±θ 1, ±θ 2, ±θ 3,, ±θ l, ( k l = tan θ l = 1 2 l, l = 0,1, 2, ) Binary Search Shift and Add No multiplier θ 0 = tan 1 (2 0 ) = θ 1 = tan 1 (2 1 ) = θ 2 = tan 1 (2 2 ) = θ 3 = tan 1 (2 3 ) = θ 4 = tan 1 (2 4 ) = θ 5 = tan 1 (2 5 ) = θ 6 = tan 1 (2 6 ) = θ 7 = tan 1 (2 7 ) = Phase of R 45º 26.56505º 14.03624º 7.12502º 3.57633º 1.78991º 0.89517º 0.44761º 1 2 1 2 1 2 1 2 1 2 1 2 1 2 > 92º θ θ [-180, +180] R = 0 ± j [-90, +90] R = 1 ± j k l 4 or more rotations 45º + 26.56505º + 14.03624º + 7.12502º = 92.726º > 92º 1A General 10
Phase and Magnitude of 1 + jk l (3) R = 1 ± j k l Magnitude of R 1 2 + k l 2 Cumulative Magnitude > 1.0 CORDIC Gain Iteration R 0 = 1 ± j (1/2 0 ) R 1 = 1 ± j (1/2 1 ) R 2 = 1 ± j (1/2 2 ) R 3 = 1 ± j (1/2 3 ) R 4 = 1 ± j (1/2 4 ) R 5 = 1 ± j (1/2 5 ) 1 2 + 1 2 = 1 2 + (1/2) 2 = 1 2 + (1/2 2 ) 2 = 1 2 + (1/2 3 ) 2 = 1 2 + (1/2 4 ) 2 = 1 2 + (1/2 5 ) 2 = 1.41421356 1.11803399 1.03077641 1.00778222 1.00195122 1.00048816 1.414213562 1.581138830 1.629800601 1.642484066 1.645688916 1.646492279 R 6 = 1 ± j (1/2 6 ) 1 2 + (1/2 6 ) 2 = 1.00012206 1.646693254 R 7 = 1 ± j (1/2 7 ) 1 2 + (1/2 7 ) 2 = 1.00003052 1.646743507 The actual CORDIC Gain depends on the number of iterations 1.647 For each iteration, the corresponding is always used (either +θ i or θ i ) θ i The magnitude is growing for correction, multiply by 0.6073 = 1 / 1.647 1A General 11
Vector Mode Calculating Magnitude vector magnitude? Vectoring Mode C = I C= + jq c + j0 c Rotate until accumulated angle is 0 Accumulator View mag x 1.647 Each iteration, the magnitude is increased by 1 2 + k l 2 CORDIC Gain (cumulative gain) 1.647 = 0.607 1 magnitude x 1.647 magnitude x 0.607 To compensate, multiply by 0.607 Can t perform this gain adjustment by simple shift and add This adjustment can be done in other part of a system when relative magnitude is enough 1A General 12
Vector Mode Calculating Phase vector phase? Vectoring Mode C = I C= + jq c + j0 c Rotate until accumulated angle is 0 0 = tan 1 2 0 = 1 = tan 1 2 1 = 2 = tan 1 2 2 = 3 = tan 1 2 3 = 4 = tan 1 2 4 = 5 = tan 1 2 5 = Phase of R 45º 26.56505º 14.03624º 7.12502º 3.57633º 1.78991º Accumulator View mag x 1.647 θ ±θ 0 ±θ 1 ±θ 2 ±θ 3 = 0 Accumulate each rotating angles then negate the result 1A General 13
Angle Update in Vector Mode ' ' = (1 + j k l ) Pre Q c > 0 Q c < 0 Rotate -90 Rotate +90 l = 0 l = 1 Q c > 0 Q c < 0 Q c > 0 Q c < 0 θ 0 +θ 0 θ 0 +θ 0 Q c > 0 Q c < 0 Q c > 0 Q c < 0 Q c > 0 Q c < 0 Q c > 0 Q c < 0 θ 1 +θ 1 θ 1 +θ 1 θ 1 +θ 1 θ 1 +θ 1 l = 2 θ 2 +θ 2 θ 90 θ 0 θ 1 θ 2 θ 90 + θ 0 θ 1 + θ 2 θ + 90 + θ 0 θ 1 θ 2 1A General 14
Multiplication of ±j Positive Phase (Q c > 0) Rotate by 90 degrees 0 j Q c j Negative Phase (Q c < 0) Rotate by +90 degrees 0 + j Q c j Resulting Phase [-90, +90] 1A General 15
Multiplication of 1 ± jk l Positive Phase (Q c > 0) Rotate by 1 j k l 1 j k l ( +2 l Q c ) + j (Q c 2 l ) Negative Phase (Q c < 0) Rotate by 1 + j k l 1 j k l ( 2 l Q c ) + j(q c +2 l ) After iterations, the result + j 0 1A General 16
Rotation Mode Calculating Sine and Cosine Rotation Mode C = + jq c C= + j0 Rotate until accumulated angle is θ Accumulator View I ' c Q ' c cosθ sin θ C= 0+ jq c θ > +90 cos θ Q c sin θ C= 0 jq c θ < 90 C = + jq c 1A General 17
Initial Vector Θ > +90 starting from 0 + j1 Θ < +90 starting from 1 + j0 Θ < 90 starting from 0 j1 Θ > 90 starting from 1 j0 Initialize the accumulate rotation -90, +90, 0 1A General 18
Angle Update in Rotation Mode In each iteration (Θ the accumulated rotation) < 0 then add the next angle (Θ the accumulated rotation) > 0 then subtract the next angle The final Q c cosine sine 1A General 19
1A General 20
References [1] http://en.wikipedia.org/ [2] J.H. McClellan, et al., Signal Processing First, Pearson Prentice Hall, 2003 [3] A graphical interpretation of the DFT and FFT, by Steve Mann [4] CORDIC FAQ, www.dspguru.com