dd1029us
Newbie level 1
- Joined
- May 1, 2014
- Messages
- 1
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 16
Hello all. I am working on a project involving an FPGA board to perform some basic calculations using the CORDIC algorithm, written in VHDL. CORDIC allows you to calculate certain functions using just add, subtract and bit-shift. I know how to use CORDIC to find sine and cosine. However, I'm trying to implement multiplication and don't seem to be getting the right results. I'll just lay out the basic iterative CORDIC algorithm as follows:
x(k+1) = x(k) - m*d(k)*y(k)*2^-k
y(k+1) = y(k) + d(k)*x(k)*2^-k
z(k+1) = z(k) - d(k)*e(k)
(d(k) = +1 or -1 depending on y(k) or z(k))
m 0,+1,-1 (0 for linear operations such as multiplication)
e(k) is a pre-stored constant.
For multiplication, we have the following procedure:
y(n+1) = x(0)*z(0),
e(k) = 2^-k,
d(k) = sign(z(k)),
y(0) = 0
Basically, you keep iterating until you get an accurate answer. The following is a Matlab script to test this procedure:
Matlab gives me the following output:
x =
4
y =
8.0000
z =
3.0000
All it seems to do is double the value of x, giving me 8 instead of 20. There must be some factor that needs to be multiplied; I'm not sure. I saw another thread similar to mine, but nobody gave a sufficient answer. I've looked all over the internet, and am unable to find any answer. There seems to be a small range within which x and z can exist to Any help would be appreciated. Thank you.
x(k+1) = x(k) - m*d(k)*y(k)*2^-k
y(k+1) = y(k) + d(k)*x(k)*2^-k
z(k+1) = z(k) - d(k)*e(k)
(d(k) = +1 or -1 depending on y(k) or z(k))
m 0,+1,-1 (0 for linear operations such as multiplication)
e(k) is a pre-stored constant.
For multiplication, we have the following procedure:
y(n+1) = x(0)*z(0),
e(k) = 2^-k,
d(k) = sign(z(k)),
y(0) = 0
Basically, you keep iterating until you get an accurate answer. The following is a Matlab script to test this procedure:
Code:
clear;
% CORDIC Multiplication Example
n=20; % Number of Iterations
x0=4;
y0=0;
z0=5;
d0=sign(z0);
x=x0;
y=y0+d0*x0*(2^(-0));
z=z0-d0*(2^(-0));
x0=x;
y0=y;
z0=z;
if z0>=0
dk=1;
else
dk=-1;
end;
for k=1:n-1
x=x0;
y=y0+dk*x0*(2^(-k));
z=z0-dk*(2^(-k));
if z>=0
dk=1;
else
dk=-1;
end;
x0=x;
y0=y;
z0=z;
end;
display(x);
display(y);
display(z);
Matlab gives me the following output:
x =
4
y =
8.0000
z =
3.0000
All it seems to do is double the value of x, giving me 8 instead of 20. There must be some factor that needs to be multiplied; I'm not sure. I saw another thread similar to mine, but nobody gave a sufficient answer. I've looked all over the internet, and am unable to find any answer. There seems to be a small range within which x and z can exist to Any help would be appreciated. Thank you.