1) Belli frekansta sinüs LUT oluştur
2) ISE de yukarıdaki dosyayı oku ve FFT sini al
3) Real ve Imaginer Out kısımlarını dosyaya yazdır
4) GNU Plotta çizdir
—————-
1)
Fs : 100MHz
Freq_input : 20MHz
Amp_input : 750 (max. 10 bit)
Length : 4096
FILE *sin_tab;
sin_tab = fopen("sin_tab.txt","w+") ;
pinum = atan2(1.0,1.0) * 4 ;
int Fs = 100000000; // Sampling Rate(Hz)
int L;
double time_interval = (double)1/Fs; //Sampling Period.. i.e. 1ms
comp sin_arr[4096];
int f1 = 20000000;
int f2 = 300; // sine frequencies
for(L=0;L<4096;L++)
{
//sin_arr[L] = (100 * sin(2 * pinum * f1 * L * time_interval ) + (250 * sin(2 * pinum * f2 * L * time_interval )));
sin_arr[L] = (750 * sin(2 * pinum * f1 * L * time_interval ));
fprintf(sin_tab,"%g\n",round(creal(sin_arr[L])));
}
2)
sin_tab içindekiler “real_in.txt” içine yazıldı.
“imag_in.txt” sıfır(0) ile dolduruldu.
-- Stimulus process
stim_proc: process
file re_i_file : TEXT open READ_MODE is "real_in.txt";
file im_i_file : TEXT open READ_MODE is "imag_in.txt";
variable re_in_line: LINE;
variable im_in_line: LINE;
variable vec_var:integer:= 0;
begin
-- hold reset state for 100 ns.
wait for 95 ns;
wait for clk_period*10;
start <= '1' ;
-- insert stimulus here
while not endfile(re_i_file) loop
readline(re_i_file,re_in_line);
read(re_in_line,vec_var);
xn_re <= std_logic_vector(to_signed(vec_var,xn_re'length)) ;
wait until clk = '1' ;
end loop ;
wait;
end process;
3)
Simülasyon sonucunda çıkışın 4096 dan fazla olması ve sıfır ile dolması
önemli değil. Sonraki adımda 4096 için okuma yapılacak.
write_file : process(clk)
file re_o_file : TEXT open WRITE_MODE is "real_out.txt";
file im_o_file : TEXT open WRITE_MODE is "imag_out.txt";
variable re_out_line: LINE;
variable im_out_line: LINE;
begin
if clk = '1' then
if dv = '1' then
write(re_out_line,to_integer(signed(xk_re)));
write(im_out_line,to_integer(signed(xk_im)));
writeline(re_o_file,re_out_line);
writeline(im_o_file,im_out_line);
end if ;
end if;
end process;
4)
cd yap
plot “mags.txt” with line
No comments:
Post a Comment