📄 cordic_mixer.m
字号:
function [Xout,Yout] = CORDIC_mixer(Sn,theta)
% CORDIC algorithm used in NCO and DDC
% Sn : input signal
%theta: the phase of the cosine and sine wave
% Ir: output signal for I arm after mixer
% Qr: output signal for Q arm after mixer
N_cordic=16;
K_cordic=1;
word_length=12;
for k=0:N_cordic-1
K_cordic=K_cordic/sqrt(1+0.25^k);
end
x0=K_cordic*Sn; % when mixing with input signal s(n),x0=s(n)
y0=0;
while(theta>pi||theta<-pi)
if(theta>pi)
theta=theta-2*pi;
else
theta=theta+2*pi;
end
end
z0=theta;
if(z0>0)
d0=1;
else
d0=-1;
end
x(1)=0;
y(1)=x0*d0;
z(1)=z0-d0*pi/2;
for i=1:N_cordic
if(z(i)>=0)
d(i)=1;
else
d(i)=-1;
end
x(i+1)=x(i)-d(i)*y(i)*2^(-(i-1));
y(i+1)=y(i)+d(i)*x(i)*2^(-(i-1));
z(i+1)=z(i)-d(i)*atan(2^(-(i-1)));
end
Xout=x(N_cordic+1);% cos
Yout=y(N_cordic+1);% sin
Ir= round(Xout*(2^word_length-1));
Qr= round(Yout*(2^word_length-1));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -