Cordic approximation algorithm

Source: Internet
Author: User

Start Learning Cordic algorithm now

Learn the blog:

(1) http://blog.csdn.net/liyuanbhu/article/details/8458769 trigonometric calculation, Cordic algorithm Introduction

(1) A good explanation of the idea of the CORDIC algorithm. Coordinate rotation formula. Derivation http://www.cnblogs.com/ywxgod/archive/2010/08/06/1793609.html

Clockwise rotation: X ' = Xcos (θ) + ysin (θ), y ' =-xsin (θ) + ycos (θ);

Counterclockwise Rotation: X ' = Xcos (θ)-ysin (θ), y ' = xsin (θ) + ycos (θ);

Once you know this, determine (x, y) polar coordinates ρ= sqrt (x2+y2), θ= arctan (y/x). The solution of θ is a requirement super function. In blog post is to find the hair by two points. Where the approximation of the indicator is y = 0; I estimate that the cordic algorithm is a similar approximation.

This two-point search is really an image.

The implementation of the FPGA is as follows: only 5-level pipelining is used. Its angular accuracy is 26-7.

1 //*****************************************************************************************2 //3 //function:achieve The coordinate rotation digital computers 54 //5 //6 //Corn 2014.11.157 //8 //9 //*****************************************************************************************Ten  One ModuleCordic_module ( A inputCLK, Rst_n, -  - input        signed[7:0] x0, y0, the  - Output    Reg    signed[7:0] R, Syta -  - ); +  - parameterWIDTH =8; +  A  at Reg    signed[WIDTH-1:0] X0_r, X1_r, X2_r, X3_r, X4_r; - Reg    signed[WIDTH-1:0] Y0_r, Y1_r, Y2_r, Y3_r, Y4_r; - Reg    signed[WIDTH-1:0] Syta0_r, Syta1_r, Syta2_r, Syta3_r, Syta4_r; -  -  -  always@(PosedgeClassor NegedgeRst_n)begin in     if(!rst_n)begin -Syta0_r <=0; to     End +     Else    begin -     //First stage---------------------------------------------------------- the         if(X0 >=0)begin        //In the first sector or forth sector *X0_r <=x0; $Y0_r <=y0;Panax NotoginsengSyta0_r <=0; -         End the         Else    if(Y0 >=0)begin    //In the second sector +X0_r <=y0; AY0_r <=-x0; theSyta0_r <= -; +         End -         Else    begin                    //In the third sector $X0_r <=-y0; $Y0_r <=x0; -Syta0_r <=- -; -         End the     //Second Stage arctan (1)------------------------------------------------------- -         if(Y0_r >=0)beginWuyiX1_r <= X0_r +Y0_r; theY1_r <= Y0_r-X0_r; -Syta1_r <= Syta0_r + $; Wu         End -         Else    begin AboutX1_r <= X0_r-Y0_r; $Y1_r <= Y0_r +X0_r; -Syta1_r <= Syta0_r- $; -         End -     //Third Stage arctan (2)--------------------------------------------------------- A         if(Y1_r >=0)begin +X2_r <= X1_r + y1_r/2; theY2_r <= Y1_r-x1_r/2; -Syta2_r <= Syta1_r + -; $         End the         Else    begin theX2_r <= X1_r-y1_r/2; theY2_r <= Y1_r + x1_r/2; theSyta2_r <= Syta1_r- -; -         End in     //Forth Stage arctan (4)--------------------------------------------------------- the         if(Y2_r >=0)begin theX3_r <= X2_r + y2_r/4; AboutY3_r <= y2_r-x2_r/4; theSyta3_r <= Syta2_r + -; the         End the         Else    begin +X3_r <= x2_r-y2_r/4; -Y3_r <= Y2_r + x2_r/4; theSyta3_r <= Syta2_r- -;Bayi         End the     //Fiveth Stage arctan (8)--------------------------------------------------------- the         if(Y3_r >=0)begin -X4_r <= X3_r + y3_r/8; -Y4_r <= Y3_r-x3_r/8; theSyta4_r <= Syta3_r +7; the         End the         Else    begin theX4_r <= X3_r-y3_r/8; -Y4_r <= Y3_r + x3_r/8; theSyta4_r <= Syta3_r-7; the         End the     94     //Output theR <=X4_r; theSyta <=Syta4_r; the     End98  About  - 101 End    // always102 //103 104  the 106 Endmodule

Simulation results:

Three groups of data were used: (-41, 55), (4,-4), (3, 3)

Results of using the computer: (68.6,-53), (5.6,-45) (4.2, 45)

Simulation results: (112,-126), (9,-40), (6, 50) where (-126) 180 = 54

Conclusion: The RADIUS has increased, the angle has a certain error range of 27-7. There is a certain error in the angle. If you want to increase the precision, increase the number of iterations.

Cordic approximation algorithm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.