- Intital revision
git-svn-id: http://moon:8086/svn/vhdl/trunk@146 cc03376c-175c-47c8-b038-4cd826a8556b
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
vlib work
|
||||
vcom -explicit -93 "../../../fixed/fixed_pkg_c.vhd"
|
||||
vcom -explicit -93 "../../../PCK_FIO-2002.7/PCK_FIO_1993.vhd"
|
||||
vcom -explicit -93 "../../../PCK_FIO-2002.7/PCK_FIO_1993_BODY.vhd"
|
||||
vcom -explicit -93 "../../cordic/src/cordic_pkg.vhd"
|
||||
vcom -explicit -93 "../../cordic/src/cordic_pipe_stage.vhd"
|
||||
vcom -explicit -93 "../../cordic/src/cordic_pipe_pre.vhd"
|
||||
vcom -explicit -93 "../../cordic/src/cordic_pipe_post.vhd"
|
||||
vcom -explicit -93 "../../cordic/src/cordic_pipe_top.vhd"
|
||||
vcom -explicit -93 "../src/nco_pkg.vhd"
|
||||
vcom -explicit -93 "../src/nco_cordic_dbg.vhd"
|
||||
vcom -explicit -93 "../src/mix_cordic_dbg.vhd"
|
||||
vcom -explicit -93 "../src/tb_mix_cordic.vhd"
|
||||
vsim -t 1ps -lib work tb_mix
|
||||
do {tb_mix_cordic.wdo}
|
||||
view wave
|
||||
view structure
|
||||
view signals
|
||||
run 250us
|
||||
@@ -0,0 +1,33 @@
|
||||
onerror {resume}
|
||||
quietly WaveActivateNextPane {} 0
|
||||
add wave -noupdate -format Logic /tb_mix/clk
|
||||
add wave -noupdate -format Logic /tb_mix/srst
|
||||
add wave -noupdate -format Logic /tb_mix/pacc_clr
|
||||
add wave -noupdate -format Logic /tb_mix/pacc_inc
|
||||
add wave -noupdate -format Logic /tb_mix/phase_load
|
||||
add wave -noupdate -format Logic /tb_mix/freq_load
|
||||
add wave -noupdate -format Literal -radix decimal /tb_mix/freq_in
|
||||
add wave -noupdate -format Literal -radix decimal /tb_mix/phase_in
|
||||
add wave -noupdate -format Analog-Step -radix decimal -scale 0.00025940300000000001 /tb_mix/wave_in_i
|
||||
add wave -noupdate -format Analog-Step -radix decimal -scale 0.00025940300000000001 /tb_mix/wave_in_q
|
||||
add wave -noupdate -format Literal -radix decimal /tb_mix/wave_out_i
|
||||
add wave -noupdate -format Literal -radix decimal /tb_mix/wave_out_q
|
||||
add wave -noupdate -format Logic /tb_mix/out_valid
|
||||
add wave -noupdate -format Literal /tb_mix/mix_debug_out
|
||||
add wave -noupdate -format Literal /tb_mix/rfgen_debug_out
|
||||
TreeUpdate [SetDefaultTree]
|
||||
WaveRestoreCursors {{Cursor 1} {77110000 ps} 0}
|
||||
configure wave -namecolwidth 193
|
||||
configure wave -valuecolwidth 100
|
||||
configure wave -justifyvalue left
|
||||
configure wave -signalnamewidth 1
|
||||
configure wave -snapdistance 10
|
||||
configure wave -datasetprefix 0
|
||||
configure wave -rowmargin 4
|
||||
configure wave -childrowmargin 2
|
||||
configure wave -gridoffset 0
|
||||
configure wave -gridperiod 1
|
||||
configure wave -griddelta 40
|
||||
configure wave -timeline 0
|
||||
update
|
||||
WaveRestoreZoom {246747082 ps} {250171207 ps}
|
||||
@@ -0,0 +1,58 @@
|
||||
% Read data
|
||||
function tb_mix_results()
|
||||
fa = 100.0;
|
||||
f = TEXTREAD('freq.txt')*1E-6
|
||||
|
||||
I_in = TEXTREAD('i_in.txt')';
|
||||
I_out = TEXTREAD('i_out.txt')';
|
||||
|
||||
N= length(I_out);
|
||||
N_fft = N
|
||||
N_fft2 = N_fft/2;
|
||||
|
||||
fft_y2 = 2/N_fft*abs(fft(I_out(1:N_fft).*hann(N_fft)'));
|
||||
|
||||
[i, v] = get_maxpur(fft_y2, fa, f);
|
||||
max_spur_freq = (i*fa/N_fft);
|
||||
max_spur_value = 20*log10(v);
|
||||
|
||||
fft_y3 = 2/N_fft*abs(fft(I_in(1:N_fft).*hann(N_fft)'));
|
||||
|
||||
[i, v] = get_maxpur(fft_y3, fa, f);
|
||||
max_ditherd_spur_freq = (i*fa/N_fft);
|
||||
max_ditherd_spur_value = 20*log10(v);
|
||||
|
||||
% Output
|
||||
close all;
|
||||
|
||||
subplot(2,1,1)
|
||||
plot(fa/N_fft*(0:N_fft2),20*log10(fft_y2(1:N_fft2+1)), '-', fa/N_fft*(0:N_fft2), max_spur_value*ones(1,N_fft2+1), 'r-', [max_spur_freq], [max_spur_value], 'ro'); grid;
|
||||
spur_legend = sprintf('Max. spur %.1fdB at %.3fMHz', max_spur_value, max_spur_freq);
|
||||
legend('With dithering', spur_legend);
|
||||
legend('No dithering', spur_legend);
|
||||
title('Table');
|
||||
ylabel('dB');
|
||||
xlabel('f/MHz');
|
||||
axis([0 fa/2 -140 0]);
|
||||
subplot(2,1,2)
|
||||
plot(fa/N_fft*(0:N_fft2),20*log10(fft_y3(1:N_fft2+1)), '-', fa/N_fft*(0:N_fft2), max_ditherd_spur_value*ones(1,N_fft2+1), 'r-', [max_ditherd_spur_freq], [max_ditherd_spur_value], 'ro'); grid;
|
||||
spur_legend = sprintf('Max. spur %.1fdB at %.3fMHz', max_ditherd_spur_value, max_ditherd_spur_freq);
|
||||
legend('With dithering', spur_legend);
|
||||
title('Table');
|
||||
ylabel('dB');
|
||||
xlabel('f/MHz');
|
||||
axis([0 fa/2 -140 0]);
|
||||
|
||||
function [max_i, max_v] = get_maxpur(spec, fa, f)
|
||||
max_v = 0;
|
||||
max_i = 0;
|
||||
for ii=1:fix(length(spec)/2+1),
|
||||
fi = ii*fa/length(spec);
|
||||
dfi = fi - f;
|
||||
if abs(dfi) > 0.005*f
|
||||
if spec(ii) > max_v
|
||||
max_v = spec(ii);
|
||||
max_i = ii-1;
|
||||
end
|
||||
end;
|
||||
end;
|
||||
Reference in New Issue
Block a user