|
发表于 2014-9-24 21:00:44
|
显示全部楼层
楼主,我参看了你写的DDS_CORDIC_eetop.m文件,只是实在不明白,cordic算法中时如何利用旋转法实现Z—in==0的,希望楼主可以解答,附上代码
- for i = 1:1:num_of_sample
-
- % input quardrant fitting
- % CORDIC does have a convergence range
- z_in = l(i) - scale_ang/2; % 0-2*pi --> -pi-pi
- if (z_in>=0)
- quad_sel = 0;
- z_in = z_in - scale_ang/4; % -pi-pi --> -pi/2-pi/2
- else
- quad_sel = 1;
- z_in = z_in + scale_ang/4; % -pi-pi --> -pi/2-pi/2
- end
- % CORDIC main
- for k=1:1:iteration
- if (k==1)
- a_in = K; % pre-rotation to cancel rotaion gain
- b_in = 0;
- [a_out,b_out,z_out] = cordic_cell(a_in,b_in,z_in,atan_table(k),k-1,0);
- else
- a_in = a_out;
- b_in = b_out;
- z_in = z_out;
- [a_out,b_out,z_out] = cordic_cell(a_in,b_in,z_in,atan_table(k),k-1,0);
- end
- end;
-
- % output quardrant fitting
- % one more word, in RTL implementation, be aware of the corner case
- % eg. -2^15, if negated, is 2^15, overflow.
- switch quad_sel
- case 0
- cos_out(i) = b_out;
- sin_out(i) =-a_out;
- case 1
- cos_out(i) =-b_out;
- sin_out(i) = a_out;
- end
-
- end
复制代码 |
|