OpenCores
URL https://opencores.org/ocsvn/wdsp/wdsp/trunk

Subversion Repositories wdsp

[/] [wdsp/] [trunk/] [sw/] [matlab-scripts/] [fft/] [plotdata.m] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 parrado
function plotdata(infile,outfile,ibin,fbin,add_g,mult_g,N)
2
%  plotdata(infile,outfile,ibin,fbin,add_g,mult_g,N)
3
%   Reads in from infile (test vectors sent into fft_f         iled_tb
4
%   and outfile (output of fft_filed_tb, usually data.out)
5
%
6
%   ibin is integer b its in the input.
7
%   fbin is fractio na l bits in the input.
8
%   add_g is the add er growth.
9
%    mult_g is the mu ltiplier growth.
10
%    N  is the number of points in the FFT.
11
%
12
%   This prog  ram us es:
13
%       str2fr ac.m
14
%
15
clf
16
fout=fopen(outfile);
17
ibout=ibin+add_g*log2(  N);
18
if mult_g >0
19
    ibout=ibout+floor((  log2(N)-1)/2);
20
end;
21
fbout =fbi n+(floor((log2(N)-1)/2)*(mult_g-1));
22
dp =ibo ut+fbout;
23
dp2=2*dp;
24
A=(fscanf(fout,'%  s',[dp2,inf]))';
25
[nr ,nc]=size(A);
26
hold on;
27
offset=N+2  ;
28
%getting fi rst outputs
29
if (N+offset)<=nr
30
    for k=offset+1:offset+N
31
        out1r(k-offset)= str2frac  (A(k,1:dp),ibout,fbout);
32
        out1i(k-offset)=str2frac(A(k,     dp+1:dp2),ibout,fbout);
33
    end
34
 out1r=out1r';
35
 out1i=out1i';
36
  %Bit reversing and r        ecombining outputs
37
 for k=0:(N-1)
38
        bitorder=dec2bin(k,log2(N));
39
        for m=1:(size(bi torder,2)/2)
40
             temp=bitorder (m);
41
 
42
 
43
             bitorder(m)=bitorder(size(bitorder,2)+1-m);
44
            bitorder(size (bitorder,2)+1-m)=temp;
45
        end
46
        bitrevpos=bin2dec(bitorder);
47
        adata(bitrevpos+1)=out1r(k+1)+i*out1i(k       +1);
48
    end
49
    subplot(2,2,1),plot(fftshift(abs(adata)),'k'),axis tight,
50
    title( 'Magnitude of FFT of Sinc Wave Input'),hold on;
51
    subplot (2,2,2),plot(fftshift(angle(adata)),'k'),axis tight,
52
    title('Angle of FFT of  Sinc Wave Input'),hold on;
53
end
54
%getting second outputs
55
offset=offset+N;
56
if (N +offset)<=nr
57
     for k=offset+1:offset+N
58
        out1r(k- offset)=str2frac(A(k,1:dp),ibout,fbout);
59
         out1i(k-offset)=str2frac(A(k,dp+1:dp2),ibout,fbout);
60
    end
61
    out1r=out1r';
62
 out1i=out1i';
63
  %Bit reversing and recombining outputs
64
 for k=0:(N-1)
65
        bitorder=dec2bin(k,log2(N));
66
        for m=1:(size(bitorder,2)/2)
67
            temp=bitorder(m);
68
            bitorder(m)=bitorder(size(bitorder,2)+1-m);
69
            bitorder(size(bitorder,2)+1-m)=temp;
70
        end
71
          bitrevpos=bin2dec(bitorder);
72
        bdata(bitrevpos+1)=out1r(k+1)+i*out1i(k+1);
73
 end
74
 subplot( 2,2,3),plot(fftshift(real(bdata)),'k'),axis tight,
75
    title('Real p art of FFT of Square wave input'),hold on;
76
 subplot(2 ,2 ,4),plot(fftshift(imag(bdata)),'k'),axis tight,
77
    title('Imaginary part of FF    T of Square wave input'),hold on;
78
end
79
 
80
 
81
%getting input waves from testvec and outputt       ing them on same plots
82
fin=fopen(infile);
83
dp=ibin+fbin;
84
dp2=2*dp+2;
85
dp=dp+2;
86
A=(fscanf(fin,'%s',[dp2  ,inf]))';
87
[nr,nc]=size (A);
88
 
89
offset=2;
90
%getting first inputs
91
if (N+offset)<=nr
92
    for k=offset+1:offse  t+N
93
        outd ata(k-offset )=str2frac(A(k,3:dp),ibin,fbin) +
94
i*str2frac(A(k,dp+1:dp 2),ibin,fbin);
95
    end
96
    afftdata=fft(outdata );
97
 
98
 
99
    subplot(2,2,1),plot(fftshift(abs(afftdata)));
100
    subpl ot(2,2,2),plot(fftshift(angle(afftdata)));
101
end
102
 
103
%getting second inputs
104
offset=offset+N;
105
if (N+offset)<=nr
106
    for k=offset+1:offset+ N
107
         outdata(k-offset)=str2frac(A(k,3:dp),ibin,fbin) +
108
i*str2frac(A(k,dp+1:dp 2),ibin,fbin);
109
     end
110
    bfftda  ta=fft(outdata);
111
    subplo t(2,2,3),plot(fftshift(real(bfftdata)));
112
    subplot(2,2,4),plot(fftshift(imag(bfftdata)));
113
end
114
 
115
 
116
fclose('all');

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.