1 |
2 |
danv |
--------------------------------------------------------------------------------
|
2 |
|
|
--
|
3 |
3 |
danv |
-- Copyright 2020
|
4 |
2 |
danv |
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
|
5 |
|
|
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
|
6 |
3 |
danv |
--
|
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 |
|
|
-- Purpose: Wideband FFT with Subband Statistics and streaming interfaces.
|
21 |
|
|
--
|
22 |
|
|
-- Description: This unit connects an incoming array of streaming interfaces
|
23 |
|
|
-- to the wideband fft. The output of the wideband fft is
|
24 |
|
|
-- connected to a set of subband statistics units. The statistics
|
25 |
|
|
-- can be read via the memory mapped interface.
|
26 |
|
|
-- A control unit takes care of the correct composition of the
|
27 |
|
|
-- output streams(sop,eop,sync,bsn,err).
|
28 |
|
|
--
|
29 |
|
|
-- Remarks: . The unit can handle only one sync at a time. Therfor the
|
30 |
|
|
-- sync interval should be larger than the total pipeline
|
31 |
|
|
-- stages of the wideband fft.
|
32 |
|
|
|
33 |
5 |
danv |
library ieee, common_pkg_lib, astron_ram_lib, dp_pkg_lib, astron_r2sdf_fft_lib, astron_statistics_lib, astron_mm_lib, astron_requantize_lib;
|
34 |
2 |
danv |
use IEEE.std_logic_1164.all;
|
35 |
|
|
use common_pkg_lib.common_pkg.all;
|
36 |
5 |
danv |
use astron_ram_lib.common_ram_pkg.all;
|
37 |
2 |
danv |
use dp_pkg_lib.dp_stream_pkg.ALL;
|
38 |
5 |
danv |
use astron_r2sdf_fft_lib.rTwoSDFPkg.all;
|
39 |
|
|
use astron_statistics_lib.all;
|
40 |
2 |
danv |
use work.fft_pkg.all;
|
41 |
|
|
|
42 |
|
|
entity fft_wide_unit is
|
43 |
|
|
generic (
|
44 |
|
|
g_fft : t_fft := c_fft; -- generics for the FFT
|
45 |
5 |
danv |
g_pft_pipeline : t_fft_pipeline := c_fft_pipeline; -- For the pipelined part, defined in astron_r2sdf_fft_lib.rTwoSDFPkg
|
46 |
|
|
g_fft_pipeline : t_fft_pipeline := c_fft_pipeline -- For the parallel part, defined in astron_r2sdf_fft_lib.rTwoSDFPkg
|
47 |
2 |
danv |
);
|
48 |
|
|
port (
|
49 |
|
|
dp_rst : in std_logic := '0';
|
50 |
|
|
dp_clk : in std_logic;
|
51 |
|
|
mm_rst : in std_logic;
|
52 |
|
|
mm_clk : in std_logic;
|
53 |
|
|
ram_st_sst_mosi : in t_mem_mosi; -- Subband statistics registers
|
54 |
|
|
ram_st_sst_miso : out t_mem_miso := c_mem_miso_rst;
|
55 |
|
|
in_sosi_arr : in t_dp_sosi_arr(g_fft.wb_factor-1 downto 0);
|
56 |
|
|
out_sosi_arr : out t_dp_sosi_arr(g_fft.wb_factor-1 downto 0)
|
57 |
|
|
);
|
58 |
|
|
end entity fft_wide_unit;
|
59 |
|
|
|
60 |
|
|
architecture str of fft_wide_unit is
|
61 |
|
|
|
62 |
|
|
constant c_lsb_w_tester : integer := g_fft.out_dat_w - g_fft.stage_dat_w;
|
63 |
|
|
constant c_lsb_w : natural := sel_a_b(c_lsb_w_tester > 0, c_lsb_w_tester, 0);
|
64 |
|
|
constant c_nof_stats : natural := (2**g_fft.nof_chan)*g_fft.nof_points/g_fft.wb_factor;
|
65 |
|
|
|
66 |
|
|
signal ram_st_sst_mosi_arr : t_mem_mosi_arr(g_fft.wb_factor-1 downto 0);
|
67 |
|
|
signal ram_st_sst_miso_arr : t_mem_miso_arr(g_fft.wb_factor-1 downto 0);
|
68 |
|
|
|
69 |
|
|
signal fft_in_re_arr : t_fft_slv_arr(g_fft.wb_factor-1 downto 0);
|
70 |
|
|
signal fft_in_im_arr : t_fft_slv_arr(g_fft.wb_factor-1 downto 0);
|
71 |
|
|
|
72 |
|
|
signal fft_out_re_arr : t_fft_slv_arr(g_fft.wb_factor-1 downto 0);
|
73 |
|
|
signal fft_out_im_arr : t_fft_slv_arr(g_fft.wb_factor-1 downto 0);
|
74 |
|
|
signal fft_out_val : std_logic;
|
75 |
|
|
|
76 |
|
|
signal fft_out_sosi_arr : t_dp_sosi_arr(g_fft.wb_factor-1 downto 0);
|
77 |
|
|
signal sst_in_sosi_arr : t_dp_sosi_arr(g_fft.wb_factor-1 downto 0);
|
78 |
|
|
|
79 |
|
|
type reg_type is record
|
80 |
|
|
in_sosi_arr : t_dp_sosi_arr(g_fft.wb_factor-1 downto 0);
|
81 |
|
|
end record;
|
82 |
|
|
|
83 |
|
|
signal r, rin : reg_type;
|
84 |
|
|
|
85 |
|
|
begin
|
86 |
|
|
|
87 |
|
|
---------------------------------------------------------------
|
88 |
|
|
-- INPUT REGISTER FOR THE SOSI ARRAY
|
89 |
|
|
---------------------------------------------------------------
|
90 |
|
|
-- The complete input sosi arry is registered.
|
91 |
|
|
comb : process(r, in_sosi_arr)
|
92 |
|
|
variable v : reg_type;
|
93 |
|
|
begin
|
94 |
|
|
v := r;
|
95 |
|
|
v.in_sosi_arr := in_sosi_arr;
|
96 |
|
|
rin <= v;
|
97 |
|
|
end process comb;
|
98 |
|
|
|
99 |
|
|
regs : process(dp_clk)
|
100 |
|
|
begin
|
101 |
|
|
if rising_edge(dp_clk) then
|
102 |
|
|
r <= rin;
|
103 |
|
|
end if;
|
104 |
|
|
end process;
|
105 |
|
|
|
106 |
|
|
---------------------------------------------------------------
|
107 |
|
|
-- COMBINE MEMORY MAPPED INTERFACES
|
108 |
|
|
---------------------------------------------------------------
|
109 |
|
|
-- Combine the internal array of mm interfaces for the subband
|
110 |
|
|
-- statistics to one array that is connected to the port of the
|
111 |
|
|
-- fft_wide_unit.
|
112 |
5 |
danv |
u_mem_mux_sst : entity astron_mm_lib.common_mem_mux
|
113 |
2 |
danv |
generic map (
|
114 |
|
|
g_nof_mosi => g_fft.wb_factor,
|
115 |
|
|
g_mult_addr_w => ceil_log2(g_fft.stat_data_sz*c_nof_stats)
|
116 |
|
|
)
|
117 |
|
|
port map (
|
118 |
|
|
mosi => ram_st_sst_mosi,
|
119 |
|
|
miso => ram_st_sst_miso,
|
120 |
|
|
mosi_arr => ram_st_sst_mosi_arr,
|
121 |
|
|
miso_arr => ram_st_sst_miso_arr
|
122 |
|
|
);
|
123 |
|
|
|
124 |
|
|
---------------------------------------------------------------
|
125 |
|
|
-- PREPARE INPUT DATA FOR WIDEBAND FFT
|
126 |
|
|
---------------------------------------------------------------
|
127 |
|
|
-- Extract the data from the in_sosi_arr records and resize it
|
128 |
|
|
-- to fit the format of the fft_r2_wide unit.
|
129 |
|
|
gen_prep_fft_data: for I in 0 to g_fft.wb_factor-1 generate
|
130 |
|
|
fft_in_re_arr(I) <= RESIZE_SVEC(r.in_sosi_arr(I).re(g_fft.in_dat_w-1 downto 0), fft_in_re_arr(I)'length);
|
131 |
|
|
fft_in_im_arr(I) <= RESIZE_SVEC(r.in_sosi_arr(I).im(g_fft.in_dat_w-1 downto 0), fft_in_im_arr(I)'length);
|
132 |
|
|
end generate;
|
133 |
|
|
|
134 |
|
|
---------------------------------------------------------------
|
135 |
|
|
-- THE WIDEBAND FFT
|
136 |
|
|
---------------------------------------------------------------
|
137 |
|
|
u_fft_wide : entity work.fft_r2_wide
|
138 |
|
|
generic map(
|
139 |
|
|
g_fft => g_fft, -- generics for the WFFT
|
140 |
|
|
g_pft_pipeline => g_pft_pipeline,
|
141 |
|
|
g_fft_pipeline => g_fft_pipeline
|
142 |
|
|
)
|
143 |
|
|
port map(
|
144 |
|
|
clk => dp_clk,
|
145 |
|
|
rst => dp_rst,
|
146 |
|
|
in_re_arr => fft_in_re_arr,
|
147 |
|
|
in_im_arr => fft_in_im_arr,
|
148 |
|
|
in_val => r.in_sosi_arr(0).valid,
|
149 |
|
|
out_re_arr => fft_out_re_arr,
|
150 |
|
|
out_im_arr => fft_out_im_arr,
|
151 |
|
|
out_val => fft_out_val
|
152 |
|
|
);
|
153 |
|
|
|
154 |
|
|
---------------------------------------------------------------
|
155 |
|
|
-- FFT CONTROL UNIT
|
156 |
|
|
---------------------------------------------------------------
|
157 |
|
|
-- The fft control unit composes the output array in the dp-
|
158 |
|
|
-- streaming format.
|
159 |
|
|
u_fft_control : entity work.fft_wide_unit_control
|
160 |
|
|
generic map (
|
161 |
|
|
g_fft => g_fft
|
162 |
|
|
)
|
163 |
|
|
port map(
|
164 |
|
|
rst => dp_rst,
|
165 |
|
|
clk => dp_clk,
|
166 |
|
|
in_re_arr => fft_out_re_arr,
|
167 |
|
|
in_im_arr => fft_out_im_arr,
|
168 |
|
|
in_val => fft_out_val,
|
169 |
|
|
ctrl_sosi => r.in_sosi_arr(0),
|
170 |
|
|
out_sosi_arr => fft_out_sosi_arr
|
171 |
|
|
);
|
172 |
|
|
|
173 |
|
|
---------------------------------------------------------------
|
174 |
|
|
-- SUBBAND STATISTICS
|
175 |
|
|
---------------------------------------------------------------
|
176 |
|
|
-- For all "wb_factor" output streams of the wideband FFT a
|
177 |
|
|
-- subband statistics unit is placed.
|
178 |
|
|
-- Since the subband statistics module uses embedded DSP blocks
|
179 |
|
|
-- for multiplication, the incoming data cannot be wider
|
180 |
|
|
-- than 18 bit. Therefor a quantizer is inserted.
|
181 |
|
|
gen_subband_stats: for I in 0 to g_fft.wb_factor-1 generate
|
182 |
5 |
danv |
u_quantizer_for_bst : entity astron_requantize_lib.dp_requantize
|
183 |
2 |
danv |
GENERIC MAP (
|
184 |
|
|
g_complex => TRUE,
|
185 |
|
|
g_representation => "SIGNED",
|
186 |
|
|
g_lsb_w => c_lsb_w,
|
187 |
|
|
g_lsb_round => TRUE,
|
188 |
|
|
g_lsb_round_clip => FALSE,
|
189 |
|
|
g_msb_clip => TRUE,
|
190 |
|
|
g_msb_clip_symmetric => TRUE,
|
191 |
|
|
g_pipeline_remove_lsb => 1,
|
192 |
|
|
g_pipeline_remove_msb => 1,
|
193 |
|
|
g_in_dat_w => g_fft.out_dat_w,
|
194 |
|
|
g_out_dat_w => g_fft.stage_dat_w
|
195 |
|
|
)
|
196 |
|
|
PORT MAP (
|
197 |
|
|
rst => dp_rst,
|
198 |
|
|
clk => dp_clk,
|
199 |
|
|
snk_in => fft_out_sosi_arr(I),
|
200 |
|
|
src_out => sst_in_sosi_arr(I),
|
201 |
|
|
out_ovr => OPEN
|
202 |
|
|
);
|
203 |
|
|
|
204 |
5 |
danv |
u_subband_stats : entity astron_statistics_lib.st_sst
|
205 |
2 |
danv |
generic map(
|
206 |
|
|
g_nof_stat => c_nof_stats,
|
207 |
|
|
g_in_data_w => g_fft.stage_dat_w,
|
208 |
|
|
g_stat_data_w => g_fft.stat_data_w,
|
209 |
|
|
g_stat_data_sz => g_fft.stat_data_sz
|
210 |
|
|
)
|
211 |
|
|
port map (
|
212 |
|
|
mm_rst => mm_rst,
|
213 |
|
|
mm_clk => mm_clk,
|
214 |
|
|
dp_rst => dp_rst,
|
215 |
|
|
dp_clk => dp_clk,
|
216 |
|
|
in_complex => sst_in_sosi_arr(I),
|
217 |
|
|
ram_st_sst_mosi => ram_st_sst_mosi_arr(I),
|
218 |
|
|
ram_st_sst_miso => ram_st_sst_miso_arr(I)
|
219 |
|
|
);
|
220 |
|
|
end generate;
|
221 |
|
|
|
222 |
|
|
-- Connect to the outside world
|
223 |
|
|
gen_output : for I in 0 to g_fft.wb_factor-1 generate
|
224 |
|
|
out_sosi_arr(I) <= fft_out_sosi_arr(I);
|
225 |
|
|
end generate;
|
226 |
|
|
|
227 |
|
|
end str;
|
228 |
|
|
|
229 |
|
|
|