There are a lot of information on the CORDIC algorithm on the internet, after looking at the Wikipedia to tell the more clear, hereby summarized + reproduced
Http://en.wikipedia.org/wiki/CORDIC
Algorithmic thinking
The CORDIC algorithm is an iterative algorithm to approximate the target value, and the more the iteration number is, the higher the precision. The iterative process requires only 2 operations and addition and subtraction operations, so it is particularly suitable for hardware implementations. In the unit circle, the x-coordinate and y-coordinate of the β point on the upper corner of the circle correspond to the Cos and sin values of β respectively, so the cordicn iteration of the sine of the angular β is as follows:
1, with (1,0) as the initial point, toward the direction of the beta rotation arctan (1) =45° get point v1
2, V1 to near the direction of β rotation angle arctan (1/2) to get points v2
3, point VI to near the direction of β rotation angle arctanc (1/(2^i)) to get vi+1
4, when the i+1=n, stop, VN coordinates is to seek the sine cosine value
Coordinate rotation
Each cordic iteration is calculated with this rotation, which is achieved by multiplying the rotation matrix, as follows:
The rotation matrix is calculated using the following formula :
and the Cos and SIN functions can be converted to Tan
It can therefore be translated into:
If you let tan take a value, then both the vi coordinate and the matrix multiplication can be implemented by shifting, at which point the rotation formula is:
which
Ki can be calculated separately after the iteration is complete, and ultimately only by multiplying the KN:
As n increases, kn tends to stabilize.
The ±1, which determines whether it rotates clockwise or counterclockwise.
β is approximated according to the following formula, and each iteration should be rotated toward the direction of the β.
Values can be obtained by looking up the table method.
Matlab Code
1 functionv =cordic (beta,n)2% thisfunctionComputes V =[cos (beta), sin (Beta)] (beta in radians)3%using n iterations. Increasing n would increase the precision.4 5 ifBeta <-pi/2|| Beta > pi/26 ifBeta <07v = cordic (beta +pi, n);8 Else9v = cordic (beta-pi, n);Ten End Onev =-V; % Flip the sign forSecondorThird Quadrant A return - End - the%initialization of tables of constants used by CORDIC -% Need aTableof arctangents of negative powers of, in radians: -% angles = Atan (2.^-(0: -)); -Angles = [ ... + 0.78539816339745 0.46364760900081 0.24497866312686 0.12435499454676 ... - 0.06241880999596 0.03123983343027 0.01562372862048 0.00781234106010 ... + 0.00390623013197 0.00195312251648 0.00097656218956 0.00048828121119 ... A 0.00024414062015 0.00012207031189 0.00006103515617 0.00003051757812 ... at 0.00001525878906 0.00000762939453 0.00000381469727 0.00000190734863 ... - 0.00000095367432 0.00000047683716 0.00000023841858 0.00000011920929 ... - 0.00000005960464 0.00000002980232 0.00000001490116 0.00000000745058 ]; -% andATableof products of reciprocal lengths of vectors [1,2^-2j]: -Kvalues = [ ... - 0.70710678118655 0.63245553203368 0.61357199107790 0.60883391251775 ... in 0.60764825625617 0.60735177014130 0.60727764409353 0.60725911229889 ... - 0.60725447933256 0.60725332108988 0.60725303152913 0.60725295913894 ... to 0.60725294104140 0.60725293651701 0.60725293538591 0.60725293510314 ... + 0.60725293503245 0.60725293501477 0.60725293501035 0.60725293500925 ... - 0.60725293500897 0.60725293500890 0.60725293500889 0.60725293500888 ]; theKn =kvalues (min (n, Length (kvalues))); * $%Initialize Loop variables:Panax Notoginsengv = [1;0]; % start with2-vector cosine andsine of Zero -Poweroftwo =1; theAngle = angles (1); + A%iterations the forj =0: N-1; + ifBeta <0 -Sigma =-1; $ Else $Sigma =1; - End -Factor = Sigma *Poweroftwo; theR = [1,-factor; Factor1]; -v = R * v; %2-by-2Matrix MultiplyWuyiBeta = beta-sigma * angle; %Update the remaining angle thePoweroftwo = poweroftwo/2; -% update the angle fromTable,oreventually by just dividing by Wu ifj+2>Length (angles) -Angle = angle/2; About Else $Angle = Angles (j+2); - End - End - A% Adjust Length ofOutputvector to bes [cos (beta), sin (Beta)]: +v = v *Kn; theReturn
View Code
Cordic algorithm calculates positive cosine