1 |
2 |
danv |
-------------------------------------------------------------------------------
|
2 |
|
|
-- Author: Harm Jan Pepping : pepping at astron.nl: 2012
|
3 |
|
|
-- Copyright (C) 2012
|
4 |
|
|
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
|
5 |
|
|
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
|
6 |
|
|
--
|
7 |
|
|
-- This program is free software: you can redistribute it and/or modify
|
8 |
|
|
-- it under the terms of the GNU General Public License as published by
|
9 |
|
|
-- the Free Software Foundation, either version 3 of the License, or
|
10 |
|
|
-- (at your option) any later version.
|
11 |
|
|
--
|
12 |
|
|
-- This program is distributed in the hope that it will be useful,
|
13 |
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
|
|
-- GNU General Public License for more details.
|
16 |
|
|
--
|
17 |
|
|
-- You should have received a copy of the GNU General Public License
|
18 |
|
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19 |
|
|
--
|
20 |
|
|
-------------------------------------------------------------------------------
|
21 |
|
|
|
22 |
|
|
library ieee, common_pkg_lib, astron_r2sdf_fft_lib, astron_wb_fft_lib, astron_filter_lib;
|
23 |
|
|
use IEEE.std_logic_1164.all;
|
24 |
|
|
use common_pkg_lib.common_pkg.all;
|
25 |
|
|
use astron_r2sdf_fft_lib.rTwoSDFPkg.all;
|
26 |
|
|
use astron_wb_fft_lib.fft_pkg.all;
|
27 |
|
|
use astron_filter_lib.fil_pkg.all;
|
28 |
|
|
|
29 |
|
|
package wpfb_pkg is
|
30 |
|
|
|
31 |
|
|
-- Parameters for the (wideband) poly phase filter.
|
32 |
|
|
type t_wpfb is record
|
33 |
|
|
-- General parameters for the wideband poly phase filter
|
34 |
|
|
wb_factor : natural; -- = default 4, wideband factor
|
35 |
|
|
nof_points : natural; -- = 1024, N point FFT (Also the number of subbands for the filter part)
|
36 |
|
|
nof_chan : natural; -- = default 0, defines the number of channels (=time-multiplexed input signals): nof channels = 2**nof_chan
|
37 |
|
|
nof_wb_streams : natural; -- = 1, the number of parallel wideband streams. The filter coefficients are shared on every wb-stream.
|
38 |
|
|
|
39 |
|
|
-- Parameters for the poly phase filter
|
40 |
|
|
nof_taps : natural; -- = 16, the number of FIR taps per subband
|
41 |
|
|
fil_backoff_w : natural; -- = 0, number of bits for input backoff to avoid output overflow
|
42 |
|
|
fil_in_dat_w : natural; -- = 8, number of input bits
|
43 |
|
|
fil_out_dat_w : natural; -- = 16, number of output bits
|
44 |
|
|
coef_dat_w : natural; -- = 16, data width of the FIR coefficients
|
45 |
|
|
|
46 |
|
|
-- Parameters for the FFT
|
47 |
|
|
use_reorder : boolean; -- = false for bit-reversed output, true for normal output
|
48 |
|
|
use_fft_shift : boolean; -- = false for [0, pos, neg] bin frequencies order, true for [neg, 0, pos] bin frequencies order in case of complex input
|
49 |
|
|
use_separate : boolean; -- = false for complex input, true for two real inputs
|
50 |
|
|
fft_in_dat_w : natural; -- = 16, number of input bits
|
51 |
|
|
fft_out_dat_w : natural; -- = 16, number of output bits >= (fil_in_dat_w=8) + log2(nof_points=1024)/2 = 13
|
52 |
|
|
fft_out_gain_w : natural; -- = 0, output gain factor applied after the last stage output, before requantization to out_dat_w
|
53 |
|
|
stage_dat_w : natural; -- = 18, number of bits that are used inter-stage
|
54 |
|
|
guard_w : natural; -- = 2, guard used to avoid overflow in first FFT stage, compensated in last guard_w nof FFT stages.
|
55 |
|
|
-- on average the gain per stage is 2 so guard_w = 1, but the gain can be 1+sqrt(2) [Lyons section
|
56 |
|
|
-- 12.3.2], therefore use input guard_w = 2.
|
57 |
|
|
guard_enable : boolean; -- = true when input needs guarding, false when input requires no guarding but scaling must be
|
58 |
|
|
-- skipped at the last stage(s) compensate for input guard (used in wb fft with pipe fft section
|
59 |
|
|
-- doing the input guard and par fft section doing the output compensation)
|
60 |
|
|
|
61 |
|
|
-- Parameters for the statistics
|
62 |
|
|
stat_data_w : positive; -- = 56
|
63 |
|
|
stat_data_sz : positive; -- = 2
|
64 |
|
|
nof_blk_per_sync : natural; -- = 800000, number of FFT output blocks per sync interval, used to pass on BSN
|
65 |
|
|
|
66 |
|
|
-- Pipeline parameters for both poly phase filter and FFT. These are heritaged from the filter and fft libraries.
|
67 |
|
|
pft_pipeline : t_fft_pipeline; -- Pipeline settings for the pipelined FFT
|
68 |
|
|
fft_pipeline : t_fft_pipeline; -- Pipeline settings for the parallel FFT
|
69 |
|
|
fil_pipeline : t_fil_ppf_pipeline; -- Pipeline settings for the filter units
|
70 |
|
|
|
71 |
|
|
end record;
|
72 |
|
|
|
73 |
|
|
-----------------------------------------------------------------------------
|
74 |
|
|
-- Apertif application specfic settings
|
75 |
|
|
-----------------------------------------------------------------------------
|
76 |
|
|
|
77 |
|
|
-- For reference Fsub, actual setting is done in the apertif_unb1_bn_filterbank design:
|
78 |
|
|
-- * wb_factor = 4 : wideband factor
|
79 |
|
|
-- nof_points = 1024 : N point FFT
|
80 |
|
|
-- nof_chan = 0 : nof channels = 2**nof_chan = 1
|
81 |
|
|
-- nof_wb_streams = 1 : 1 two real wb stream per WPFB, because the subband filterbank uses 2 independent instances of WPFB
|
82 |
|
|
-- * nof_taps = 16 : number of FIR taps in the subband filterbank
|
83 |
|
|
-- fil_backoff_w = 1 : backoff input to fit temporary PFIR output overshoot that can occur even though DC gain is 1
|
84 |
|
|
-- fil_in_dat_w = 8 : ADC data width
|
85 |
|
|
-- fil_out_dat_w = 16 : = fft_in_dat_w
|
86 |
|
|
-- coef_dat_w = 16 : width of the subband FIR coefficients
|
87 |
|
|
-- * use_reorder = true : must be true for two real input FFT
|
88 |
|
|
-- use_fft_shift = false : must be false for two real input FFT
|
89 |
|
|
-- use_separate = true : must be true for two real input FFT
|
90 |
|
|
-- fft_in_dat_w = 16 : = c_dsp_mult_w-guard_w = 18-2
|
91 |
|
|
-- fft_out_dat_w = 16 : subband data width in the transpose transport and at the BF input
|
92 |
|
|
-- fft_out_gain_w = 1 : compensate for divide by 2 in separate function for two real input FFT
|
93 |
|
|
-- stage_dat_w = 18 : = c_dsp_mult_w, number of bits that are used inter-stage
|
94 |
|
|
-- guard_w = 2 : must be 2 to avoid overflow in first FFT stage
|
95 |
|
|
-- guard_enable = true : must be true to enable input guard_w
|
96 |
|
|
-- * stat_data_w = 56 : could be 52 = 2*16+1 - 1 + ceil_log2(781250)
|
97 |
|
|
-- . 2*fft_out_dat_w for product
|
98 |
|
|
-- . +1 for complex product
|
99 |
|
|
-- . -1 to skip double sign
|
100 |
|
|
-- . +ceil_log2(Nint) for accumlation bit growth
|
101 |
|
|
-- stat_data_sz = 2 : must be 2 to fit stat_data_w in two 32 bit words
|
102 |
|
|
-- nof_blk_per_sync = 800000 : number of FFT output blocks per sync interval
|
103 |
|
|
|
104 |
|
|
-- Fsub settings:
|
105 |
|
|
-- . fil_backoff_w = 1 instead of 0 to avoid the overflow that occurs for WG with --ampl >= 119 and e.g. --sub 65, --chan 4,
|
106 |
|
|
-- see svn -r 18800 log of node_apertif_unb1_bn_filterbank
|
107 |
|
|
-- . fft_out_dat_w = 16 by internal dp_requantize will not overflow, so no need to use external dp_requantize with clipping
|
108 |
|
|
-- . fft_out_gain_w = 1 instead of 0 to compensate for 1/2 in separate.
|
109 |
|
|
constant c_wpfb_apertif_subbands : t_wpfb := (4, 1024, 0, 1,
|
110 |
|
|
16, 1, 8, 16, 16,
|
111 |
|
|
true, false, true, 16, 16, 1, c_dsp_mult_w, 2, true, 56, 2, 800000,
|
112 |
|
|
c_fft_pipeline, c_fft_pipeline, c_fil_ppf_pipeline);
|
113 |
|
|
|
114 |
|
|
-- For reference Fchan_x, actual setting is done in the apertif_unb1_correlator design:
|
115 |
|
|
-- * wb_factor = 1 : wideband factor
|
116 |
|
|
-- nof_points = 64 : N point FFT
|
117 |
|
|
-- nof_chan = 1 : nof channels = 2**nof_chan = 2 multiplex streams
|
118 |
|
|
-- nof_wb_streams = 12 : 12 complex streams per WPFB, that all share the FIR coefficients
|
119 |
|
|
-- * nof_taps = 8 : number of FIR taps in the channel filterbank
|
120 |
|
|
-- fil_backoff_w = 0 : backoff input to fit temporary PFIR output overshoot can occur even though DC gain is 1
|
121 |
|
|
-- fil_in_dat_w = 8 : keep at 8, also when Apertif BF outputs 6 bit beamlet data, because that is sign extended to 8b
|
122 |
|
|
-- fil_out_dat_w = 16 : = fft_in_dat_w
|
123 |
|
|
-- coef_dat_w = 9 : width of the channel FIR coefficients
|
124 |
|
|
-- * use_reorder = false : use true to have [0, pos, neg] frequency bin order for complex input FFT
|
125 |
|
|
-- use_fft_shift = false : use false to keep [0, pos, neg] frequency bin order
|
126 |
|
|
-- use_separate = false : must be false for complex input FFT
|
127 |
|
|
-- fft_in_dat_w = 16 : = c_dsp_mult_w-guard_w = 18-2
|
128 |
|
|
-- fft_out_dat_w = 9 : to fit correlator input width
|
129 |
|
|
-- fft_out_gain_w = 0 : keep at 0 for complex input input FFT
|
130 |
|
|
-- stage_dat_w = 18 : = c_dsp_mult_w, number of bits that are used inter-stage
|
131 |
|
|
-- guard_w = 2 : must be 2 to avoid overflow in first FFT stage
|
132 |
|
|
-- guard_enable = true : must be true to enable input guard_w
|
133 |
|
|
-- * stat_data_w = 56 : could be 32 = 2*9+1 - 1 + ceil_log2(781250/64):
|
134 |
|
|
-- . 2*fft_out_dat_w for product
|
135 |
|
|
-- . +1 for complex product
|
136 |
|
|
-- . -1 to skip double sign
|
137 |
|
|
-- . +ceil_log2(Nint) for accumlation bit growth
|
138 |
|
|
-- stat_data_sz = 2 : keep two 32b-word, even if stat_data_w could fit in one 32b-word
|
139 |
|
|
-- nof_blk_per_sync = 12500 : = 800000/64, number of FFT output blocks per sync interval
|
140 |
|
|
|
141 |
|
|
-- Fchan_x settings in node_apertif_unb1_correlator_processing.vhd:
|
142 |
|
|
-- . fil_backoff_w = 0, because for the Fchan there appears no PFIR output overshoot in practise using WG data
|
143 |
|
|
-- . use_reorder = false and use_fft_shift = false, because channel index bit flip and FFT shift are done in
|
144 |
|
|
-- apertif_unb1_correlator_vis_offload
|
145 |
|
|
-- . fft_out_dat_w = 18, because in there is a separate dp_requantize to get from 18b --> 9b in
|
146 |
|
|
-- node_apertif_unb1_correlator_processing, this dp_requantize uses symmertical clipping.
|
147 |
|
|
CONSTANT c_wpfb_apertif_channels : t_wpfb := (1, 64, 1, 12,
|
148 |
|
|
8, 0, 8, 16, 9,
|
149 |
|
|
false, false, false, 16, 18, 0, c_dsp_mult_w, 2, true, 56, 2, 12500,
|
150 |
|
|
c_fft_pipeline, c_fft_pipeline, c_fil_ppf_pipeline);
|
151 |
|
|
|
152 |
|
|
-- Fchan_sc3 settings:
|
153 |
|
|
-- . Arts SC3 uses the Fchan fine channels from Apertif X. Therefore to allow commensal Arts SC3 the Apertif X
|
154 |
|
|
-- will have to use use_reorder = true and use_fft_shift = true.
|
155 |
|
|
-- . Arts SC4 at half Stokes rate, so with nof_blk_per_sync = 12500 and nof_points = 64, has same rate as
|
156 |
|
|
-- Arts SC3. At full rate Arts SC4 would have nof_blk_per_sync = 25000 and nof_points = 32.
|
157 |
|
|
-- . fft_out_dat_w = 9, because Arts SC3 uses the fine channels from Apertif X.
|
158 |
|
|
constant c_wpfb_arts_channels_sc3 : t_wpfb := (1, 64, 1, 12,
|
159 |
|
|
8, 0, 8, 16, 9,
|
160 |
|
|
true, true, false, 16, 9, 0, c_dsp_mult_w, 2, true, 56, 2, 12500,
|
161 |
|
|
c_fft_pipeline, c_fft_pipeline, c_fil_ppf_pipeline);
|
162 |
|
|
|
163 |
|
|
-- Fchan_sc4 settings in arts_unb1_sc4_processing.vhd svn -r 19337:
|
164 |
|
|
-- . fft_out_dat_w = 9 for Arts SC3, but can be 12 to preserve more LSbit for SC4. However this is not necessary,
|
165 |
|
|
-- because the 9b are already sufficient to maintain sensitivity
|
166 |
|
|
-- . fft_out_gain_w = 2 to fit 2 more LSbits which is possible because fft_out_dat_w = 12. However if
|
167 |
|
|
-- fft_out_dat_w = 9, then fft_out_gain_w must be 0 to avoid output overflow. Instead the factor 2**2
|
168 |
|
|
-- then needs to be accommodated at the input of the subsequent IQUV, IAB or TAB processing.
|
169 |
|
|
-- . Using fft_out_dat_w = 12 instead of 9 and fft_out_gain_w = 2 instead of 0 created 12 - 9 - 2 = 1 bit more
|
170 |
|
|
-- dynamic range. Therefore it may not be necessary to use fine channel symmetrical clipping using an external
|
171 |
|
|
-- dp_requantize, like in Apertif X.
|
172 |
|
|
CONSTANT c_wpfb_arts_channels_sc4 : t_wpfb := (1, 64, 1, 12,
|
173 |
|
|
8, 0, 8, 16, 9,
|
174 |
|
|
true, true, false, 16, 12, 2, c_dsp_mult_w, 2, true, 56, 2, 12500,
|
175 |
|
|
c_fft_pipeline, c_fft_pipeline, c_fil_ppf_pipeline);
|
176 |
|
|
|
177 |
|
|
-- Conclusion:
|
178 |
|
|
-- . To support fine channel offload to Arts SC3 the Apertif X settings will have to use use_reorder = true
|
179 |
|
|
-- and use_fft_shift = true
|
180 |
|
|
-- . It seems fine to keep the Arts SC4 settings fft_out_dat_w = 12 and fft_out_gain_w = 2 and no fine channel
|
181 |
|
|
-- clipping.
|
182 |
|
|
-- . Arts SC3 will use the same settings as Apertif X so fft_out_dat_w = 9 and fft_out_gain_w = 0 and fine
|
183 |
|
|
-- channel clipping. The input of the subsequent IQUV, IAB or TAB processing in arts_unb2b_sc3 may need to
|
184 |
|
|
-- be shifted by fft_out_gain_w compared to how it is connected in Arts SC4.
|
185 |
|
|
|
186 |
|
|
-- Estimate maximum number of blocks of latency between WPFB input and output
|
187 |
|
|
function func_wpfb_maximum_sop_latency(wpfb : t_wpfb) return natural;
|
188 |
|
|
function func_wpfb_set_nof_block_per_sync(wpfb : t_wpfb; nof_block_per_sync : NATURAL) return t_wpfb;
|
189 |
|
|
|
190 |
|
|
end package wpfb_pkg;
|
191 |
|
|
|
192 |
|
|
package body wpfb_pkg is
|
193 |
|
|
|
194 |
|
|
function func_wpfb_maximum_sop_latency(wpfb : t_wpfb) return natural is
|
195 |
|
|
constant c_nof_channels : natural := 2**wpfb.nof_chan;
|
196 |
|
|
constant c_block_size : natural := c_nof_channels * wpfb.nof_points / wpfb.wb_factor;
|
197 |
|
|
constant c_block_dly : natural := 10;
|
198 |
|
|
begin
|
199 |
|
|
-- The prefilter, pipelined FFT, pipelined reorder and the wideband separate reorder
|
200 |
|
|
-- cause block latency.
|
201 |
|
|
-- The parallel FFT has no block latency.
|
202 |
|
|
-- The parallel FFT reorder is merely a rewiring and causes no latency.
|
203 |
|
|
-- ==> This yields maximim 4 block latency
|
204 |
|
|
-- ==> Add one extra block latency to round up
|
205 |
|
|
-- Each block in the Wideband FFT also introduces about c_block_dly clock cycles of
|
206 |
|
|
-- pipeline latency.
|
207 |
|
|
-- ==> This yields maximum ( 5 * c_block_dly ) / c_block_size of block latency
|
208 |
|
|
return 4 + 1 + (5 * c_block_dly) / c_block_size;
|
209 |
|
|
end func_wpfb_maximum_sop_latency;
|
210 |
|
|
|
211 |
|
|
-- Overwrite nof_block_per_sync field in wpfb (typically for faster simulation)
|
212 |
|
|
function func_wpfb_set_nof_block_per_sync(wpfb : t_wpfb; nof_block_per_sync : NATURAL) return t_wpfb is
|
213 |
|
|
variable v_wpfb : t_wpfb;
|
214 |
|
|
begin
|
215 |
|
|
v_wpfb := wpfb;
|
216 |
|
|
v_wpfb.nof_blk_per_sync := nof_block_per_sync;
|
217 |
|
|
return v_wpfb;
|
218 |
|
|
end func_wpfb_set_nof_block_per_sync;
|
219 |
|
|
|
220 |
|
|
end wpfb_pkg;
|
221 |
|
|
|