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

Subversion Repositories dblclockfft

[/] [dblclockfft/] [trunk/] [rtl/] [ifftmain.v] - Blame information for rev 39

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 36 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    ifftmain.v
4
//
5
// Project:     A General Purpose Pipelined FFT Implementation
6
//
7
// Purpose:     This is the main module in the General Purpose FPGA FFT
8
//              implementation.  As such, all other modules are subordinate
9
//      to this one.  This module accomplish a fixed size Complex FFT on
10
//      2048 data points.
11 39 dgisselq
//      The FFT is fully pipelined, and accepts as inputs one complex two's
12
//      complement sample per clock.
13 36 dgisselq
//
14
// Parameters:
15
//      i_clk   The clock.  All operations are synchronous with this clock.
16
//      i_reset Synchronous reset, active high.  Setting this line will
17
//                      force the reset of all of the internals to this routine.
18
//                      Further, following a reset, the o_sync line will go
19
//                      high the same time the first output sample is valid.
20
//      i_ce    A clock enable line.  If this line is set, this module
21 39 dgisselq
//                      will accept one complex input value, and produce
22
//                      one (possibly empty) complex output value.
23
//      i_sample        The complex input sample.  This value is split
24 36 dgisselq
//                      into two two's complement numbers, 15 bits each, with
25
//                      the real portion in the high order bits, and the
26
//                      imaginary portion taking the bottom 15 bits.
27 39 dgisselq
//      o_result        The output result, of the same format as i_sample,
28 36 dgisselq
//                      only having 21 bits for each of the real and imaginary
29
//                      components, leading to 42 bits total.
30 39 dgisselq
//      o_sync  A one bit output indicating the first sample of the FFT frame.
31
//                      It also indicates the first valid sample out of the FFT
32
//                      on the first frame.
33 36 dgisselq
//
34
// Arguments:   This file was computer generated using the following command
35
//              line:
36
//
37 39 dgisselq
//              % ./fftgen -i -d ../rtl -f 2048 -1 -k 1 -p 0 -n 15 -a ../bench/cpp/ifftsize.h
38 36 dgisselq
//
39 39 dgisselq
//      This core will use hardware accelerated multiplies (DSPs)
40
//      for 0 of the 11 stages
41
//
42 36 dgisselq
// Creator:     Dan Gisselquist, Ph.D.
43
//              Gisselquist Technology, LLC
44
//
45
////////////////////////////////////////////////////////////////////////////////
46
//
47
// Copyright (C) 2015-2018, Gisselquist Technology, LLC
48
//
49 39 dgisselq
// This file is part of the general purpose pipelined FFT project.
50 36 dgisselq
//
51 39 dgisselq
// The pipelined FFT project is free software (firmware): you can redistribute
52
// it and/or modify it under the terms of the GNU Lesser General Public License
53
// as published by the Free Software Foundation, either version 3 of the
54
// License, or (at your option) any later version.
55 36 dgisselq
//
56 39 dgisselq
// The pipelined FFT project is distributed in the hope that it will be useful,
57
// but WITHOUT ANY WARRANTY; without even the implied warranty of
58
// MERCHANTIBILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
59
// General Public License for more details.
60
//
61
// You should have received a copy of the GNU Lesser General Public License
62
// along with this program.  (It's in the $(ROOT)/doc directory.  Run make
63
// with no target there if the PDF file isn't present.)  If not, see
64 36 dgisselq
// <http://www.gnu.org/licenses/> for a copy.
65
//
66 39 dgisselq
// License:     LGPL, v3, as defined and found on www.gnu.org,
67
//              http://www.gnu.org/licenses/lgpl.html
68 36 dgisselq
//
69
//
70
////////////////////////////////////////////////////////////////////////////////
71
//
72
//
73
`default_nettype        none
74
//
75
//
76
//
77
module ifftmain(i_clk, i_reset, i_ce,
78 39 dgisselq
                i_sample, o_result, o_sync);
79
        // The bit-width of the input, IWIDTH, output, OWIDTH, and the log
80
        // of the FFT size.  These are localparams, rather than parameters,
81
        // because once the core has been generated, they can no longer be
82
        // changed.  (These values can be adjusted by running the core
83
        // generator again.)  The reason is simply that these values have
84
        // been hardwired into the core at several places.
85
        localparam      IWIDTH=15, OWIDTH=21, LGWIDTH=11;
86 36 dgisselq
        //
87 39 dgisselq
        input   wire                            i_clk, i_reset, i_ce;
88 36 dgisselq
        //
89 39 dgisselq
        input   wire    [(2*IWIDTH-1):0] i_sample;
90
        output  reg     [(2*OWIDTH-1):0] o_result;
91 36 dgisselq
        output  reg                             o_sync;
92
 
93
 
94
        // Outputs of the FFT, ready for bit reversal.
95 39 dgisselq
        wire    [(2*OWIDTH-1):0] br_sample;
96 36 dgisselq
 
97
 
98
        wire            w_s2048;
99 39 dgisselq
        wire    [31:0]   w_d2048;
100
        fftstage        #(IWIDTH,IWIDTH+4,16,10,0,
101
                        0, 1, "icmem_2048.hex")
102
                stage_2048(i_clk, i_reset, i_ce,
103
                        (!i_reset), i_sample, w_d2048, w_s2048);
104 36 dgisselq
 
105
 
106
        wire            w_s1024;
107 39 dgisselq
        wire    [33:0]   w_d1024;
108
        fftstage        #(16,20,17,9,0,
109
                        0, 1, "icmem_1024.hex")
110
                stage_1024(i_clk, i_reset, i_ce,
111
                        w_s2048, w_d2048, w_d1024, w_s1024);
112 36 dgisselq
 
113
        wire            w_s512;
114 39 dgisselq
        wire    [33:0]   w_d512;
115
        fftstage        #(17,21,17,8,0,
116
                        0, 1, "icmem_512.hex")
117
                stage_512(i_clk, i_reset, i_ce,
118
                        w_s1024, w_d1024, w_d512, w_s512);
119 36 dgisselq
 
120
        wire            w_s256;
121 39 dgisselq
        wire    [35:0]   w_d256;
122
        fftstage        #(17,21,18,7,0,
123
                        0, 1, "icmem_256.hex")
124
                stage_256(i_clk, i_reset, i_ce,
125
                        w_s512, w_d512, w_d256, w_s256);
126 36 dgisselq
 
127
        wire            w_s128;
128 39 dgisselq
        wire    [35:0]   w_d128;
129
        fftstage        #(18,22,18,6,0,
130
                        0, 1, "icmem_128.hex")
131
                stage_128(i_clk, i_reset, i_ce,
132
                        w_s256, w_d256, w_d128, w_s128);
133 36 dgisselq
 
134
        wire            w_s64;
135 39 dgisselq
        wire    [37:0]   w_d64;
136
        fftstage        #(18,22,19,5,0,
137
                        0, 1, "icmem_64.hex")
138
                stage_64(i_clk, i_reset, i_ce,
139
                        w_s128, w_d128, w_d64, w_s64);
140 36 dgisselq
 
141
        wire            w_s32;
142 39 dgisselq
        wire    [37:0]   w_d32;
143
        fftstage        #(19,23,19,4,0,
144
                        0, 1, "icmem_32.hex")
145
                stage_32(i_clk, i_reset, i_ce,
146
                        w_s64, w_d64, w_d32, w_s32);
147 36 dgisselq
 
148
        wire            w_s16;
149 39 dgisselq
        wire    [39:0]   w_d16;
150
        fftstage        #(19,23,20,3,0,
151
                        0, 1, "icmem_16.hex")
152
                stage_16(i_clk, i_reset, i_ce,
153
                        w_s32, w_d32, w_d16, w_s16);
154 36 dgisselq
 
155
        wire            w_s8;
156 39 dgisselq
        wire    [39:0]   w_d8;
157
        fftstage        #(20,24,20,2,0,
158
                        0, 1, "icmem_8.hex")
159
                stage_8(i_clk, i_reset, i_ce,
160
                        w_s16, w_d16, w_d8, w_s8);
161 36 dgisselq
 
162
        wire            w_s4;
163 39 dgisselq
        wire    [41:0]   w_d4;
164
        qtrstage        #(20,21,11,1,0)  stage_4(i_clk, i_reset, i_ce,
165
                                                w_s8, w_d8, w_d4, w_s4);
166 36 dgisselq
        wire            w_s2;
167 39 dgisselq
        wire    [41:0]   w_d2;
168 36 dgisselq
        laststage       #(21,21,0)       stage_2(i_clk, i_reset, i_ce,
169 39 dgisselq
                                        w_s4, w_d4, w_d2, w_s2);
170 36 dgisselq
 
171
 
172
        // Prepare for a (potential) bit-reverse stage.
173 39 dgisselq
        assign  br_sample= w_d2;
174 36 dgisselq
 
175
        wire    br_start;
176
        reg     r_br_started;
177
        initial r_br_started = 1'b0;
178
        always @(posedge i_clk)
179
                if (i_reset)
180
                        r_br_started <= 1'b0;
181
                else if (i_ce)
182
                        r_br_started <= r_br_started || w_s2;
183
        assign  br_start = r_br_started || w_s2;
184
 
185
        // Now for the bit-reversal stage.
186
        wire    br_sync;
187 39 dgisselq
        wire    [(2*OWIDTH-1):0] br_o_result;
188 36 dgisselq
        bitreverse      #(11,21)
189
                revstage(i_clk, i_reset,
190 39 dgisselq
                        (i_ce & br_start), br_sample,
191
                        br_o_result, br_sync);
192 36 dgisselq
 
193
 
194
        // Last clock: Register our outputs, we're done.
195
        initial o_sync  = 1'b0;
196
        always @(posedge i_clk)
197
                if (i_reset)
198
                        o_sync  <= 1'b0;
199
                else if (i_ce)
200
                        o_sync  <= br_sync;
201
 
202
        always @(posedge i_clk)
203
                if (i_ce)
204 39 dgisselq
                        o_result  <= br_o_result;
205 36 dgisselq
 
206
 
207
endmodule

powered by: WebSVN 2.1.0

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