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 5

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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