cordic的FPGA实现(五) 除法实现

时间:2022-07-22
本文章向大家介绍cordic的FPGA实现(五) 除法实现,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

根据之前的更新,大家可能已经看出,其实除法器的实现,仅仅改变旋转的参考系即可,除法所使用的参考系为:z,其matlab代码为:

function c = chufaqi(x,y) 
t=1.0;
z=0;
for i=0:1:15
    %y是x累加的结果
    %z是斜度的长度 1/2^i是移动的距离 
   if y<0  %矢量向下移动  参考系为y
       y=y+x*t;
       z=z-t;
       t=t/2;
   else %矢量向上移动  参考系为y
       y=y-x*t;
       z=z+t;
       t=t/2;
   end
end
c=z;

CORDIC算法verilog实现仅需要更改乘法器的几个变量即可。

常量表

关于前几篇中使用的常量,后台看到了有朋友提问说是什么意思,在结尾和大家解释一下:

atan(1)对应的角度是45°;
atan(0.5)对应的角度是26.565051177078°;
atan(0.25)对应的角度是14.0362434679265°;
atan(0.125)对应的角度是7.1250163489018°;
atan(0.0625)对应的角度是3.57633437499735°;
atan(0.03125)对应的角度是1.78991061°;
atan(0.015625)对应的角度是0.8951737102111°;
atan(0.0078125)对应的角度是0.4476141708606°;
atan(0.00390625)对应的角度是0.2238105003685°;
atan(0.001953125)对应的角度是0.1119056770662°;
atan(0.0009765625)对应的角度是0.0559528918938°;
atan(0.00048828125)对应的角度是0.027976452617,°;
atan(0.000244140625)对应的角度是0.01398822714227°;
atan(0.0001220703125)对应的角度是0.006994113675353°;
atan(0.00006103515625)对应的角度是0.003497056850704°;
atan(0.000030517578125)对应的角度是0.0017485284269°;

将一切视为常量:

为了在FPGA上实现CORDIC运算,需要将浮点数转换为定点数,转换的方式很简单~~~,左移16位不就好了!

所以将上图中的常量统一左移16位,即乘2^16,得到的结果为:

`define rot0  32'd2949120       //45度*2^16
`define rot1  32'd1740992       //26.5651度*2^16
`define rot2  32'd919872        //14.0362度*2^16
`define rot3  32'd466944        //7.1250度*2^16
`define rot4  32'd234368        //3.5763度*2^16
`define rot5  32'd117312        //1.7899度*2^16
`define rot6  32'd58688         //0.8952度*2^16
`define rot7  32'd29312         //0.4476度*2^16
`define rot8  32'd14656         //0.2238度*2^16
`define rot9  32'd7360          //0.1119度*2^16
`define rot10 32'd3648          //0.0560度*2^16
`define rot11 32'd1856          //0.0280度*2^16
`define rot12 32'd896           //0.0140度*2^16
`define rot13 32'd448           //0.0070度*2^16
`define rot14 32'd256           //0.0035度*2^16
`define rot15 32'd128           //0.0018度*2^16

END