?? ddc_simulate_short.m
字號:
<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><style type="text/css"><!--body,td,p,th{font-size:14px;line-height:180%;}input{font-size:12px;}--></style><title></title></head><body bgcolor=#EDF0F5 leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" border=0><pre style="width:100%;white-space:normal;word-wrap:break-word">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%DDC擬采用NCO+CIC+FIR補償濾波器的結構實現,輸入數據率120M,輸出數據率2M,抽取率60,使用CIC極大的簡化了設計!!!
%%雷達相關參數:
T=100e-6; %脈寬: 2us
Ts=1/(120e6); %采樣率:120m
%%其中:CIC:R=6,N=4,M=2,位寬固定為28位
R_cic=60;
N_cic=4;
M_cic=2;
%%FIR補償濾波器抽取率:10
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%input: AD采樣結果,N個/PRT
N=fix(T/Ts);
%input=[1,zeros(1,N-1)];
t_temp=Ts:Ts:T;
input_temp=(cos(2*pi*(46e6+1e4)*t_temp)+0.03*randn(1,fix(T/Ts)))/1.03; %SNR=30 dB,
q_input=quantizer('fixed',[10 9]); %to be deleted
q_input_final=quantizer('fixed',[14 0]); %to be deleted
input=quantize(q_input,input_temp); %to be deleted
input=input.*(16*511);
input=quantize(q_input_final,input);
figure(3)
plot(20*log10(abs(fft(input))));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% NCO 部分 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%NCO:
%%Q本振:SIN,I本振:COS
q_NCO=quantizer('fixed',[12 0]); %%nco 量化器
q_nco_result=quantizer('fixed',[16 0]);
for t=Ts:Ts:T
Q_osc_temp=2047*sin(2*pi*46e6*t+2.4); %Q_osc:Q本振 +2.4
I_osc_temp=2047*cos(2*pi*46e6*t+2.4); %I_osc:I本振 +2.4
Q_osc=quantize(q_NCO,Q_osc_temp); %Q量化
I_osc=quantize(q_NCO,I_osc_temp); %I量化
y_nco_Q(round(t/Ts))=(input(round(t/Ts)))*Q_osc;
y_nco_Q(round(t/Ts))=quantize(q_nco_result,y_nco_Q(round(t/Ts))/512);
y_nco_I(round(t/Ts))=(input(round(t/Ts)))*I_osc;
y_nco_I(round(t/Ts))=quantize(q_nco_result,y_nco_I(round(t/Ts))/512);
end
figure(1); %%看NCO結果
subplot(2,1,1), plot(20*log10(abs(fft(y_nco_Q)))); title('Q-nco-result');
subplot(2,1,2), plot(20*log10(abs(fft(y_nco_I)))); title('I-nco-result');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CIC 部分 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%int and comb quantizer
q_cic=quantizer('fixed','wrap',[44 0]);
%%integrator
%%integrator results
y_int_1_I=zeros(1,N);
y_int_2_I=zeros(1,N);
y_int_3_I=zeros(1,N);
y_int_4_I=zeros(1,N);
y_int_1_Q=zeros(1,N);
y_int_2_Q=zeros(1,N);
y_int_3_Q=zeros(1,N);
y_int_4_Q=zeros(1,N);
%stage 1
for j_cic_int_re=1:1:N
if(j_cic_int_re==1)
y_int_1_I(j_cic_int_re)=y_nco_I(j_cic_int_re)+0;
y_int_1_Q(j_cic_int_re)=y_nco_Q(j_cic_int_re)+0;
y_int_1_I(j_cic_int_re)=quantize(q_cic,y_int_1_I(j_cic_int_re));
y_int_1_Q(j_cic_int_re)=quantize(q_cic,y_int_1_Q(j_cic_int_re));
else
y_int_1_I(j_cic_int_re)=y_nco_I(j_cic_int_re)+y_int_1_I(j_cic_int_re-1);
y_int_1_Q(j_cic_int_re)=y_nco_Q(j_cic_int_re)+y_int_1_Q(j_cic_int_re-1);
y_int_1_I(j_cic_int_re)=quantize(q_cic,y_int_1_I(j_cic_int_re));
y_int_1_Q(j_cic_int_re)=quantize(q_cic,y_int_1_Q(j_cic_int_re));
end
end
%stage 2
for j_cic_int_re=1:1:N
if(j_cic_int_re==1)
y_int_2_I(j_cic_int_re)=y_int_1_I(j_cic_int_re)+0;
y_int_2_Q(j_cic_int_re)=y_int_1_Q(j_cic_int_re)+0;
y_int_2_I(j_cic_int_re)=quantize(q_cic,y_int_2_I(j_cic_int_re));
y_int_2_Q(j_cic_int_re)=quantize(q_cic,y_int_2_Q(j_cic_int_re));
else
y_int_2_I(j_cic_int_re)=y_int_1_I(j_cic_int_re)+y_int_2_I(j_cic_int_re-1);
y_int_2_Q(j_cic_int_re)=y_int_1_Q(j_cic_int_re)+y_int_2_Q(j_cic_int_re-1);
y_int_2_I(j_cic_int_re)=quantize(q_cic,y_int_2_I(j_cic_int_re));
y_int_2_Q(j_cic_int_re)=quantize(q_cic,y_int_2_Q(j_cic_int_re));
end
end
%stage3
for j_cic_int_re=1:1:N
if(j_cic_int_re==1)
y_int_3_I(j_cic_int_re)=y_int_2_I(j_cic_int_re)+0;
y_int_3_Q(j_cic_int_re)=y_int_2_Q(j_cic_int_re)+0;
y_int_3_I(j_cic_int_re)=quantize(q_cic,y_int_3_I(j_cic_int_re));
y_int_3_Q(j_cic_int_re)=quantize(q_cic,y_int_3_Q(j_cic_int_re));
else
y_int_3_I(j_cic_int_re)=y_int_2_I(j_cic_int_re)+y_int_3_I(j_cic_int_re-1);
y_int_3_Q(j_cic_int_re)=y_int_2_Q(j_cic_int_re)+y_int_3_Q(j_cic_int_re-1);
y_int_3_I(j_cic_int_re)=quantize(q_cic,y_int_3_I(j_cic_int_re));
y_int_3_Q(j_cic_int_re)=quantize(q_cic,y_int_3_Q(j_cic_int_re));
end
end
%stage 4
for j_cic_int_re=1:1:N
if(j_cic_int_re==1)
y_int_4_I(j_cic_int_re)=y_int_3_I(j_cic_int_re)+0;
y_int_4_Q(j_cic_int_re)=y_int_3_Q(j_cic_int_re)+0;
y_int_4_I(j_cic_int_re)=quantize(q_cic,y_int_4_I(j_cic_int_re));
y_int_4_Q(j_cic_int_re)=quantize(q_cic,y_int_4_Q(j_cic_int_re));
else
y_int_4_I(j_cic_int_re)=y_int_3_I(j_cic_int_re)+y_int_4_I(j_cic_int_re-1);
y_int_4_Q(j_cic_int_re)=y_int_3_Q(j_cic_int_re)+y_int_4_Q(j_cic_int_re-1);
y_int_4_I(j_cic_int_re)=quantize(q_cic,y_int_4_I(j_cic_int_re));
y_int_4_Q(j_cic_int_re)=quantize(q_cic,y_int_4_Q(j_cic_int_re));
end
end
%%抽取,R_cic=6*5
%%抽取結果
y_cic_sel_I=zeros(1,fix(N/R_cic));
y_cic_sel_Q=zeros(1,fix(N/R_cic));
for i_sel=1:1:fix(N/R_cic)
y_cic_sel_I(i_sel)=y_int_4_I(i_sel*R_cic-(R_cic-30));
y_cic_sel_Q(i_sel)=y_int_4_Q(i_sel*R_cic-(R_cic-30));
end
%%comb,M_cic=2
%%comb filter results
y_comb_1_I=zeros(1,fix(N/R_cic));
y_comb_2_I=zeros(1,fix(N/R_cic));
y_comb_3_I=zeros(1,fix(N/R_cic));
y_comb_4_I=zeros(1,fix(N/R_cic));
y_comb_1_Q=zeros(1,fix(N/R_cic));
y_comb_2_Q=zeros(1,fix(N/R_cic));
y_comb_3_Q=zeros(1,fix(N/R_cic));
y_comb_4_Q=zeros(1,fix(N/R_cic));
%stage 1
for j_cic_comb_re=1:1:fix(N/R_cic)
if(j_cic_comb_re==1 | j_cic_comb_re==2)
y_comb_1_I(j_cic_comb_re)=y_cic_sel_I(j_cic_comb_re)+0;
y_comb_1_Q(j_cic_comb_re)=y_cic_sel_Q(j_cic_comb_re)+0;
y_comb_1_I(j_cic_comb_re)=quantize(q_cic,y_comb_1_I(j_cic_comb_re));
y_comb_1_Q(j_cic_comb_re)=quantize(q_cic,y_comb_1_Q(j_cic_comb_re));
else
y_comb_1_I(j_cic_comb_re)=y_cic_sel_I(j_cic_comb_re)-y_cic_sel_I(j_cic_comb_re-2);
y_comb_1_Q(j_cic_comb_re)=y_cic_sel_Q(j_cic_comb_re)-y_cic_sel_Q(j_cic_comb_re-2);
y_comb_1_I(j_cic_comb_re)=quantize(q_cic,y_comb_1_I(j_cic_comb_re));
y_comb_1_Q(j_cic_comb_re)=quantize(q_cic,y_comb_1_Q(j_cic_comb_re));
end
end
%stage 2
for j_cic_comb_re=1:1:fix(N/R_cic)
if(j_cic_comb_re==1 | j_cic_comb_re==2)
y_comb_2_I(j_cic_comb_re)=y_comb_1_I(j_cic_comb_re)+0;
y_comb_2_Q(j_cic_comb_re)=y_comb_1_Q(j_cic_comb_re)+0;
y_comb_2_I(j_cic_comb_re)=quantize(q_cic,y_comb_2_I(j_cic_comb_re));
y_comb_2_Q(j_cic_comb_re)=quantize(q_cic,y_comb_2_Q(j_cic_comb_re));
else
y_comb_2_I(j_cic_comb_re)=y_comb_1_I(j_cic_comb_re)-y_comb_1_I(j_cic_comb_re-2);
y_comb_2_Q(j_cic_comb_re)=y_comb_1_Q(j_cic_comb_re)-y_comb_1_Q(j_cic_comb_re-2);
y_comb_2_I(j_cic_comb_re)=quantize(q_cic,y_comb_2_I(j_cic_comb_re));
y_comb_2_Q(j_cic_comb_re)=quantize(q_cic,y_comb_2_Q(j_cic_comb_re));
end
end
%stage3
for j_cic_comb_re=1:1:fix(N/R_cic)
if(j_cic_comb_re==1 | j_cic_comb_re==2)
y_comb_3_I(j_cic_comb_re)=y_comb_2_I(j_cic_comb_re)+0;
y_comb_3_Q(j_cic_comb_re)=y_comb_2_Q(j_cic_comb_re)+0;
y_comb_3_I(j_cic_comb_re)=quantize(q_cic,y_comb_3_I(j_cic_comb_re));
y_comb_3_Q(j_cic_comb_re)=quantize(q_cic,y_comb_3_Q(j_cic_comb_re));
else
y_comb_3_I(j_cic_comb_re)=y_comb_2_I(j_cic_comb_re)-y_comb_2_I(j_cic_comb_re-2);
y_comb_3_Q(j_cic_comb_re)=y_comb_2_Q(j_cic_comb_re)-y_comb_2_Q(j_cic_comb_re-2);
y_comb_3_I(j_cic_comb_re)=quantize(q_cic,y_comb_3_I(j_cic_comb_re));
y_comb_3_Q(j_cic_comb_re)=quantize(q_cic,y_comb_3_Q(j_cic_comb_re));
end
end
%stage 4
for j_cic_comb_re=1:1:fix(N/R_cic)
if(j_cic_comb_re==1 | j_cic_comb_re==2)
y_comb_4_I(j_cic_comb_re)=y_comb_3_I(j_cic_comb_re)+0;
y_comb_4_Q(j_cic_comb_re)=y_comb_3_Q(j_cic_comb_re)+0;
y_comb_4_I(j_cic_comb_re)=quantize(q_cic,y_comb_4_I(j_cic_comb_re));
y_comb_4_Q(j_cic_comb_re)=quantize(q_cic,y_comb_4_Q(j_cic_comb_re));
else
y_comb_4_I(j_cic_comb_re)=y_comb_3_I(j_cic_comb_re)-y_comb_3_I(j_cic_comb_re-2);
y_comb_4_Q(j_cic_comb_re)=y_comb_3_Q(j_cic_comb_re)-y_comb_3_Q(j_cic_comb_re-2);
y_comb_4_I(j_cic_comb_re)=quantize(q_cic,y_comb_4_I(j_cic_comb_re));
y_comb_4_Q(j_cic_comb_re)=quantize(q_cic,y_comb_4_Q(j_cic_comb_re));
end
end
q_cic_re=quantizer('fixed',[24 0]);
y_cic_I=quantize(q_cic_re,y_comb_4_I./(2^20));
y_cic_Q=quantize(q_cic_re,y_comb_4_Q./(2^20));
%y_cic_I=y_comb_4_I;
%y_cic_Q=y_comb_4_Q;
figure(2); %%看CIC結果
subplot(2,1,1), plot(20*log10(abs(fft(y_cic_Q)))); title('Q-cic-result');
subplot(2,1,2), plot(20*log10(abs(fft(y_cic_I)))); title('I-cic-result');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</pre></body></html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -