基于FPGA的DDS参考设计
DDS内核电路的 RTL View |
DDS内核电路的Quartus仿真波形 |
DDS电路的SignalTAP输出波形 |
DDS电路的SignalTAP输出波形数据频谱分析 |
DDS相位累加频率合成的原理 |
%//////////////////////////////////////////////////////////////////////////////// % USUAGE : demo the dds principle % AUTHOR : duweitao AT cuc.edu.cn % DATE : 2011-11-15 %//////////////////////////////////////////////////////////////////////////////// N_rom = 16; % number of rom data N_plot = 32; % number of sine wave plot points idx_N = [0:N_rom-1] ; % rom index acc_WL = 5; % phase acc word length in bits rom_WL = log2(N_rom); % wave table rom word length acc_inc_val_1 = 1; % acc increase value acc_inc_val_2 = 2; acc_inc_val_3 = 4; max_acc_val = 2^acc_WL - 1; rom_data = sin(2*pi*idx_N/N_rom); acc_val_plot = zeros(3,N_plot); idx_plot = [0:N_plot-1]; % plot index acc_val_plot(1,:) = mod(idx_plot*acc_inc_val_1, max_acc_val); acc_val_plot(2,:) = mod(idx_plot*acc_inc_val_2, max_acc_val); acc_val_plot(3,:) = mod(idx_plot*acc_inc_val_3, max_acc_val); wav_val_plot = zeros(3,N_plot); rom_addr = bitshift(acc_val_plot,rom_WL-acc_WL); wav_val_plot(1,:) = rom_data(rom_addr(1,:)+1); wav_val_plot(2,:) = rom_data(rom_addr(2,:)+1); wav_val_plot(3,:) = rom_data(rom_addr(3,:)+1); figure; subplot(3,1,1); stem(idx_plot, wav_val_plot(1,:), 'fill'); title_str = sprintf('DDS Sine Wave, %dbit ACC, %dbit ROM ADDRESS, ACC INCREASE VAL is %d ', ... acc_WL, rom_WL, acc_inc_val_1); title(title_str, 'FontSize', 14); for(i_loop = 0:N_plot-1) text(i_loop +0.1,0.1*sign(wav_val_plot(1,i_loop+1)+1E-10),... num2str(acc_val_plot(1,i_loop+1)),'FontSize',12, 'color', 'r') ; text(i_loop +0.1,0.3*sign(wav_val_plot(1,i_loop+1)+1E-10),... num2str(rom_addr(1,i_loop+1)),'FontSize',12, 'color', 'k') ; end; subplot(3,1,2); stem(idx_plot, wav_val_plot(2,:), 'fill'); title_str = sprintf('DDS Sine Wave, %dbit ACC, %dbit ROM ADDRESS, ACC INCREASE VAL is %d ', ... acc_WL, rom_WL, acc_inc_val_2); title(title_str, 'FontSize', 14); for(i_loop = 0:N_plot-1) text(i_loop +0.1,0.1*sign(wav_val_plot(2,i_loop+1)+1E-10),... num2str(acc_val_plot(2,i_loop+1)),'FontSize',12, 'color', 'r') ; text(i_loop +0.1,0.3*sign(wav_val_plot(2,i_loop+1)+1E-10),... num2str(rom_addr(2,i_loop+1)),'FontSize',12, 'color', 'k') ; end; subplot(3,1,3); stem(idx_plot, wav_val_plot(3,:), 'fill'); title_str = sprintf('DDS Sine Wave, %dbit ACC, %dbit ROM ADDRESS, ACC INCREASE VAL is %d ', ... acc_WL, rom_WL, acc_inc_val_3); title(title_str, 'FontSize', 14); for(i_loop = 0:N_plot-1) text(i_loop +0.1,0.1*sign(wav_val_plot(3,i_loop+1)+1E-10),... num2str(acc_val_plot(3,i_loop+1)),'FontSize',12, 'color', 'r') ; text(i_loop +0.1,0.3*sign(wav_val_plot(3,i_loop+1)+1E-10),... num2str(rom_addr(3,i_loop+1)),'FontSize',12, 'color', 'k') ; end;