|
This should be a follow-up on an active thread but I can't
find it now ... I apologize.
I converted the inner loop of my CORDIC from integer-only
implementation:
x(i+1) = x(i) + sgn(y(i))*floor(y(i)*pow2(1-i));
y(i+1) = y(i) - sgn(y(i))*floor(x(i)*pow2(1-i));
To FPT implementation:
switch sgn(y(i))
case -1 , x(i+1) = x(i) - bitsra(y(i),i-1);
case 0 , x(i+1) = 0;
case 1 , x(i+1) = x(i) + bitsra(y(i),i-1);
end
switch sgn(y(i))
case -1 , y(i+1) = y(i) + bitsra(x(i),i-1);
case 0 , y(i+1) = 0;
case 1 , y(i+1) = y(i) - bitsra(x(i),i-1);
end
I noticed two problems, when running 7.6.0 on Linux:
1) the underflow messages do appear when bitsra is used,
contrary to what the other thread just claimed.
2) the execution speed, at least in interpreted mode, slowed
way down, by more than factor of 20.
The integer-only implementation was written for speed,
admittedly, so it avoids the needless left and right shifts
during rounding just to maintain the binary point.
So the question is: is this the best way to do this simple
operation? I'm looking for something both easy to read and fast.
I'm using
x(i+1) = x(i) + sgn(y(i))*floor(y(i)*pow2(1-i));
instead of
x = x + sgn(y) * floor( y * pow2(1-i) );
just to keep track of what happens after each iteration.
It's not a required part of the algorithm.
|