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

Subversion Repositories fft_fir_filter

[/] [fft_fir_filter/] [trunk/] [rtl/] [fftdpathi.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 unicore
---------------------------------------------------------------------
2
----                                                             ----
3
----  FFT Filter IP core                                         ----
4
----                                                             ----
5
----  Authors: Anatoliy Sergienko, Volodya Lepeha                ----
6
----  Company: Unicore Systems http://unicore.co.ua              ----
7
----                                                             ----
8
----  Downloaded from: http://www.opencores.org                  ----
9
----                                                             ----
10
---------------------------------------------------------------------
11
----                                                             ----
12
---- Copyright (C) 2006-2010 Unicore Systems LTD                 ----
13
---- www.unicore.co.ua                                           ----
14
---- o.uzenkov@unicore.co.ua                                     ----
15
----                                                             ----
16
---- This source file may be used and distributed without        ----
17
---- restriction provided that this copyright statement is not   ----
18
---- removed from the file and that any derivative work contains ----
19
---- the original copyright notice and the associated disclaimer.----
20
----                                                             ----
21
---- THIS SOFTWARE IS PROVIDED "AS IS"                           ----
22
---- AND ANY EXPRESSED OR IMPLIED WARRANTIES,                    ----
23
---- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED                  ----
24
---- WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT              ----
25
---- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.        ----
26
---- IN NO EVENT SHALL THE UNICORE SYSTEMS OR ITS                ----
27
---- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,            ----
28
---- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL            ----
29
---- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT         ----
30
---- OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,               ----
31
---- DATA, OR PROFITS; OR BUSINESS INTERRUPTION)                 ----
32
---- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,              ----
33
---- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT              ----
34
---- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING                 ----
35
---- IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,                 ----
36
---- EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.          ----
37
----                                                             ----
38
---------------------------------------------------------------------
39
 
40
-- AUTHORS      Volodymir Lepekha,              
41
--              Anatoli Sergyienko.
42
--HISTORY       :07.2005 mode added:
43
--           00 - multiply by window
44
--           01 - butterfly
45
--           10 - restore for real FFT     
46
-- only for Virtex2 and later   
47
--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~           
48
 
49
 
50
 
51
library IEEE;
52
use IEEE.std_logic_1164.all;
53
use IEEE.std_logic_arith.all;
54
 
55
entity FFTDPATHI is
56
        generic (width: integer :=8     ;               --  word width =8...24
57
                Wwdth: integer:=7;                      --  coefficient width =7...15  
58
                reall:integer;
59
                V2:integer
60
                );
61
        port (
62
                CLK: in STD_LOGIC;
63
                RST: in STD_LOGIC;
64
                CE: in STD_LOGIC;
65
                ODDC: in STD_LOGIC;      --
66
                DIV2: in STD_LOGIC;             --Scaling factor
67
                ZWR: in STD_LOGIC;
68
                ZWI: in STD_LOGIC;
69
                SIGNRE:  in STD_LOGIC;
70
                MODE: in STD_LOGIC_VECTOR (1 downto 0);--00-umnozenie na okno, 01-FFT,10-wosstanowlenie 
71
                REDI: in STD_LOGIC_VECTOR (width downto 0);
72
                IMDI: in STD_LOGIC_VECTOR (width downto 0);
73
                WF: in STD_LOGIC_VECTOR (wwdth-1 downto 0);
74
                REDO: out STD_LOGIC_VECTOR (width downto 0);
75
                IMDO: out STD_LOGIC_VECTOR (width downto 0)
76
                );
77
end FFTDPATHI;
78
 
79
 
80
architecture FFTDPATH_s of FFTDPATHI is
81
 
82
        constant zeros: STD_LOGIC_VECTOR (width-wwdth downto 0):=
83
        CONV_STD_LOGIC_VECTOR(0,width-wwdth+1);
84
        signal  ar,ai,ar3,ai3:    STD_LOGIC_VECTOR (width-1 downto 0);
85
        signal  br1,bi1,br,bi,br2,bi2:    STD_LOGIC_VECTOR (width-1 downto 0);
86
        signal renorm,imnorm,br4,bi4:     STD_LOGIC_VECTOR (width-1 downto 0);
87
        signal ard,aid:   STD_LOGIC_VECTOR (3 downto 0);
88
        signal wr,wr1:    STD_LOGIC_VECTOR (wwdth-1 downto 0);
89
        signal prodrb,prodib: STD_LOGIC_VECTOR (width+wwdth downto 0);
90
        signal prodr1,prodi1: STD_LOGIC_VECTOR (width+wwdth-2 downto wwdth-2);
91
        signal prodr2,prodi2: STD_LOGIC_VECTOR (width+wwdth-1 downto wwdth-2);
92
        signal prodr,prodi,prodrd,prodid: STD_LOGIC_VECTOR (width downto 0);
93
        signal cr,ci:     STD_LOGIC_VECTOR (width downto 0);
94
        signal dr,di:     STD_LOGIC_VECTOR (width+2 downto 0);
95
        signal zwri,zwii,zwr1,zwi1,zwr2,zwi2,signrei,signre1,signre2: STD_LOGIC;
96
 
97
 
98
begin
99
 
100
        SHIFT:process(REDI,IMDI,DIV2)
101
        begin
102
                if DIV2='1' then
103
                        renorm <=  REDI (width downto 1);
104
                        imnorm <= IMDI (width downto 1);
105
                else
106
                        renorm <= REDI(width-1 downto 0);
107
                        imnorm <= IMDI(width-1 downto 0);
108
                end if;
109
        end process;
110
 
111
        RDELAY:process(CLK,RST)
112
        begin
113
                if RST = '1' then
114
                        wr <= (others =>'0');
115
                        wr1 <= (others =>'0');
116
                        ar <= (others =>'0');
117
                        br <= (others =>'0');
118
                        br1<= (others =>'0');
119
                        br2 <= (others =>'0');
120
                        ar3 <= (others =>'0');
121
                        br4 <= (others =>'0');
122
                        ai <= (others =>'0');
123
                        bi <= (others =>'0');
124
                        bi1<= (others =>'0');
125
                        bi2 <= (others =>'0');
126
                        ai3 <= (others =>'0');
127
                        bi4 <= (others =>'0');
128
                elsif CLK = '1' and CLK'event then
129
                        if CE = '1' then
130
                                wr<=WF;
131
                                wr1<=wr;
132
                                br2<=br1;
133
                                bi2<=bi1;
134
                                if ODDC='0' or mode="00" or mode="11" then
135
                                        ar<= renorm;
136
                                        ar3<=ar;
137
                                        br4<=br2;
138
                                        ai<= imnorm;
139
                                        ai3<=ai;
140
                                        bi4<=bi2;
141
                                else
142
                                        br<= renorm;
143
                                        br1<=br;
144
                                        bi<= imnorm;
145
                                        bi1<=bi;
146
                                end if;
147
                        end if;
148
                end if;
149
        end process;
150
 
151
        TTDELAY:process(CLK,RST)
152
        begin
153
                if RST='1' then
154
                        zwri<='0';
155
                        zwii<='0';
156
                        zwr1<='0';
157
                        zwi1<='0';
158
                        zwr2<='0';
159
                        zwi2<='0';
160
                        signrei<='0';
161
                        signre1<='0';
162
                        signre2<='0';
163
                elsif CLK='1' and CLK'event then
164
                        if CE='1' then
165
                                zwri<=ZWR;
166
                                zwii<=ZWI;
167
                                zwr1<=zwri;
168
                                zwi1<=zwii;
169
                                zwr2<=zwr1;
170
                                zwi2<=zwi1;
171
                                signrei<=SIGNRE;
172
                                signre1<=signrei;
173
                                signre2<=signre1;
174
                        end if;
175
                end if;
176
        end process;
177
 
178
 
179
 
180
 
181
 
182
        BLCK:if v2=1 generate
183
                MPU_U:  process(CLK,RST)
184
                        variable prodr,prodi:STD_LOGIC_VECTOR(width+wwdth-2 downto 0);
185
                        variable minusre,minusim:STD_LOGIC;
186
                begin
187
                        if RST = '1' then
188
                                prodrb <= (others =>'0');
189
                                prodr2 <= (others =>'0');
190
                                prodib <= (others =>'0');
191
                                prodi2 <= (others =>'0');
192
 
193
                        elsif CLK = '1' and CLK'event then
194
                                if CE = '1' then
195
                                        prodrb <= signed('0'& wr) * signed(ar);
196
                                        prodib <= signed('0'& wr) * signed(ai);
197
 
198
                                        prodr2<=prodrb(width+wwdth-1 downto wwdth-2);
199
                                        prodi2<=prodib(width+wwdth-1 downto wwdth-2);
200
                                end if;
201
                        end if;
202
                end process;
203
        end generate;
204
 
205
        prodr<=prodr2( width+wwdth-1 downto wwdth-1);
206
        prodi<=prodi2( width+wwdth-1 downto wwdth-1);
207
 
208
        RPRODD: process(CLK,RST)
209
        begin
210
 
211
                if RST='1' then
212
                        prodrd<=(others=>'0');
213
                        prodid<=(others=>'0');
214
                elsif CLK='1' and CLK'event then
215
                        if CE ='1' then
216
                                if signre1='1' then
217
                                        prodrd<= - signed(prodr);
218
                                        prodid<= - signed(prodi);
219
                                else
220
                                        prodrd<=prodr;
221
                                        prodid<=prodi;
222
                                end if;
223
                        end if;
224
                end if;
225
        end process;
226
 
227
        ACPROD:process(RST,CLK)
228
        begin
229
                if RST='1' then
230
                        cr<=(others=>'0');
231
                        ci<=(others=>'0');
232
                elsif CLK='1' and CLK'event then
233
                        if CE ='1' and ODDC='0' then
234
                                if zwi2='1' then
235
                                        cr <= ar3&'0';
236
                                        ci <= ai3&'0';
237
                                elsif zwr2='1' then
238
                                        cr <= 0- signed(ai3&'0');
239
                                        ci <= ar3&'0';
240
                                else-- if signre2='1' then
241
                                        --                                                      cr<= 0- signed(prodrd)-signed(prodi);
242
                                        --                                                      ci<= 0- signed(prodid)+signed(prodr);
243
                                        --                                              else
244
                                        cr<=  signed(prodrd)-signed(prodi);
245
                                        ci<=  signed(prodid)+signed(prodr);
246
                                        --      end if;
247
                                end if;
248
                        end if;
249
                end if;
250
        end process;
251
 
252
        ABUTTERF:process(CLK,RST)
253
        begin
254
                if RST='1' then
255
                        dr<=(others=>'0');
256
                        di<=(others=>'0');
257
                elsif CLK='1' and CLK'event then
258
                        if CE ='1' then
259
                                case MODE is
260
                                        when "00" => dr<=prodr&"01";
261
                                        di<=prodI&"01" ;
262
                                        when "11" =>             -- *jW
263
                                        if ODDC='0' and reall=0 then
264
                                                dr<=0-signed(prodi&"01");  --posle n/2
265
                                                di<=prodr&"01" ;
266
                                        else
267
                                                dr<=prodi&"01";
268
                                                di<=0-signed(prodr&"00") ; -- do n/2
269
                                        end if;
270
                                        when "01" => --butterfly
271
                                        if ODDC='1' then                              --addition with rounding
272
                                                dr<=signed(br4&"01")+signed( cr(width)&cr&'1');
273
                                                di<=signed(bi4&"01")+signed( ci(width)&ci&'1');
274
                                        else
275
                                                dr<=signed(br4&"01")-signed( cr(width)&cr&'1');
276
                                                di<=signed(bi4&"01")-signed( ci(width)&ci&'1');
277
                                        end if;
278
 
279
                                        when others=>   -- Wosstanowlenie
280
                                        if ODDC='1' then                              --addition with rounding
281
                                                dr<=signed(br4&"01")-signed( ci(width)&ci&'1');
282
                                                di<=signed(bi4&"01")+signed( cr(width)&cr&'1');
283
                                        else
284
                                                dr<=signed(br4&"01")+signed( ci(width)&ci&'1');
285
                                                di<=signed( cr(width)&cr&'1')- signed(bi4&"01");
286
                                        end if;
287
                                end case ;
288
                        end if;
289
                end if;
290
        end process;
291
 
292
        REDO<=  dr(width+2 downto 2) ;
293
        IMDO<=  di(width+2 downto 2);
294
 
295
 
296
end FFTDPATH_s;

powered by: WebSVN 2.1.0

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