我正在计算极坐标系中两条线的交点:
typedef ap_fixed<16,3,AP_RND> t_lines_angle;
typedef ap_fixed<16,14,AP_RND> t_lines_rho;
bool get_intersection(
hls::Polar_< t_lines_angle, t_lines_rho>* lineOne,
hls::Polar_< t_lines_angle, t_lines_rho>* lineTwo,
Point* point)
{
float angleL1 = lineOne->angle.to_float();
float angleL2 = lineTwo->angle.to_float();
t_lines_angle rhoL1 = lineOne->rho.to_float();
t_lines_angle rhoL2 = lineTwo->rho.to_float();
t_lines_angle ct1=cosf(angleL1);
t_lines_angle st1=sinf(angleL1);
t_lines_angle ct2=cosf(angleL2);
t_lines_angle st2=sinf(angleL2);
t_lines_angle d=ct1*st2-st1*ct2;
// we make sure that the lines intersect
// which means that parallel lines are not possible
point->X = (int)((st2*rhoL1-st1*rhoL2)/d);
point->Y = (int)((-ct2*rhoL1+ct1*rhoL2)/d);
return true;
}
在对我们的 FPGA 进行综合后,我看到浮点正弦(和余弦)的 4 种实现每次实现需要 4800 个 LUT,这 4 个函数的总和为 19000 个 LUT。我想通过使用定点正弦来减少 LUT 计数。我已经找到了CORDIC的实现,但我不确定如何使用它。该函数的输入是一个整数,但我有一个ap_fixed
数据类型。如何将其映射ap_fixed
到整数?以及如何将我的 3.13 固定点映射到所需的 2.14 固定点?