| 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 |
4 |
danv |
library ieee, common_pkg_lib, common_components_lib, astron_counter_lib, astron_requantize_lib;
|
| 22 |
2 |
danv |
use IEEE.std_logic_1164.all;
|
| 23 |
|
|
use common_pkg_lib.common_pkg.all;
|
| 24 |
|
|
use work.twiddlesPkg.all;
|
| 25 |
|
|
use work.rTwoSDFPkg.all;
|
| 26 |
|
|
|
| 27 |
|
|
entity rTwoSDFStage is
|
| 28 |
|
|
generic (
|
| 29 |
|
|
g_nof_chan : natural := 0; -- Exponent of nr of subbands (0 means 1 subband)
|
| 30 |
|
|
g_stage : natural := 8;
|
| 31 |
|
|
g_stage_offset : natural := 0; -- The Stage offset: 0 for normal FFT. Other than 0 in wideband FFT
|
| 32 |
|
|
g_twiddle_offset : natural := 0; -- The twiddle offset: 0 for normal FFT. Other than 0 in wideband FFT
|
| 33 |
|
|
g_scale_enable : boolean := TRUE; --
|
| 34 |
|
|
g_pipeline : t_fft_pipeline := c_fft_pipeline -- internal pipeline settings
|
| 35 |
|
|
);
|
| 36 |
|
|
port (
|
| 37 |
|
|
clk : in std_logic;
|
| 38 |
|
|
rst : in std_logic;
|
| 39 |
|
|
in_re : in std_logic_vector;
|
| 40 |
|
|
in_im : in std_logic_vector;
|
| 41 |
|
|
in_val : in std_logic;
|
| 42 |
|
|
out_re : out std_logic_vector;
|
| 43 |
|
|
out_im : out std_logic_vector;
|
| 44 |
|
|
out_val : out std_logic
|
| 45 |
|
|
);
|
| 46 |
|
|
end entity rTwoSDFStage;
|
| 47 |
|
|
|
| 48 |
|
|
architecture str of rTwoSDFStage is
|
| 49 |
|
|
|
| 50 |
|
|
-- The amplification factor per stage is 2, therefor bit growth defintion of 1.
|
| 51 |
|
|
-- Scale enable is defined by generic.
|
| 52 |
|
|
constant c_rtwo_stage_bit_growth : natural := sel_a_b(g_scale_enable, 1, 0);
|
| 53 |
|
|
|
| 54 |
|
|
-- counter for ctrl_sel
|
| 55 |
|
|
constant c_cnt_lat : integer := 1;
|
| 56 |
|
|
constant c_cnt_init : integer := 0;
|
| 57 |
|
|
|
| 58 |
|
|
signal ctrl_sel : std_logic_vector(g_stage + g_nof_chan downto 1);
|
| 59 |
|
|
|
| 60 |
|
|
signal in_sel : std_logic;
|
| 61 |
|
|
|
| 62 |
|
|
signal bf_re : std_logic_vector(in_re'range);
|
| 63 |
|
|
signal bf_im : std_logic_vector(in_im'range);
|
| 64 |
|
|
signal bf_sel : std_logic;
|
| 65 |
|
|
signal bf_val : std_logic;
|
| 66 |
|
|
|
| 67 |
|
|
signal weight_addr : std_logic_vector(g_stage-1 downto 1);
|
| 68 |
|
|
signal weight_re : wTyp;
|
| 69 |
|
|
signal weight_im : wTyp;
|
| 70 |
|
|
|
| 71 |
|
|
signal mul_out_re : std_logic_vector(out_re'range);
|
| 72 |
|
|
signal mul_out_im : std_logic_vector(out_im'range);
|
| 73 |
|
|
signal mul_out_val : std_logic;
|
| 74 |
|
|
|
| 75 |
|
|
signal quant_out_re : std_logic_vector(out_re'range);
|
| 76 |
|
|
signal quant_out_im : std_logic_vector(out_im'range);
|
| 77 |
|
|
|
| 78 |
|
|
begin
|
| 79 |
|
|
|
| 80 |
|
|
------------------------------------------------------------------------------
|
| 81 |
|
|
-- stage counter
|
| 82 |
|
|
------------------------------------------------------------------------------
|
| 83 |
4 |
danv |
u_control : entity astron_counter_lib.common_counter
|
| 84 |
2 |
danv |
generic map (
|
| 85 |
|
|
g_latency => c_cnt_lat,
|
| 86 |
|
|
g_init => c_cnt_init,
|
| 87 |
|
|
g_width => g_stage + g_nof_chan,
|
| 88 |
|
|
g_step_size => 1
|
| 89 |
|
|
)
|
| 90 |
|
|
port map (
|
| 91 |
|
|
rst => rst,
|
| 92 |
|
|
clk => clk,
|
| 93 |
|
|
cnt_en => in_val,
|
| 94 |
|
|
count => ctrl_sel
|
| 95 |
|
|
);
|
| 96 |
|
|
|
| 97 |
|
|
------------------------------------------------------------------------------
|
| 98 |
|
|
-- complex butterfly
|
| 99 |
|
|
------------------------------------------------------------------------------
|
| 100 |
|
|
in_sel <= ctrl_sel(g_stage + g_nof_chan);
|
| 101 |
|
|
|
| 102 |
|
|
u_butterfly: entity work.rTwoBFStage
|
| 103 |
|
|
generic map (
|
| 104 |
|
|
g_nof_chan => g_nof_chan,
|
| 105 |
|
|
g_stage => g_stage,
|
| 106 |
|
|
g_bf_lat => g_pipeline.bf_lat,
|
| 107 |
|
|
g_bf_use_zdly => g_pipeline.bf_use_zdly,
|
| 108 |
|
|
g_bf_in_a_zdly => g_pipeline.bf_in_a_zdly,
|
| 109 |
|
|
g_bf_out_d_zdly => g_pipeline.bf_out_d_zdly
|
| 110 |
|
|
)
|
| 111 |
|
|
port map (
|
| 112 |
|
|
clk => clk,
|
| 113 |
|
|
rst => rst,
|
| 114 |
|
|
in_re => in_re,
|
| 115 |
|
|
in_im => in_im,
|
| 116 |
|
|
in_sel => in_sel,
|
| 117 |
|
|
in_val => in_val,
|
| 118 |
|
|
out_re => bf_re,
|
| 119 |
|
|
out_im => bf_im,
|
| 120 |
|
|
out_sel => bf_sel,
|
| 121 |
|
|
out_val => bf_val
|
| 122 |
|
|
);
|
| 123 |
|
|
|
| 124 |
|
|
------------------------------------------------------------------------------
|
| 125 |
|
|
-- get twiddles
|
| 126 |
|
|
------------------------------------------------------------------------------
|
| 127 |
|
|
weight_addr <= ctrl_sel(g_stage + g_nof_chan-1 downto g_nof_chan + 1);
|
| 128 |
|
|
|
| 129 |
|
|
u_weights: entity work.rTwoWeights
|
| 130 |
|
|
generic map (
|
| 131 |
|
|
g_stage => g_stage,
|
| 132 |
|
|
g_twiddle_offset => g_twiddle_offset,
|
| 133 |
|
|
g_stage_offset => g_stage_offset,
|
| 134 |
|
|
g_lat => g_pipeline.weight_lat
|
| 135 |
|
|
)
|
| 136 |
|
|
port map (
|
| 137 |
|
|
clk => clk,
|
| 138 |
|
|
in_wAdr => weight_addr,
|
| 139 |
|
|
weight_re => weight_re,
|
| 140 |
|
|
weight_im => weight_im
|
| 141 |
|
|
);
|
| 142 |
|
|
|
| 143 |
|
|
------------------------------------------------------------------------------
|
| 144 |
|
|
-- twiddle multiplication
|
| 145 |
|
|
------------------------------------------------------------------------------
|
| 146 |
|
|
u_TwiddleMult: entity work.rTwoWMul
|
| 147 |
|
|
generic map (
|
| 148 |
|
|
g_stage => g_stage,
|
| 149 |
|
|
g_lat => g_pipeline.mul_lat
|
| 150 |
|
|
)
|
| 151 |
|
|
port map (
|
| 152 |
|
|
clk => clk,
|
| 153 |
|
|
rst => rst,
|
| 154 |
|
|
weight_re => weight_re,
|
| 155 |
|
|
weight_im => weight_im,
|
| 156 |
|
|
in_re => bf_re,
|
| 157 |
|
|
in_im => bf_im,
|
| 158 |
|
|
in_val => bf_val,
|
| 159 |
|
|
in_sel => bf_sel,
|
| 160 |
|
|
out_re => mul_out_re,
|
| 161 |
|
|
out_im => mul_out_im,
|
| 162 |
|
|
out_val => mul_out_val
|
| 163 |
|
|
);
|
| 164 |
|
|
|
| 165 |
|
|
------------------------------------------------------------------------------
|
| 166 |
|
|
-- stage requantization
|
| 167 |
|
|
------------------------------------------------------------------------------
|
| 168 |
4 |
danv |
u_requantize_re : entity astron_requantize_lib.common_requantize
|
| 169 |
2 |
danv |
generic map (
|
| 170 |
|
|
g_representation => "SIGNED",
|
| 171 |
|
|
g_lsb_w => c_rtwo_stage_bit_growth,
|
| 172 |
|
|
g_lsb_round => TRUE,
|
| 173 |
|
|
g_lsb_round_clip => FALSE,
|
| 174 |
|
|
g_msb_clip => FALSE,
|
| 175 |
|
|
g_msb_clip_symmetric => FALSE,
|
| 176 |
|
|
g_pipeline_remove_lsb => 0,
|
| 177 |
|
|
g_pipeline_remove_msb => 0,
|
| 178 |
|
|
g_in_dat_w => in_re'LENGTH,
|
| 179 |
|
|
g_out_dat_w => out_re'LENGTH
|
| 180 |
|
|
)
|
| 181 |
|
|
port map (
|
| 182 |
|
|
clk => clk,
|
| 183 |
|
|
clken => '1',
|
| 184 |
|
|
in_dat => mul_out_re,
|
| 185 |
|
|
out_dat => quant_out_re,
|
| 186 |
|
|
out_ovr => open
|
| 187 |
|
|
);
|
| 188 |
|
|
|
| 189 |
4 |
danv |
u_requantize_im : entity astron_requantize_lib.common_requantize
|
| 190 |
2 |
danv |
generic map (
|
| 191 |
|
|
g_representation => "SIGNED",
|
| 192 |
|
|
g_lsb_w => c_rtwo_stage_bit_growth,
|
| 193 |
|
|
g_lsb_round => TRUE,
|
| 194 |
|
|
g_lsb_round_clip => FALSE,
|
| 195 |
|
|
g_msb_clip => FALSE,
|
| 196 |
|
|
g_msb_clip_symmetric => FALSE,
|
| 197 |
|
|
g_pipeline_remove_lsb => 0,
|
| 198 |
|
|
g_pipeline_remove_msb => 0,
|
| 199 |
|
|
g_in_dat_w => in_im'LENGTH,
|
| 200 |
|
|
g_out_dat_w => out_im'LENGTH
|
| 201 |
|
|
)
|
| 202 |
|
|
port map (
|
| 203 |
|
|
clk => clk,
|
| 204 |
|
|
clken => '1',
|
| 205 |
|
|
in_dat => mul_out_im,
|
| 206 |
|
|
out_dat => quant_out_im,
|
| 207 |
|
|
out_ovr => open
|
| 208 |
|
|
);
|
| 209 |
|
|
|
| 210 |
|
|
------------------------------------------------------------------------------
|
| 211 |
|
|
-- output
|
| 212 |
|
|
------------------------------------------------------------------------------
|
| 213 |
|
|
u_re_lat : entity common_components_lib.common_pipeline
|
| 214 |
|
|
generic map (
|
| 215 |
|
|
g_pipeline => g_pipeline.stage_lat,
|
| 216 |
|
|
g_in_dat_w => out_re'length,
|
| 217 |
|
|
g_out_dat_w => out_re'length
|
| 218 |
|
|
)
|
| 219 |
|
|
port map (
|
| 220 |
|
|
clk => clk,
|
| 221 |
|
|
in_dat => quant_out_re,
|
| 222 |
|
|
out_dat => out_re
|
| 223 |
|
|
);
|
| 224 |
|
|
|
| 225 |
|
|
u_im_lat : entity common_components_lib.common_pipeline
|
| 226 |
|
|
generic map (
|
| 227 |
|
|
g_pipeline => g_pipeline.stage_lat,
|
| 228 |
|
|
g_in_dat_w => out_im'length,
|
| 229 |
|
|
g_out_dat_w => out_im'length
|
| 230 |
|
|
)
|
| 231 |
|
|
port map (
|
| 232 |
|
|
clk => clk,
|
| 233 |
|
|
in_dat => quant_out_im,
|
| 234 |
|
|
out_dat => out_im
|
| 235 |
|
|
);
|
| 236 |
|
|
|
| 237 |
|
|
u_val_lat : entity common_components_lib.common_pipeline_sl
|
| 238 |
|
|
generic map (
|
| 239 |
|
|
g_pipeline => g_pipeline.stage_lat
|
| 240 |
|
|
)
|
| 241 |
|
|
port map (
|
| 242 |
|
|
clk => clk,
|
| 243 |
|
|
in_dat => mul_out_val,
|
| 244 |
|
|
out_dat => out_val
|
| 245 |
|
|
);
|
| 246 |
|
|
|
| 247 |
|
|
end str;
|