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

Subversion Repositories astron_wb_fft

[/] [astron_wb_fft/] [trunk/] [fft_r2_bf_par.vhd] - Blame information for rev 2

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 danv
--------------------------------------------------------------------------------
2
--   Author: Harm Jan Pepping : HJP at astron.nl: Jun 2012
3
--   Copyright (C) 2009-2010
4
--   ASTRON (Netherlands Institute for Radio Astronomy)
5
--   P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
6
--
7
--   This file is part of the UniBoard software suite.
8
--   The file is free software: you can redistribute it and/or modify
9
--   it under the terms of the GNU General Public License as published by
10
--   the Free Software Foundation, either version 3 of the License, or
11
--   (at your option) any later version.
12
--
13
--   This program is distributed in the hope that it will be useful,
14
--   but WITHOUT ANY WARRANTY; without even the implied warranty of
15
--   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
--   GNU General Public License for more details.
17
--
18
--   You should have received a copy of the GNU General Public License
19
--   along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
--------------------------------------------------------------------------------
21
--
22
-- Purpose: The fft_r2_bf_par describes a parallel complex butterfly.
23
--
24
-- Description: Output x is defined as x+y
25
--              Output y is defined as (x-y)*W
26
--             
27
--
28
-- Remarks: 
29
-- 
30
 
31
library ieee, common_pkg_lib, common_components_lib, common_requantize_lib, rTwoSDF_lib;
32
use IEEE.std_logic_1164.all;
33
use common_pkg_lib.common_pkg.all;
34
use common_pkg_lib.common_str_pkg.all;
35
use rTwoSDF_lib.twiddlesPkg.all;
36
use rTwoSDF_lib.rTwoSDFPkg.all;
37
use work.fft_pkg.all;
38
 
39
entity fft_r2_bf_par is
40
  generic (
41
    g_stage        : natural := 3;
42
    g_element      : natural := 1;
43
    g_scale_enable : boolean := TRUE;
44
    -- internal pipeline settings
45
    g_pipeline    : t_fft_pipeline := c_fft_pipeline  -- defined in rTwoSDF_lib.rTwoSDFPkg
46
  );
47
  port (
48
    clk      : in  std_logic;
49
    rst      : in  std_logic;
50
    x_in_re  : in  std_logic_vector;
51
    x_in_im  : in  std_logic_vector;
52
    y_in_re  : in  std_logic_vector;
53
    y_in_im  : in  std_logic_vector;
54
    in_val   : in  std_logic;
55
    x_out_re : out std_logic_vector;
56
    x_out_im : out std_logic_vector;
57
    y_out_re : out std_logic_vector;
58
    y_out_im : out std_logic_vector;
59
    out_val  : out std_logic
60
  );
61
end entity fft_r2_bf_par;
62
 
63
architecture str of fft_r2_bf_par is
64
 
65
  -- The amplification factor per stage is 2, therefor bit growth defintion of 1.
66
  -- Scale enable is defined by generic.
67
  constant c_stage_bit_growth : natural := sel_a_b(g_scale_enable, 1, 0);
68
 
69
  constant c_out_dat_w     : natural := x_out_re'length;  -- re and im have same width  
70
 
71
  constant c_bf_in_a_zdly  : natural := 0;  -- No delays in bf_stage, since they only apply to one in- or output
72
  constant c_bf_out_b_zdly : natural := 0;  -- No delays in bf_stage, since they only apply to one in- or output
73
 
74
  signal sum_re             : std_logic_vector(x_out_re'range);
75
  signal sum_im             : std_logic_vector(x_out_im'range);
76
  signal sum_quant_re       : std_logic_vector(x_out_re'range);
77
  signal sum_quant_im       : std_logic_vector(x_out_im'range);
78
 
79
  signal dif_re             : std_logic_vector(y_out_re'range);
80
  signal dif_im             : std_logic_vector(y_out_im'range);
81
 
82
  signal dif_out_re         : std_logic_vector(y_out_re'range);
83
  signal dif_out_im         : std_logic_vector(y_out_im'range);
84
 
85
  signal bf_sum_complex     : std_logic_vector(c_nof_complex*c_out_dat_w-1 downto 0);
86
  signal bf_sum_complex_dly : std_logic_vector(bf_sum_complex'range);
87
  signal bf_dif_complex     : std_logic_vector(c_nof_complex*c_out_dat_w-1 downto 0);
88
  signal bf_dif_complex_dly : std_logic_vector(bf_dif_complex'range);
89
 
90
  signal weight_addr        : std_logic_vector(g_stage-1 downto 1);
91
  signal weight_re          : wTyp;
92
  signal weight_im          : wTyp;
93
 
94
  signal mul_out_re         : std_logic_vector(y_out_re'range);
95
  signal mul_out_im         : std_logic_vector(y_out_im'range);
96
  signal mul_quant_re       : std_logic_vector(y_out_re'range);
97
  signal mul_quant_im       : std_logic_vector(y_out_im'range);
98
  signal mul_out_val        : std_logic;
99
  signal mul_in_val         : std_logic;
100
 
101
begin
102
 
103
  ------------------------------------------------------------------------------
104
  -- complex butterfly
105
  ------------------------------------------------------------------------------
106
  u_bf_re : entity rTwoSDF_lib.rTwoBF
107
  generic map (
108
    g_in_a_zdly  => c_bf_in_a_zdly,
109
    g_out_d_zdly => c_bf_out_b_zdly
110
  )
111
  port map (
112
    clk    => clk,
113
    in_a   => x_in_re,
114
    in_b   => y_in_re,
115
    in_sel => '1',
116
    in_val => in_val,
117
    out_c  => sum_re,
118
    out_d  => dif_re
119
  );
120
 
121
  u_bf_im : entity rTwoSDF_lib.rTwoBF
122
  generic map (
123
    g_in_a_zdly  => c_bf_in_a_zdly,
124
    g_out_d_zdly => c_bf_out_b_zdly
125
  )
126
  port map (
127
    clk    => clk,
128
    in_a   => x_in_im,
129
    in_b   => y_in_im,
130
    in_sel => '1',
131
    in_val => in_val,
132
    out_c  => sum_im,
133
    out_d  => dif_im
134
  );
135
 
136
  ------------------------------------------------------------------------------
137
  -- requantize x output
138
  ------------------------------------------------------------------------------
139
  u_requantize_x_re : entity common_requantize_lib.common_requantize
140
  generic map (
141
    g_representation      => "SIGNED",
142
    g_lsb_w               => c_stage_bit_growth,
143
    g_lsb_round           => TRUE,
144
    g_lsb_round_clip      => FALSE,
145
    g_msb_clip            => FALSE,
146
    g_msb_clip_symmetric  => FALSE,
147
    g_pipeline_remove_lsb => 0,
148
    g_pipeline_remove_msb => 0,
149
    g_in_dat_w            => sum_re'LENGTH,
150
    g_out_dat_w           => sum_quant_re'LENGTH
151
  )
152
  port map (
153
    clk        => clk,
154
    clken      => '1',
155
    in_dat     => sum_re,
156
    out_dat    => sum_quant_re,
157
    out_ovr    => open
158
  );
159
 
160
  u_requantize_x_im : entity common_requantize_lib.common_requantize
161
  generic map (
162
    g_representation      => "SIGNED",
163
    g_lsb_w               => c_stage_bit_growth,
164
    g_lsb_round           => TRUE,
165
    g_lsb_round_clip      => FALSE,
166
    g_msb_clip            => FALSE,
167
    g_msb_clip_symmetric  => FALSE,
168
    g_pipeline_remove_lsb => 0,
169
    g_pipeline_remove_msb => 0,
170
    g_in_dat_w            => sum_im'LENGTH,
171
    g_out_dat_w           => sum_quant_im'LENGTH
172
  )
173
  port map (
174
    clk        => clk,
175
    clken      => '1',
176
    in_dat     => sum_im,
177
    out_dat    => sum_quant_im,
178
    out_ovr    => open
179
  );
180
 
181
  ------------------------------------------------------------------------------
182
  -- Butterfly output pipelining: the sum output (output C)
183
  -- 
184
  -- The instantiated pipeline for the sum output takes into account the 
185
  -- bf_lat + mul_lat + stage_lat. Output of the pipeline is directly connected 
186
  -- to the output. 
187
  ------------------------------------------------------------------------------
188
  bf_sum_complex <= sum_quant_im & sum_quant_re;
189
 
190
  u_pipeline_sum : entity common_components_lib.common_pipeline
191
  generic map (
192
    g_pipeline  => g_pipeline.bf_lat + g_pipeline.mul_lat + g_pipeline.stage_lat,
193
    g_in_dat_w  => bf_sum_complex'length,
194
    g_out_dat_w => bf_sum_complex'length
195
  )
196
  port map (
197
    clk     => clk,
198
    in_dat  => bf_sum_complex,
199
    out_dat => bf_sum_complex_dly
200
  );
201
  -- connect to the output. 
202
  x_out_re <= bf_sum_complex_dly(  c_out_dat_w-1 downto 0);
203
  x_out_im <= bf_sum_complex_dly(2*c_out_dat_w-1 downto c_out_dat_w);
204
 
205
  ------------------------------------------------------------------------------
206
  -- Butterfly output pipelining: the dif output (output D)
207
  -- 
208
  -- The dif output requires only the bf_lat pipelining. The data of the dif
209
  -- output is than fed to the multiplier. 
210
  ------------------------------------------------------------------------------
211
  bf_dif_complex <= dif_im & dif_re;
212
 
213
  u_pipeline_dif : entity common_components_lib.common_pipeline
214
  generic map (
215
    g_pipeline  => g_pipeline.bf_lat,
216
    g_in_dat_w  => bf_dif_complex'length,
217
    g_out_dat_w => bf_dif_complex'length
218
  )
219
  port map (
220
    clk     => clk,
221
    in_dat  => bf_dif_complex,
222
    out_dat => bf_dif_complex_dly
223
  );
224
 
225
  dif_out_re <= bf_dif_complex_dly(  c_out_dat_w-1 downto 0);
226
  dif_out_im <= bf_dif_complex_dly(2*c_out_dat_w-1 downto c_out_dat_w);
227
 
228
  ------------------------------------------------------------------------------
229
  -- In_valid pipelining. The in_val signal must be pipelined for bf_lat cycles
230
  -- before it drives to the multiplier. 
231
  ------------------------------------------------------------------------------
232
  u_val_bf_lat : entity common_components_lib.common_pipeline_sl
233
  generic map (
234
    g_pipeline => g_pipeline.bf_lat
235
  )
236
  port map (
237
    clk     => clk,
238
    in_dat  => in_val,
239
    out_dat => mul_in_val
240
  );
241
 
242
  ------------------------------------------------------------------------------
243
  -- twiddle multiplication
244
  ------------------------------------------------------------------------------
245
  u_TwiddleMult: entity rTwoSDF_lib.rTwoWMul
246
  generic map (
247
    g_stage => g_stage,
248
    g_lat   => g_pipeline.mul_lat
249
  )
250
  port map (
251
    clk         => clk,
252
    rst         => rst,
253
    weight_re   => weight_re,
254
    weight_im   => weight_im,
255
    in_re       => dif_out_re,
256
    in_im       => dif_out_im,
257
    in_val      => mul_in_val,
258
    in_sel      => '1',        -- Always select the multiplier output
259
    out_re      => mul_out_re,
260
    out_im      => mul_out_im,
261
    out_val     => mul_out_val
262
  );
263
 
264
  weight_re <= wRe(wMap(g_element, g_stage));
265
  weight_im <= wIm(wMap(g_element, g_stage));
266
 
267
  print_str("Parallel: [stage = " & integer'image(g_stage) & " [element = " & integer'image(g_element) & "] " & "[index = " & integer'image(wMap(g_element, g_stage)) & "] " );
268
 
269
  ------------------------------------------------------------------------------
270
  -- requantize y output
271
  ------------------------------------------------------------------------------
272
  u_requantize_y_re : entity common_requantize_lib.common_requantize
273
  generic map (
274
    g_representation      => "SIGNED",
275
    g_lsb_w               => c_stage_bit_growth,
276
    g_lsb_round           => TRUE,
277
    g_lsb_round_clip      => FALSE,
278
    g_msb_clip            => FALSE,
279
    g_msb_clip_symmetric  => FALSE,
280
    g_pipeline_remove_lsb => 0,
281
    g_pipeline_remove_msb => 0,
282
    g_in_dat_w            => mul_out_re'LENGTH,
283
    g_out_dat_w           => mul_quant_re'LENGTH
284
  )
285
  port map (
286
    clk        => clk,
287
    clken      => '1',
288
    in_dat     => mul_out_re,
289
    out_dat    => mul_quant_re,
290
    out_ovr    => open
291
  );
292
 
293
  u_requantize_y_im : entity common_requantize_lib.common_requantize
294
  generic map (
295
    g_representation      => "SIGNED",
296
    g_lsb_w               => c_stage_bit_growth,
297
    g_lsb_round           => TRUE,
298
    g_lsb_round_clip      => FALSE,
299
    g_msb_clip            => FALSE,
300
    g_msb_clip_symmetric  => FALSE,
301
    g_pipeline_remove_lsb => 0,
302
    g_pipeline_remove_msb => 0,
303
    g_in_dat_w            => mul_out_im'LENGTH,
304
    g_out_dat_w           => mul_quant_im'LENGTH
305
  )
306
  port map (
307
    clk        => clk,
308
    clken      => '1',
309
    in_dat     => mul_out_im,
310
    out_dat    => mul_quant_im,
311
    out_ovr    => open
312
  );
313
 
314
  ------------------------------------------------------------------------------
315
  -- output
316
  ------------------------------------------------------------------------------
317
  u_y_re_stage_lat : entity common_components_lib.common_pipeline
318
  generic map (
319
    g_pipeline  => g_pipeline.stage_lat,
320
    g_in_dat_w  => mul_quant_re'LENGTH,
321
    g_out_dat_w => y_out_re'LENGTH
322
  )
323
  port map (
324
    clk     => clk,
325
    in_dat  => mul_quant_re,
326
    out_dat => y_out_re
327
  );
328
 
329
  u_y_im_stage_lat : entity common_components_lib.common_pipeline
330
  generic map (
331
    g_pipeline  => g_pipeline.stage_lat,
332
    g_in_dat_w  => mul_quant_im'LENGTH,
333
    g_out_dat_w => y_out_im'LENGTH
334
  )
335
  port map (
336
    clk     => clk,
337
    in_dat  => mul_quant_im,
338
    out_dat => y_out_im
339
  );
340
 
341
  u_val_stage_lat : entity common_components_lib.common_pipeline_sl
342
  generic map (
343
    g_pipeline => g_pipeline.stage_lat
344
  )
345
  port map (
346
    clk     => clk,
347
    in_dat  => mul_out_val,
348
    out_dat => out_val
349
  );
350
 
351
end str;

powered by: WebSVN 2.1.0

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