- added
git-svn-id: http://moon:8086/svn/vhdl/trunk@1495 cc03376c-175c-47c8-b038-4cd826a8556b
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
% Read data
|
||||
function tb_results()
|
||||
%fa = 100.0;
|
||||
fa = textread('fa.txt')/1E6
|
||||
R = textread('ratio.txt');
|
||||
N = textread('nstages.txt');;
|
||||
M = 1;
|
||||
fa_dec = fa/R
|
||||
N_pfir = 63;
|
||||
|
||||
I_out_dec = textread('i_dec.txt')';
|
||||
Q_out_dec = textread('q_dec.txt')';
|
||||
I_out_fir = textread('i_fir.txt')';
|
||||
Q_out_fir = textread('q_fir.txt')';
|
||||
|
||||
N_dec = length(I_out_dec)-2*N_pfir;
|
||||
N_fft_dec = N_dec
|
||||
N_fft2_dec = N_fft_dec/2;
|
||||
|
||||
N_fir = length(I_out_fir)-2*N_pfir;
|
||||
N_fft_fir = N_fir
|
||||
N_fft2_fir = N_fft_fir/2;
|
||||
|
||||
fft_y2_fir = 2/N_fft_fir*abs(fft(I_out_fir(2*N_pfir+1:N_fft_fir+2*N_pfir).*hann(N_fft_fir)'));
|
||||
|
||||
fft_y2_dec = 2/N_fft_dec*abs(fft(I_out_dec(2*N_pfir+1:N_fft_dec+2*N_pfir).*hann(N_fft_dec)'));
|
||||
|
||||
f = (1:N_fft_dec)/N_fft_dec;
|
||||
g = (R*M)^N;
|
||||
H = abs(sin(pi*M.*f)./sin(pi.*f/R)).^N;
|
||||
|
||||
[v, j] = max(fft_y2_dec(1:N_fft2_dec/2))
|
||||
H = v*H/H(j);
|
||||
|
||||
audiowrite('iq.wav', 0.5*[I_out_dec' Q_out_dec'], 16000, 'BitsPerSample', 16);
|
||||
audiowrite('iq_cfir.wav', 0.5*[I_out_fir' Q_out_fir'], 8000, 'BitsPerSample', 16);
|
||||
|
||||
% Output
|
||||
close all;
|
||||
|
||||
plot(1:length(I_out_dec), I_out_dec, 1:length(Q_out_dec), Q_out_dec); grid;
|
||||
|
||||
figure;
|
||||
cic_plot(M, N, R);
|
||||
|
||||
figure;
|
||||
subplot(2,1,1)
|
||||
plot(fa/(R*N_fft_dec)*(0:N_fft2_dec),20*log10(fft_y2_dec(1:N_fft2_dec+1)), '-', fa/(R*N_fft_dec)*(0:N_fft2_dec),20*log10(H(1:N_fft2_dec+1)), 'r-');
|
||||
legend('CIC', 'Droop');
|
||||
xlabel('MHz');
|
||||
grid;
|
||||
subplot(2,1,2)
|
||||
plot(fa/(2*R*N_fft_fir)*(0:N_fft2_fir),20*log10(fft_y2_fir(1:N_fft2_fir+1)), '-');
|
||||
legend('CFIR');
|
||||
xlabel('MHz');
|
||||
grid;
|
||||
|
||||
Reference in New Issue
Block a user