⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fft_32k_tb.m

📁 FFT 32k use VHDL MATLAB
💻 M
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% file : fft_32K_tb.m%% Description : The following Matlab testbench excercises the Altera FFT Model fft_small_model.m% generated by Altera's FFT Megacore and outputs results to text files.%% Copyright (C) 1988-2005 Altera Corporation                                                % Parameterization Space    N=16384;num_frames = 2;% Read input complex vector from source text files fidr = fopen('..\source\real_input.txt','r');                                            fidi = fopen('..\source\imag_input.txt','r');  foreal = fopen('..\source\real_output_ver.txt', 'r');foimag = fopen('..\source\imag_output_ver.txt', 'r');foexp = fopen('..\source\exponent_output_ver.txt', 'r');xreali=fscanf(fidr,'%d');                                                      ximagi=fscanf(fidi,'%d');                   fftrealo = fscanf(foreal,'%d');fftimago = fscanf(foimag,'%d');fftexpo = fscanf(foexp, '%d');fclose(fidi);                                                                  fclose(fidr);                                                                  % Create input complex row vector from source text files x = xreali' + j*ximagi'; num_sample = max(size(x));top_i = 1;bot_i = 1;for i=1:num_sample    if (mod(i,2) == 0)        x_bot(bot_i) = x(i);        bot_i = bot_i + 1;    else        x_top(top_i) = x(i);        top_i = top_i + 1;    endendfor i=1:num_frames    [y_top((i-1)*N+1:i*N), exp_out_top((i-1)*N+1:i*N)] = fft_small_model(x_top((i-1)*N+1:i*N),N,0);     [y_bot((i-1)*N+1:i*N), exp_out_bot((i-1)*N+1:i*N)] = fft_small_model(x_bot((i-1)*N+1:i*N),N,0); endfor k=1:num_frames    for i=1:N        op_bot((k-1)*2*N+i) = floor((y_bot((k-1)*N+i) * twiddle(i)) / 2^15);        op_top((k-1)*2*N+i) = y_top((k-1)*N+i);        final_fft((k-1)*2*N+i) = op_bot((k-1)*2*N+i) + op_top((k-1)*2*N+i);    endendfor k=1:num_frames    for i=N+1:2*N        op_bot((k-1)*2*N+i) = floor((y_bot((k-1)*N+i-N) * twiddle(i)) / 2^15);        op_top((k-1)*2*N+i) = y_top((k-1)*N+i-N);        final_fft((k-1)*2*N+i) = op_bot((k-1)*2*N+i) + op_top((k-1)*2*N+i);    endend%compare fft_real_outfor k=1:num_frames    for i=1:N*2        comp_real((k-1)*2*N+i,1) = fftrealo((k-1)*2*N+i);        comp_real((k-1)*2*N+i,2) = real(final_fft((k-1)*2*N+i));    endenderror_real = isequal(comp_real(:,1), comp_real(:,2));%compare fft_imag_outfor k=1:num_frames    for i=1:N*2        comp_imag((k-1)*2*N+i,1) = fftimago((k-1)*2*N+i);        comp_imag((k-1)*2*N+i,2) = imag(final_fft((k-1)*2*N+i));    endenderror_imag = isequal(comp_imag(:,1), comp_imag(:,2));if (error_real==1 && error_imag==1)    disp('Simulation passes - Results Match');else    disp('Simulation fails - Results Mismatch');end                                              

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -