最近写的一个参数化的CORDIC算法 ,有兴趣的一起来探讨一下
//CORDIC alogrithm
//author:yanshanyan@csdn, crazyalpha@github
//email:yunweidz@126.com
module cordic(
clk_in,
reset_n,
ena,
phase_in,
clk_out,
phase_out,
cos_o,
sin_o
);
parameter dat_width = 16, pha_width =16, pipeline = 10;
input clk_in, reset_n, ena;
input [pha_width-1 : 0] phase_in;
output clk_out;
output [pha_width-1 : 0] phase_out;
output [dat_width-1 : 0] cos_o, sin_o;
//reg [1:0] quad;
//reg [pha_width-3 : 0] phase;
reg [dat_width-1 : 0] x[pipeline :0];
reg [dat_width-1 : 0] y[pipeline :0];
reg [pha_width-1 : 0] z[pipeline :0];
reg [pha_width-1 : 0] phase_tmp[pipeline :0];
wire [dat_width-1:0] amp;
wire [pha_width-1:0] atan [32:0];
assign amp = 32'd1304065887 >>(32-dat_width); //K=0.607253 * 2^(datwidth-1), 1bit sign bit
assign atan[0] = 32'd536870912 >>(32-pha_width); //atan(1) * 2^(pha_width) /360 = 45? * 2^(pha_width) /360
assign atan[1] = 32'd316933407 >>(32-pha_width); //atan(1/2) * 2^(pha_width) /360 = 26.5651 ? * 2^(pha_width) /360
assign atan[2] = 32'd167458907 >>(32-pha_width); //atan(1/4) = 26.5651
assign atan[3]= 32'd85004756 >>(32-pha_width); //atan(1/8) = 14.0362
assign atan[4]= 32'd42667331 >>(32-pha_width); //atan(1/16) = 7.1250
assign atan[5]= 32'd21354465 >>(32-pha_width); //atan(1/32) = 3.5763
assign atan[6]= 32'd10679838 >>(32-pha_width); //atan(1/64) = 1.7899
assign atan[7]= 32'd5340245 >>(32-pha_width); //a