49 bool xneg, yneg, dneg;
52 const phase_t cord_M_PI = 3.14159265358979323846;
53 const phase_t cord_M_PI_2 = 1.57079632679489661923;
56 static const phase_t atan_2Mi[] = { 0.7854, 0.4636, 0.2450, 0.1244, 0.0624,
57 0.0312, 0.0156, 0.0078, 0.0039 };
60 static const coord_t lut_pow2[] = {1, 2, 4, 8, 16, 32, 64, 128, 256};
92 unsigned char quadrant = 0;
93 if ((x0 > 0) & (y0 > 0))
95 else if ((x0 < 0) & (y0 > 0))
97 else if ((x0 < 0) & (y0 < 0))
99 else if ((x0 > 0) & (y0 < 0))
102 LOOP1:
for (i = 0; i <=
ROT; i++)
105 #pragma HLS PIPELINE II=1 114 xp = x + y/lut_pow2[i];
115 yp = y - x/lut_pow2[i];
117 zp = z + atan_2Mi[i];
123 xp = x-y/lut_pow2[i];
124 yp = y+x/lut_pow2[i];
126 zp = z - atan_2Mi[i];
137 }
else if (quadrant == 2) {
141 }
else if (quadrant == 3) {
145 }
else if (quadrant == 4) {
154 #if defined(DB_DOUBLE_PRECISION) 155 *zn = atan2( (
double) y0, (
double) x0);
156 #elif defined(DB_SINGLE_PRECISION) 157 *zn = atan2f( (
float) y0, (
float) x0);
158 #elif defined(DB_CORDIC) 161 #error <UNDEFINED ATAN2 METHOD!>
void cordic_atan2(coord_t y0, coord_t x0, phase_t *zn)
x
Return the smallest n such that 2^n >= _x.
void top_atan2(coord_t y0, coord_t x0, phase_t *zn)