1 |
2 |
danv |
|
2 |
|
|
-------------------------------------------------------------------------------
|
3 |
|
|
--
|
4 |
|
|
-- Copyright (C) 2012
|
5 |
|
|
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
|
6 |
|
|
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
|
7 |
|
|
--
|
8 |
|
|
-- This program 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 |
|
|
--
|
23 |
|
|
-- Purpose: Test bench for the wideband poly phase filterbank.
|
24 |
|
|
--
|
25 |
|
|
-- The testbech uses blockgenerators to generate data for
|
26 |
|
|
-- every input of the wideband poly phase filterbank.
|
27 |
|
|
-- The output of the WPFB is stored in databuffers.
|
28 |
|
|
-- Both the block generators and databuffers are controlled
|
29 |
|
|
-- via a mm interface.
|
30 |
|
|
-- Use this testbench in conjunction with:
|
31 |
|
|
--
|
32 |
|
|
-- ../python/tc_mmf_wpfb_unit.py
|
33 |
|
|
-- For verifying the complete wideband polyphase filter bank: g_use_bg = FALSE
|
34 |
|
|
--
|
35 |
|
|
-- ../python/tc_mmf_wpfb_unit_functional.py
|
36 |
|
|
-- For verifying the different wide- and narrowband configurationss
|
37 |
|
|
-- of the wpfb_unit.
|
38 |
|
|
--
|
39 |
|
|
-- (Automated) Usage:
|
40 |
|
|
-- > Be sure that the c_start_modelsim variable is set to 1 in the script.
|
41 |
|
|
-- > Run python script in separate terminal: "python tc_mmf_wpfb_unit.py --unb 0 --bn 0 --sim"
|
42 |
|
|
--
|
43 |
|
|
-- (Manual) Usage:
|
44 |
|
|
-- > run -all
|
45 |
|
|
-- > Be sure that the c_start_modelsim variable is set to 0 in the script.
|
46 |
|
|
-- > Run python script in separate terminal: "python tc_mmf_wpfb_unit.py --unb 0 --bn 0 --sim"
|
47 |
|
|
-- > Check the results of the python script.
|
48 |
|
|
-- > Stop the simulation manually in Modelsim by pressing the stop-button.
|
49 |
|
|
-- > For fractional frequencies set g_nof_blocks=32 to be able to simulate a sufficent number of periods without transition.
|
50 |
|
|
|
51 |
|
|
|
52 |
|
|
LIBRARY IEEE, common_pkg_lib, astron_mm_lib, astron_diagnostics_lib, dp_pkg_lib, astron_r2sdf_fft_lib, astron_wb_fft_lib, astron_filter_lib, astron_ram_lib, astron_sim_tools_lib;
|
53 |
|
|
USE IEEE.std_logic_1164.ALL;
|
54 |
|
|
USE IEEE.numeric_std.ALL;
|
55 |
|
|
USE IEEE.math_real.ALL;
|
56 |
|
|
USE common_pkg_lib.common_pkg.ALL;
|
57 |
|
|
USE astron_ram_lib.common_ram_pkg.ALL;
|
58 |
|
|
USE common_pkg_lib.common_str_pkg.ALL;
|
59 |
|
|
USE common_pkg_lib.tb_common_pkg.ALL;
|
60 |
|
|
USE astron_mm_lib.tb_common_mem_pkg.ALL;
|
61 |
|
|
USE astron_mm_lib.mm_file_unb_pkg.ALL;
|
62 |
|
|
USE astron_mm_lib.mm_file_pkg.ALL;
|
63 |
|
|
USE dp_pkg_lib.dp_stream_pkg.ALL;
|
64 |
|
|
USE astron_diagnostics_lib.diag_pkg.ALL;
|
65 |
|
|
USE astron_r2sdf_fft_lib.twiddlesPkg.all;
|
66 |
|
|
USE astron_r2sdf_fft_lib.rTwoSDFPkg.all;
|
67 |
|
|
USE astron_wb_fft_lib.tb_fft_pkg.all;
|
68 |
|
|
USE astron_wb_fft_lib.fft_pkg.all;
|
69 |
|
|
USE astron_filter_lib.fil_pkg.all;
|
70 |
|
|
USE work.wpfb_pkg.all;
|
71 |
|
|
|
72 |
|
|
|
73 |
|
|
ENTITY tb_wpfb_unit_dev IS
|
74 |
|
|
GENERIC(
|
75 |
|
|
g_wb_factor : NATURAL := 1; -- = default 1, wideband factor
|
76 |
|
|
g_nof_wb_streams : NATURAL := 1; -- = 1, the number of parallel wideband streams. The filter coefficients are shared on every wb-stream.
|
77 |
|
|
g_nof_chan : NATURAL := 0; -- = default 0, defines the number of channels (=time-multiplexed input signals): nof channels = 2**nof_chan
|
78 |
|
|
g_nof_points : NATURAL := 64; -- = 1024, N point FFT
|
79 |
|
|
g_nof_taps : NATURAL := 8; -- = 8 nof taps n the filter
|
80 |
|
|
g_nof_blocks : NATURAL := 4; -- = 4, the number of blocks of g_nof_points each in the BG waveform (must be power of 2 due to that BG c_bg_block_len must be power of 2)
|
81 |
|
|
g_in_dat_w : NATURAL := 8; -- = 8, number of input bits
|
82 |
|
|
g_out_dat_w : NATURAL := 16; -- = 14, number of output bits: in_dat_w + natural((ceil_log2(nof_points))/2)
|
83 |
|
|
g_use_prefilter : BOOLEAN := FALSE; --TRUE;
|
84 |
|
|
g_use_separate : BOOLEAN := FALSE; -- = false for complex input, true for two real inputs
|
85 |
|
|
g_use_bg : BOOLEAN := FALSE;
|
86 |
|
|
g_coefs_file_prefix : STRING := "hex/chan_fil_coefs_wide"
|
87 |
|
|
);
|
88 |
|
|
END tb_wpfb_unit_dev;
|
89 |
|
|
|
90 |
|
|
ARCHITECTURE tb OF tb_wpfb_unit_dev IS
|
91 |
|
|
|
92 |
|
|
CONSTANT c_wpfb : t_wpfb := (g_wb_factor, g_nof_points, g_nof_chan, g_nof_wb_streams,
|
93 |
|
|
g_nof_taps, 0, g_in_dat_w, 16, 16,
|
94 |
|
|
true, false, g_use_separate, 16, g_out_dat_w, 0, 18, 2, true, 56, 2, 20,
|
95 |
|
|
c_fft_pipeline, c_fft_pipeline, c_fil_ppf_pipeline);
|
96 |
|
|
|
97 |
|
|
-- type t_wpfb is record
|
98 |
|
|
-- -- General parameters for the wideband poly phase filter
|
99 |
|
|
-- wb_factor : natural; -- = default 4, wideband factor
|
100 |
|
|
-- nof_points : natural; -- = 1024, N point FFT (Also the number of subbands for the filetr part)
|
101 |
|
|
-- nof_chan : natural; -- = default 0, defines the number of channels (=time-multiplexed input signals): nof channels = 2**nof_chan
|
102 |
|
|
-- nof_wb_streams : natural; -- = 1, the number of parallel wideband streams. The filter coefficients are shared on every stream.
|
103 |
|
|
--
|
104 |
|
|
-- -- Parameters for the poly phase filter
|
105 |
|
|
-- nof_taps : natural; -- = 16, the number of FIR taps per subband
|
106 |
|
|
-- fil_backoff_w : natural; -- = 0, number of bits for input backoff to avoid output overflow
|
107 |
|
|
-- fil_in_dat_w : natural; -- = 8, number of input bits
|
108 |
|
|
-- fil_out_dat_w : natural; -- = 16, number of output bits
|
109 |
|
|
-- coef_dat_w : natural; -- = 16, data width of the FIR coefficients
|
110 |
|
|
--
|
111 |
|
|
-- -- Parameters for the FFT
|
112 |
|
|
-- use_reorder : boolean; -- = false for bit-reversed output, true for normal output
|
113 |
|
|
-- 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
|
114 |
|
|
-- use_separate : boolean; -- = false for complex input, true for two real inputs
|
115 |
|
|
-- fft_in_dat_w : natural; -- = 16, number of input bits
|
116 |
|
|
-- fft_out_dat_w : natural; -- = 13, number of output bits
|
117 |
|
|
-- fft_out_gain_w : natural; -- = 0, output gain factor applied after the last stage output, before requantization to out_dat_w
|
118 |
|
|
-- stage_dat_w : natural; -- = 18, number of bits that are used inter-stage
|
119 |
|
|
--
|
120 |
|
|
-- -- Parameters for the statistics
|
121 |
|
|
-- stat_data_w : positive; -- = 56
|
122 |
|
|
-- stat_data_sz : positive; -- = 2
|
123 |
|
|
-- nof_blk_per_sync : natural; -- = 800000, number of FFT output blocks per sync interval
|
124 |
|
|
--
|
125 |
|
|
-- -- Pipeline parameters for both poly phase filter and FFT. These are heritaged from the filter and fft libraries.
|
126 |
|
|
-- pft_pipeline : t_fft_pipeline; -- Pipeline settings for the pipelined FFT
|
127 |
|
|
-- fft_pipeline : t_fft_pipeline; -- Pipeline settings for the parallel FFT
|
128 |
|
|
-- fil_pipeline : t_fil_ppf_pipeline; -- Pipeline settings for the filter units
|
129 |
|
|
--
|
130 |
|
|
-- end record;
|
131 |
|
|
|
132 |
|
|
----------------------------------------------------------------------------
|
133 |
|
|
-- Clocks and resets
|
134 |
|
|
----------------------------------------------------------------------------
|
135 |
|
|
CONSTANT c_mm_clk_period : TIME := 100 ps;
|
136 |
|
|
CONSTANT c_dp_clk_period : TIME := 5 ns;
|
137 |
|
|
CONSTANT c_sclk_period : TIME := c_dp_clk_period / c_wpfb.wb_factor;
|
138 |
|
|
CONSTANT c_dp_pps_period : NATURAL := 64;
|
139 |
|
|
|
140 |
|
|
SIGNAL dp_pps : STD_LOGIC;
|
141 |
|
|
|
142 |
|
|
SIGNAL mm_rst : STD_LOGIC;
|
143 |
|
|
SIGNAL mm_clk : STD_LOGIC := '0';
|
144 |
|
|
|
145 |
|
|
SIGNAL dp_rst : STD_LOGIC;
|
146 |
|
|
SIGNAL dp_clk : STD_LOGIC := '0';
|
147 |
|
|
|
148 |
|
|
SIGNAL SCLK : STD_LOGIC := '0';
|
149 |
|
|
|
150 |
|
|
----------------------------------------------------------------------------
|
151 |
|
|
-- MM buses
|
152 |
|
|
----------------------------------------------------------------------------
|
153 |
|
|
SIGNAL reg_diag_bg_mosi : t_mem_mosi;
|
154 |
|
|
SIGNAL reg_diag_bg_miso : t_mem_miso;
|
155 |
|
|
|
156 |
|
|
SIGNAL ram_diag_bg_mosi : t_mem_mosi;
|
157 |
|
|
SIGNAL ram_diag_bg_miso : t_mem_miso;
|
158 |
|
|
|
159 |
|
|
SIGNAL ram_diag_data_buf_re_mosi : t_mem_mosi;
|
160 |
|
|
SIGNAL ram_diag_data_buf_re_miso : t_mem_miso;
|
161 |
|
|
|
162 |
|
|
SIGNAL reg_diag_data_buf_re_mosi : t_mem_mosi;
|
163 |
|
|
SIGNAL reg_diag_data_buf_re_miso : t_mem_miso;
|
164 |
|
|
|
165 |
|
|
SIGNAL ram_diag_data_buf_im_mosi : t_mem_mosi;
|
166 |
|
|
SIGNAL ram_diag_data_buf_im_miso : t_mem_miso;
|
167 |
|
|
|
168 |
|
|
SIGNAL reg_diag_data_buf_im_mosi : t_mem_mosi;
|
169 |
|
|
SIGNAL reg_diag_data_buf_im_miso : t_mem_miso;
|
170 |
|
|
|
171 |
|
|
SIGNAL ram_st_sst_mosi : t_mem_mosi := c_mem_mosi_rst;
|
172 |
|
|
SIGNAL ram_st_sst_miso : t_mem_miso := c_mem_miso_rst;
|
173 |
|
|
|
174 |
|
|
SIGNAL ram_fil_coefs_mosi : t_mem_mosi := c_mem_mosi_rst;
|
175 |
|
|
SIGNAL ram_fil_coefs_miso : t_mem_miso := c_mem_miso_rst;
|
176 |
|
|
|
177 |
|
|
SIGNAL reg_diag_bg_pfb_mosi : t_mem_mosi := c_mem_mosi_rst;
|
178 |
|
|
SIGNAL reg_diag_bg_pfb_miso : t_mem_miso := c_mem_miso_rst;
|
179 |
|
|
|
180 |
|
|
SIGNAL ram_diag_bg_pfb_mosi : t_mem_mosi := c_mem_mosi_rst;
|
181 |
|
|
SIGNAL ram_diag_bg_pfb_miso : t_mem_miso := c_mem_miso_rst;
|
182 |
|
|
|
183 |
|
|
CONSTANT c_coefs_file_prefix : STRING := g_coefs_file_prefix & NATURAL'IMAGE(c_wpfb.wb_factor) & "_p"& NATURAL'IMAGE(c_wpfb.nof_points) & "_t"& NATURAL'IMAGE(c_wpfb.nof_taps);
|
184 |
|
|
|
185 |
|
|
CONSTANT c_nof_streams : POSITIVE := c_wpfb.nof_wb_streams*c_wpfb.wb_factor;
|
186 |
|
|
CONSTANT c_nof_channels : NATURAL := 2**c_wpfb.nof_chan;
|
187 |
|
|
CONSTANT c_bg_block_len : NATURAL := c_wpfb.nof_points*g_nof_blocks*c_nof_channels/c_wpfb.wb_factor;
|
188 |
|
|
|
189 |
|
|
CONSTANT c_bg_buf_adr_w : NATURAL := ceil_log2(c_bg_block_len);
|
190 |
|
|
CONSTANT c_bg_data_file_index_arr : t_nat_natural_arr := array_init(0, c_nof_streams, 1);
|
191 |
|
|
CONSTANT c_bg_data_file_prefix : STRING := "UNUSED";
|
192 |
|
|
|
193 |
|
|
SIGNAL bg_siso_arr : t_dp_siso_arr(c_nof_streams-1 DOWNTO 0) := (OTHERS=>c_dp_siso_rdy);
|
194 |
|
|
SIGNAL bg_sosi_arr : t_dp_sosi_arr(c_nof_streams-1 DOWNTO 0);
|
195 |
|
|
SIGNAL out_sosi_arr : t_dp_sosi_arr(c_nof_streams-1 DOWNTO 0);
|
196 |
|
|
|
197 |
|
|
SIGNAL scope_in_sosi : t_dp_sosi_integer_arr(c_wpfb.nof_wb_streams-1 DOWNTO 0);
|
198 |
|
|
SIGNAL scope_out_sosi : t_dp_sosi_integer_arr(c_wpfb.nof_wb_streams-1 DOWNTO 0);
|
199 |
|
|
SIGNAL scope_out_power : REAL := 0.0;
|
200 |
|
|
SIGNAL scope_out_ampl : REAL := 0.0;
|
201 |
|
|
SIGNAL scope_out_index : NATURAL;
|
202 |
|
|
SIGNAL scope_out_bin : NATURAL;
|
203 |
|
|
SIGNAL scope_out_band : NATURAL;
|
204 |
|
|
SIGNAL scope_out_ampl_x : REAL := 0.0;
|
205 |
|
|
SIGNAL scope_out_ampl_y : REAL := 0.0;
|
206 |
|
|
|
207 |
|
|
BEGIN
|
208 |
|
|
|
209 |
|
|
----------------------------------------------------------------------------
|
210 |
|
|
-- Clock and reset generation
|
211 |
|
|
----------------------------------------------------------------------------
|
212 |
|
|
mm_clk <= NOT mm_clk AFTER c_mm_clk_period/2;
|
213 |
|
|
mm_rst <= '1', '0' AFTER c_mm_clk_period*5;
|
214 |
|
|
|
215 |
|
|
dp_clk <= NOT dp_clk AFTER c_dp_clk_period/2;
|
216 |
|
|
dp_rst <= '1', '0' AFTER c_dp_clk_period*5;
|
217 |
|
|
|
218 |
|
|
SCLK <= NOT SCLK AFTER c_sclk_period/2;
|
219 |
|
|
|
220 |
|
|
------------------------------------------------------------------------------
|
221 |
|
|
-- External PPS
|
222 |
|
|
------------------------------------------------------------------------------
|
223 |
|
|
proc_common_gen_pulse(1, c_dp_pps_period, '1', dp_clk, dp_pps);
|
224 |
|
|
|
225 |
|
|
----------------------------------------------------------------------------
|
226 |
|
|
-- Procedure that polls a sim control file that can be used to e.g. get
|
227 |
|
|
-- the simulation time in ns
|
228 |
|
|
----------------------------------------------------------------------------
|
229 |
|
|
mmf_poll_sim_ctrl_file(c_mmf_unb_file_path & "sim.ctrl", c_mmf_unb_file_path & "sim.stat");
|
230 |
|
|
|
231 |
|
|
----------------------------------------------------------------------------
|
232 |
|
|
-- MM buses
|
233 |
|
|
----------------------------------------------------------------------------
|
234 |
|
|
u_mm_file_reg_diag_bg : mm_file GENERIC MAP(mmf_unb_file_prefix(0, 0, "BN") & "REG_DIAG_BG")
|
235 |
|
|
PORT MAP(mm_rst, mm_clk, reg_diag_bg_mosi, reg_diag_bg_miso);
|
236 |
|
|
|
237 |
|
|
u_mm_file_ram_diag_bg : mm_file GENERIC MAP(mmf_unb_file_prefix(0, 0, "BN") & "RAM_DIAG_BG")
|
238 |
|
|
PORT MAP(mm_rst, mm_clk, ram_diag_bg_mosi, ram_diag_bg_miso);
|
239 |
|
|
|
240 |
|
|
u_mm_file_ram_diag_data_buf_re : mm_file GENERIC MAP(mmf_unb_file_prefix(0, 0, "BN") & "RAM_DIAG_DATA_BUFFER_REAL")
|
241 |
|
|
PORT MAP(mm_rst, mm_clk, ram_diag_data_buf_re_mosi, ram_diag_data_buf_re_miso);
|
242 |
|
|
|
243 |
|
|
u_mm_file_reg_diag_data_buf_re : mm_file GENERIC MAP(mmf_unb_file_prefix(0, 0, "BN") & "REG_DIAG_DATA_BUFFER_REAL")
|
244 |
|
|
PORT MAP(mm_rst, mm_clk, reg_diag_data_buf_re_mosi, reg_diag_data_buf_re_miso);
|
245 |
|
|
|
246 |
|
|
u_mm_file_ram_diag_data_buf_im : mm_file GENERIC MAP(mmf_unb_file_prefix(0, 0, "BN") & "RAM_DIAG_DATA_BUFFER_IMAG")
|
247 |
|
|
PORT MAP(mm_rst, mm_clk, ram_diag_data_buf_im_mosi, ram_diag_data_buf_im_miso);
|
248 |
|
|
|
249 |
|
|
u_mm_file_reg_diag_data_buf_im : mm_file GENERIC MAP(mmf_unb_file_prefix(0, 0, "BN") & "REG_DIAG_DATA_BUFFER_IMAG")
|
250 |
|
|
PORT MAP(mm_rst, mm_clk, reg_diag_data_buf_im_mosi, reg_diag_data_buf_im_miso);
|
251 |
|
|
|
252 |
|
|
u_mm_file_ram_fil_coefs : mm_file GENERIC MAP(mmf_unb_file_prefix(0, 0, "BN") & "RAM_FIL_COEFS")
|
253 |
|
|
PORT MAP(mm_rst, mm_clk, ram_fil_coefs_mosi, ram_fil_coefs_miso);
|
254 |
|
|
|
255 |
|
|
u_mm_file_ram_st_sst : mm_file GENERIC MAP(mmf_unb_file_prefix(0, 0, "BN") & "RAM_ST_SST")
|
256 |
|
|
PORT MAP(mm_rst, mm_clk, ram_st_sst_mosi, ram_st_sst_miso);
|
257 |
|
|
|
258 |
|
|
u_mm_file_reg_diag_pfb_bg : mm_file GENERIC MAP(mmf_unb_file_prefix(0, 0, "BN") & "REG_DIAG_BG_PFB")
|
259 |
|
|
PORT MAP(mm_rst, mm_clk, reg_diag_bg_pfb_mosi, reg_diag_bg_pfb_miso);
|
260 |
|
|
|
261 |
|
|
u_mm_file_ram_diag_pfb_bg : mm_file GENERIC MAP(mmf_unb_file_prefix(0, 0, "BN") & "RAM_DIAG_BG_PFB")
|
262 |
|
|
PORT MAP(mm_rst, mm_clk, ram_diag_bg_pfb_mosi, ram_diag_bg_pfb_miso);
|
263 |
|
|
|
264 |
|
|
----------------------------------------------------------------------------
|
265 |
|
|
-- Source: block generator
|
266 |
|
|
----------------------------------------------------------------------------
|
267 |
|
|
u_bg : ENTITY astron_diagnostics_lib.mms_diag_block_gen
|
268 |
|
|
GENERIC MAP(
|
269 |
|
|
g_nof_streams => c_nof_streams,
|
270 |
|
|
g_buf_dat_w => c_nof_complex*c_wpfb.fil_in_dat_w,
|
271 |
|
|
g_buf_addr_w => c_bg_buf_adr_w, -- Waveform buffer size 2**g_buf_addr_w nof samples
|
272 |
|
|
g_file_index_arr => c_bg_data_file_index_arr,
|
273 |
|
|
g_file_name_prefix => c_bg_data_file_prefix
|
274 |
|
|
)
|
275 |
|
|
PORT MAP(
|
276 |
|
|
-- System
|
277 |
|
|
mm_rst => mm_rst,
|
278 |
|
|
mm_clk => mm_clk,
|
279 |
|
|
dp_rst => dp_rst,
|
280 |
|
|
dp_clk => dp_clk,
|
281 |
|
|
en_sync => dp_pps,
|
282 |
|
|
-- MM interface
|
283 |
|
|
reg_bg_ctrl_mosi => reg_diag_bg_mosi,
|
284 |
|
|
reg_bg_ctrl_miso => reg_diag_bg_miso,
|
285 |
|
|
ram_bg_data_mosi => ram_diag_bg_mosi,
|
286 |
|
|
ram_bg_data_miso => ram_diag_bg_miso,
|
287 |
|
|
-- ST interface
|
288 |
|
|
out_siso_arr => bg_siso_arr,
|
289 |
|
|
out_sosi_arr => bg_sosi_arr
|
290 |
|
|
);
|
291 |
|
|
|
292 |
|
|
----------------------------------------------------------------------------
|
293 |
|
|
-- Source: DUT input scope
|
294 |
|
|
----------------------------------------------------------------------------
|
295 |
|
|
gen_input_scopes : FOR I IN 0 TO c_wpfb.nof_wb_streams-1 GENERATE
|
296 |
|
|
u_in_scope : ENTITY astron_sim_tools_lib.dp_wideband_wb_arr_scope
|
297 |
|
|
GENERIC MAP (
|
298 |
|
|
g_sim => TRUE,
|
299 |
|
|
g_wideband_factor => c_wpfb.wb_factor,
|
300 |
|
|
g_wideband_big_endian => FALSE,
|
301 |
|
|
g_dat_w => c_wpfb.fil_in_dat_w
|
302 |
|
|
)
|
303 |
|
|
PORT MAP (
|
304 |
|
|
SCLK => SCLK,
|
305 |
|
|
wb_sosi_arr => bg_sosi_arr((I+1)*c_wpfb.wb_factor-1 DOWNTO I*c_wpfb.wb_factor),
|
306 |
|
|
scope_sosi => scope_in_sosi(I)
|
307 |
|
|
);
|
308 |
|
|
END GENERATE;
|
309 |
|
|
----------------------------------------------------------------------------
|
310 |
|
|
-- DUT = Device Under Test
|
311 |
|
|
----------------------------------------------------------------------------
|
312 |
|
|
u_dut : ENTITY work.wpfb_unit_dev
|
313 |
|
|
GENERIC MAP(
|
314 |
|
|
g_wpfb => c_wpfb,
|
315 |
|
|
g_use_bg => g_use_bg,
|
316 |
|
|
g_use_prefilter => g_use_prefilter,
|
317 |
|
|
g_coefs_file_prefix => c_coefs_file_prefix
|
318 |
|
|
)
|
319 |
|
|
PORT MAP(
|
320 |
|
|
dp_rst => dp_rst,
|
321 |
|
|
dp_clk => dp_clk,
|
322 |
|
|
mm_rst => mm_rst,
|
323 |
|
|
mm_clk => mm_clk,
|
324 |
|
|
ram_fil_coefs_mosi => ram_fil_coefs_mosi,
|
325 |
|
|
ram_fil_coefs_miso => ram_fil_coefs_miso,
|
326 |
|
|
ram_st_sst_mosi => ram_st_sst_mosi,
|
327 |
|
|
ram_st_sst_miso => ram_st_sst_miso,
|
328 |
|
|
reg_bg_ctrl_mosi => reg_diag_bg_pfb_mosi,
|
329 |
|
|
reg_bg_ctrl_miso => reg_diag_bg_pfb_miso,
|
330 |
|
|
ram_bg_data_mosi => ram_diag_bg_pfb_mosi,
|
331 |
|
|
ram_bg_data_miso => ram_diag_bg_pfb_miso,
|
332 |
|
|
in_sosi_arr => bg_sosi_arr,
|
333 |
|
|
out_sosi_arr => out_sosi_arr
|
334 |
|
|
);
|
335 |
|
|
|
336 |
|
|
time_map : process is
|
337 |
|
|
variable sim_time_str_v : string(1 to 30); -- 30 chars should be enough
|
338 |
|
|
variable sim_time_len_v : natural;
|
339 |
|
|
begin
|
340 |
|
|
wait for 1000 ns;
|
341 |
|
|
sim_time_len_v := time'image(now)'length;
|
342 |
|
|
sim_time_str_v := (others => ' ');
|
343 |
|
|
sim_time_str_v(1 to sim_time_len_v) := time'image(now);
|
344 |
|
|
report "Sim time string length: " & integer'image(sim_time_len_v);
|
345 |
|
|
report "Sim time string.......:'" & sim_time_str_v & "'";
|
346 |
|
|
end process;
|
347 |
|
|
|
348 |
|
|
----------------------------------------------------------------------------
|
349 |
|
|
-- Sink: DUT output scope
|
350 |
|
|
----------------------------------------------------------------------------
|
351 |
|
|
gen_output_scopes : FOR I IN 0 TO c_wpfb.nof_wb_streams-1 GENERATE
|
352 |
|
|
u_out_scope : ENTITY astron_sim_tools_lib.dp_wideband_wb_arr_scope
|
353 |
|
|
GENERIC MAP (
|
354 |
|
|
g_sim => TRUE,
|
355 |
|
|
g_wideband_factor => c_wpfb.wb_factor,
|
356 |
|
|
g_wideband_big_endian => FALSE,
|
357 |
|
|
g_dat_w => c_wpfb.fft_out_dat_w
|
358 |
|
|
)
|
359 |
|
|
PORT MAP (
|
360 |
|
|
SCLK => SCLK,
|
361 |
|
|
wb_sosi_arr => out_sosi_arr((I+1)*c_wpfb.wb_factor-1 DOWNTO I*c_wpfb.wb_factor),
|
362 |
|
|
scope_sosi => scope_out_sosi(I)
|
363 |
|
|
);
|
364 |
|
|
END GENERATE;
|
365 |
|
|
|
366 |
|
|
p_scope_out_index : PROCESS(SCLK)
|
367 |
|
|
BEGIN
|
368 |
|
|
IF rising_edge(SCLK) THEN
|
369 |
|
|
IF scope_out_sosi(0).valid='1' THEN
|
370 |
|
|
scope_out_index <= scope_out_index+1;
|
371 |
|
|
IF scope_out_index>=g_nof_points-1 THEN
|
372 |
|
|
scope_out_index <= 0;
|
373 |
|
|
END IF;
|
374 |
|
|
END IF;
|
375 |
|
|
END IF;
|
376 |
|
|
END PROCESS;
|
377 |
|
|
scope_out_bin <= fft_index_to_bin_frequency(c_wpfb.wb_factor, c_wpfb.nof_points, scope_out_index, TRUE, FALSE, TRUE); -- complex bin
|
378 |
|
|
scope_out_band <= fft_index_to_bin_frequency(c_wpfb.wb_factor, c_wpfb.nof_points, scope_out_index, TRUE, TRUE, TRUE); -- two real bin
|
379 |
|
|
|
380 |
|
|
scope_out_power <= REAL(scope_out_sosi(0).re)**2 + REAL(scope_out_sosi(0).im)**2;
|
381 |
|
|
scope_out_ampl <= SQRT(scope_out_power);
|
382 |
|
|
scope_out_ampl_x <= scope_out_ampl WHEN (scope_out_bin MOD 2)=0 ELSE 0.0;
|
383 |
|
|
scope_out_ampl_y <= scope_out_ampl WHEN (scope_out_bin MOD 2)=1 ELSE 0.0;
|
384 |
|
|
|
385 |
|
|
----------------------------------------------------------------------------
|
386 |
|
|
-- Sink: data buffer real
|
387 |
|
|
----------------------------------------------------------------------------
|
388 |
|
|
u_data_buf_re : ENTITY astron_diagnostics_lib.mms_diag_data_buffer
|
389 |
|
|
GENERIC MAP (
|
390 |
|
|
g_nof_streams => c_nof_streams,
|
391 |
|
|
g_data_type => e_real,
|
392 |
|
|
g_data_w => c_wpfb.fft_out_dat_w,
|
393 |
|
|
g_buf_nof_data => c_bg_block_len,
|
394 |
|
|
g_buf_use_sync => TRUE
|
395 |
|
|
)
|
396 |
|
|
PORT MAP (
|
397 |
|
|
-- System
|
398 |
|
|
mm_rst => mm_rst,
|
399 |
|
|
mm_clk => mm_clk,
|
400 |
|
|
dp_rst => dp_rst,
|
401 |
|
|
dp_clk => dp_clk,
|
402 |
|
|
|
403 |
|
|
-- MM interface
|
404 |
|
|
ram_data_buf_mosi => ram_diag_data_buf_re_mosi,
|
405 |
|
|
ram_data_buf_miso => ram_diag_data_buf_re_miso,
|
406 |
|
|
|
407 |
|
|
reg_data_buf_mosi => reg_diag_data_buf_re_mosi,
|
408 |
|
|
reg_data_buf_miso => reg_diag_data_buf_re_miso,
|
409 |
|
|
|
410 |
|
|
-- ST interface
|
411 |
|
|
in_sync => out_sosi_arr(0).sync,
|
412 |
|
|
in_sosi_arr => out_sosi_arr
|
413 |
|
|
);
|
414 |
|
|
|
415 |
|
|
----------------------------------------------------------------------------
|
416 |
|
|
-- Sink: data buffer imag
|
417 |
|
|
----------------------------------------------------------------------------
|
418 |
|
|
u_data_buf_im : ENTITY astron_diagnostics_lib.mms_diag_data_buffer
|
419 |
|
|
GENERIC MAP (
|
420 |
|
|
g_nof_streams => c_nof_streams,
|
421 |
|
|
g_data_type => e_imag,
|
422 |
|
|
g_data_w => c_wpfb.fft_out_dat_w,
|
423 |
|
|
g_buf_nof_data => c_bg_block_len,
|
424 |
|
|
g_buf_use_sync => TRUE
|
425 |
|
|
)
|
426 |
|
|
PORT MAP (
|
427 |
|
|
-- System
|
428 |
|
|
mm_rst => mm_rst,
|
429 |
|
|
mm_clk => mm_clk,
|
430 |
|
|
dp_rst => dp_rst,
|
431 |
|
|
dp_clk => dp_clk,
|
432 |
|
|
|
433 |
|
|
-- MM interface
|
434 |
|
|
ram_data_buf_mosi => ram_diag_data_buf_im_mosi,
|
435 |
|
|
ram_data_buf_miso => ram_diag_data_buf_im_miso,
|
436 |
|
|
|
437 |
|
|
reg_data_buf_mosi => reg_diag_data_buf_im_mosi,
|
438 |
|
|
reg_data_buf_miso => reg_diag_data_buf_im_miso,
|
439 |
|
|
|
440 |
|
|
-- ST interface
|
441 |
|
|
in_sync => out_sosi_arr(0).sync,
|
442 |
|
|
in_sosi_arr => out_sosi_arr
|
443 |
|
|
);
|
444 |
|
|
|
445 |
|
|
END tb;
|