Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about sin/cos CORDIC algorithm #4

Open
leemango1998 opened this issue Nov 10, 2022 · 0 comments
Open

Question about sin/cos CORDIC algorithm #4

leemango1998 opened this issue Nov 10, 2022 · 0 comments

Comments

@leemango1998
Copy link

Hi, I have a question about CORDIC algorithm in liquid-fpm. According to wiki, the basic operations in rotation in CORDIC are showed below:

 x[i+1] = x[i] - d[i] * y[i] * 2^(-i)
 y[i+1] = y[i] + d[i] * x[i] * 2^(-i)
 θ[i+1] = θ[i] − d[i] * α[i]

where d[i] is either 1 or -1. I note that in liquid-fpm, we use XOR operation to deal with the judgment of positive and negative signs.

for (i=0; i<n; i++) {
d = ( z>=0 ) ? 0 : -1;
// d = z >> 31;
tx = x - ((y>>i)^d)-d;
ty = y + ((x>>i)^d)-d;
tz = z - ((Q(_cordic_Ak_tab)[i]^d)-d);
x = tx;
y = ty;
z = tz;

But I suspect there is a bug in the above code. In line 123, there seems to be a missing parenthesis of ((y>>i)^d) -d;. They should be a whole like line 125.

tz = z - ((Q(_cordic_Ak_tab)[i]^d)-d);

Is there a trick here that I don't know about or is this a simple clerical error? Looking forward to your reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant