URL
https://opencores.org/ocsvn/versatile_fft/versatile_fft/trunk
Details |
Compare with Previous |
View Log
Line No. |
Rev |
Author |
Line |
1 |
2 |
wzab |
% Modify the length of the FFT in the line below
|
2 |
|
|
log2fftlen = 10;
|
3 |
|
|
% If you modify the number of bits used to represent
|
4 |
|
|
% real and imaginary part of the complex number,
|
5 |
|
|
% you should also modify the ICPX_WIDTH constant
|
6 |
|
|
% in the icpx_pkg.vhd file
|
7 |
|
|
icpx_width = 16;
|
8 |
|
|
% Do not modify below
|
9 |
|
|
% Write the package defining length of the FFT
|
10 |
|
|
fo=fopen("src/fft_len.vhd","w");
|
11 |
|
|
fprintf(fo,"package fft_len is\n");
|
12 |
|
|
fprintf(fo,"constant LOG2_FFT_LEN : integer := %d;\n",log2fftlen);
|
13 |
|
|
fprintf(fo,"end fft_len;\n");
|
14 |
|
|
fclose(fo)
|
15 |
|
|
fftlen=2 ** log2fftlen;
|
16 |
|
|
%Generate the data. Now it is only a noise, but you
|
17 |
|
|
%can generate something with periodic components
|
18 |
|
|
%It is important, that values fit in range of representation
|
19 |
|
|
%(-2,2) for standard implementation.
|
20 |
|
|
%May be changed if you redefine our icpx_number format
|
21 |
|
|
re=3*rand(1,fftlen)-1.5;
|
22 |
|
|
im=3*rand(1,fftlen)-1.5;
|
23 |
|
|
fo=fopen("data_in.txt","w");
|
24 |
|
|
for i=1:fftlen
|
25 |
|
|
fprintf(fo,"%g %g\n",re(i),im(i));
|
26 |
|
|
end
|
27 |
|
|
fclose(fo)
|
28 |
|
|
scale = 2 ** (icpx_width-2);
|
29 |
|
|
di = (re+j*im)*scale/fftlen;
|
30 |
|
|
fr = fft(di);
|
31 |
|
|
fo=fopen("data_oct.txt","w");
|
32 |
|
|
for i=1:fftlen
|
33 |
|
|
fprintf(fo,"%d %d\n",floor(real(fr(i))),floor(imag(fr(i))));
|
34 |
|
|
end
|
35 |
|
|
fclose(fo)
|
36 |
|
|
%Run the simulation
|
37 |
|
|
system("make clean; make")
|
38 |
|
|
%Compare results calculated in octave and in our IP core
|
39 |
|
|
system("vim -d data_oct.txt data_out.txt")
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.