Initial import
git-svn-id: http://moon:8086/svn/vhdl/trunk@5 cc03376c-175c-47c8-b038-4cd826a8556b
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
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 "../src/nco_pkg.vhd"
|
||||
vcom -explicit -93 "../src/waverom_dual.vhd"
|
||||
vcom -explicit -93 "../src/wavelut.vhd"
|
||||
vcom -explicit -93 "../src/nco_dbg.vhd"
|
||||
vcom -explicit -93 "../src/tb_nco.vhd"
|
||||
vsim -t 1ps -lib work tb_nco
|
||||
do {tb_nco.wdo}
|
||||
view wave
|
||||
view structure
|
||||
view signals
|
||||
run 250us
|
||||
@@ -0,0 +1,46 @@
|
||||
onerror {resume}
|
||||
quietly WaveActivateNextPane {} 0
|
||||
add wave -noupdate -format Logic /tb_nco/uut/srst
|
||||
add wave -noupdate -format Logic /tb_nco/uut/clk
|
||||
add wave -noupdate -format Logic /tb_nco/uut/pacc_clr
|
||||
add wave -noupdate -format Logic /tb_nco/uut/pacc_inc
|
||||
add wave -noupdate -format Literal -radix hexadecimal /tb_nco/uut/freq_in
|
||||
add wave -noupdate -format Logic /tb_nco/uut/freq_load
|
||||
add wave -noupdate -format Literal -radix hexadecimal /tb_nco/uut/phase_in
|
||||
add wave -noupdate -format Logic /tb_nco/uut/phase_load
|
||||
add wave -noupdate -format Literal -radix hexadecimal /tb_nco/uut/phase_out
|
||||
add wave -noupdate -format Analog-Step -radix decimal -scale 7.629423635191479e-005 /tb_nco/uut/wave_out_i
|
||||
add wave -noupdate -format Analog-Step -radix decimal -scale 7.629423635191479e-005 /tb_nco/uut/wave_out_q
|
||||
add wave -noupdate -format Logic /tb_nco/uut/out_valid
|
||||
add wave -noupdate -format Literal -radix hexadecimal /tb_nco/uut/debug_out
|
||||
add wave -noupdate -format Literal -radix hexadecimal /tb_nco/uut/phase
|
||||
add wave -noupdate -format Literal -radix hexadecimal /tb_nco/uut/freq_in_r
|
||||
add wave -noupdate -format Literal -radix hexadecimal /tb_nco/uut/phase_in_r
|
||||
add wave -noupdate -format Literal -radix hexadecimal /tb_nco/uut/lut_addr_ud
|
||||
add wave -noupdate -format Literal -radix hexadecimal /tb_nco/uut/lut_addr_d
|
||||
add wave -noupdate -format Literal /tb_nco/uut/wave_i_d
|
||||
add wave -noupdate -format Literal /tb_nco/uut/wave_q_d
|
||||
add wave -noupdate -format Literal /tb_nco/uut/wave_i_ud
|
||||
add wave -noupdate -format Literal /tb_nco/uut/wave_q_ud
|
||||
add wave -noupdate -format Literal /tb_nco/uut/lfsr
|
||||
add wave -noupdate -format Literal /tb_nco/uut/lfsr_out
|
||||
add wave -noupdate -format Logic /tb_nco/uut/lut_addr_valid
|
||||
add wave -noupdate -format Logic /tb_nco/uut/lfsr_valid
|
||||
add wave -noupdate -format Logic /tb_nco/uut/wave_d_valid
|
||||
add wave -noupdate -format Logic /tb_nco/uut/wave_ud_valid
|
||||
TreeUpdate [SetDefaultTree]
|
||||
WaveRestoreCursors {{Cursor 1} {249141632 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 {249024188 ps} {250051359 ps}
|
||||
@@ -0,0 +1,61 @@
|
||||
% Read data
|
||||
function tb_nco_results(nbins)
|
||||
fa = 100.0;
|
||||
f = TEXTREAD('freq.txt')*1E-6
|
||||
|
||||
I_ud = TEXTREAD('q_ud.txt')';
|
||||
I_d = TEXTREAD('q_d.txt')';
|
||||
LFSR = TEXTREAD('lfsr.txt');
|
||||
|
||||
N= length(I_ud);
|
||||
N_fft = min(16384, N);
|
||||
N_fft2 = N_fft/2;
|
||||
|
||||
fft_y2 = 2/N_fft*abs(fft(I_ud(1:N_fft).*hann(N_fft)'));
|
||||
fft_y3 = 2/N_fft*abs(fft(I_d(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);
|
||||
|
||||
[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(1E-6+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 %.1fMHz', 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 -120 0]);
|
||||
subplot(2,1,2)
|
||||
plot(fa/N_fft*(0:N_fft2),20*log10(1E-6+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 %.1fMHz', max_ditherd_spur_value, max_ditherd_spur_freq);
|
||||
legend('With dithering', spur_legend);
|
||||
title('Table');
|
||||
ylabel('dB');
|
||||
xlabel('f/MHz');
|
||||
axis([0 fa/2 -120 0]);
|
||||
|
||||
figure;
|
||||
hist(LFSR, nbins)
|
||||
|
||||
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.05*f
|
||||
if spec(ii) > max_v
|
||||
max_v = spec(ii);
|
||||
max_i = ii;
|
||||
end
|
||||
end;
|
||||
end;
|
||||
Reference in New Issue
Block a user