diff --git a/applications/lofar2/libraries/sdp/hdllib.cfg b/applications/lofar2/libraries/sdp/hdllib.cfg index d4df839f258eb81cc7febb610627c832a351e6d4..bb9487754ada43e78e013659a77aace61681ab4c 100644 --- a/applications/lofar2/libraries/sdp/hdllib.cfg +++ b/applications/lofar2/libraries/sdp/hdllib.cfg @@ -5,6 +5,8 @@ hdl_lib_uses_sim = hdl_lib_technology = synth_files = + src/vhdl/sdp_pkg.vhd + src/vhdl/sdp_scope.vhd src/vhdl/node_sdp_filterbank.vhd test_bench_files = diff --git a/applications/lofar2/libraries/sdp/src/vhdl/node_sdp_filterbank.vhd b/applications/lofar2/libraries/sdp/src/vhdl/node_sdp_filterbank.vhd index 0a1711cb3870188f62ad7ad5a9865704e22cea4c..1714612c629a8a85b33d1e3979d8ef5024739fb9 100644 --- a/applications/lofar2/libraries/sdp/src/vhdl/node_sdp_filterbank.vhd +++ b/applications/lofar2/libraries/sdp/src/vhdl/node_sdp_filterbank.vhd @@ -43,18 +43,19 @@ USE dp_lib.dp_stream_pkg.ALL; USE rTwoSDF_lib.rTwoSDFPkg.ALL; USE filter_lib.fil_pkg.ALL; USE wpfb_lib.wpfb_pkg.ALL; +USE work.sdp_pkg.ALL; ENTITY node_sdp_filterbank IS GENERIC ( - g_sim : BOOLEAN := FALSE; - g_nof_streams : NATURAL := 12 -- CONSTANT + g_sim : BOOLEAN := FALSE; + g_scope_selected_subband : NATURAL := 0 ); PORT ( dp_clk : IN STD_LOGIC; dp_rst : IN STD_LOGIC; - in_sosi_arr : IN t_dp_sosi_arr(g_nof_streams-1 DOWNTO 0); - pfb_sosi_arr : OUT t_dp_sosi_arr(g_nof_streams/2-1 DOWNTO 0); + in_sosi_arr : IN t_dp_sosi_arr(c_sdp_S_pn-1 DOWNTO 0); + pfb_sosi_arr : OUT t_dp_sosi_arr(c_sdp_P_pfb-1 DOWNTO 0); mm_rst : IN STD_LOGIC; mm_clk : IN STD_LOGIC; @@ -69,28 +70,17 @@ ENTITY node_sdp_filterbank IS END node_sdp_filterbank; ARCHITECTURE str OF node_sdp_filterbank IS - - -- In SDP c_nof_channels = 2**nof_chan = 1 and wb_factor = 1, - -- therefore these parameters are not explicitly used in calculation of derived constants - CONSTANT c_wpfb_lofar_subbands : t_wpfb := - (1, 1024, 0, 6, - 16, 1, 14, 16, 16, - true, false, true, 16, 18, 1, 18, 2, true, 54, 2, 195313, - c_fft_pipeline, c_fft_pipeline, c_fil_ppf_pipeline); - CONSTANT c_in_dat_w : NATURAL := c_wpfb_lofar_subbands.fil_in_dat_w; - CONSTANT c_out_dat_w : NATURAL := c_wpfb_lofar_subbands.fft_out_dat_w; - CONSTANT c_coefs_file_prefix : STRING := "UNUSED"; --"data/coefs_wide"; - SIGNAL ram_st_sst_mosi_arr : t_mem_mosi_arr(c_wpfb_lofar_subbands.nof_wb_streams-1 DOWNTO 0) := (OTHERS => c_mem_mosi_rst); - SIGNAL ram_st_sst_miso_arr : t_mem_miso_arr(c_wpfb_lofar_subbands.nof_wb_streams-1 DOWNTO 0) := (OTHERS => c_mem_miso_rst); + SIGNAL ram_st_sst_mosi_arr : t_mem_mosi_arr(c_sdp_P_pfb-1 DOWNTO 0) := (OTHERS => c_mem_mosi_rst); + SIGNAL ram_st_sst_miso_arr : t_mem_miso_arr(c_sdp_P_pfb-1 DOWNTO 0) := (OTHERS => c_mem_miso_rst); - SIGNAL si_sosi_arr : t_dp_sosi_arr(g_nof_streams-1 DOWNTO 0) := (OTHERS => c_dp_sosi_rst); - SIGNAL wpfb_unit_out_sosi_arr : t_dp_sosi_arr(c_wpfb_lofar_subbands.nof_wb_streams-1 DOWNTO 0) := (OTHERS => c_dp_sosi_rst); - SIGNAL wpfb_unit_fil_sosi_arr : t_dp_sosi_arr(c_wpfb_lofar_subbands.nof_wb_streams-1 DOWNTO 0) := (OTHERS => c_dp_sosi_rst); - SIGNAL wpfb_unit_in_sosi_arr : t_dp_sosi_arr(c_wpfb_lofar_subbands.nof_wb_streams-1 DOWNTO 0) := (OTHERS => c_dp_sosi_rst); - SIGNAL scope_sosi_arr : t_dp_sosi_integer_arr(c_wpfb_lofar_subbands.nof_wb_streams-1 DOWNTO 0); + SIGNAL si_sosi_arr : t_dp_sosi_arr(c_sdp_S_pn-1 DOWNTO 0) := (OTHERS => c_dp_sosi_rst); + SIGNAL wpfb_unit_out_sosi_arr : t_dp_sosi_arr(c_sdp_P_pfb-1 DOWNTO 0) := (OTHERS => c_dp_sosi_rst); + SIGNAL wpfb_unit_fil_sosi_arr : t_dp_sosi_arr(c_sdp_P_pfb-1 DOWNTO 0) := (OTHERS => c_dp_sosi_rst); + SIGNAL wpfb_unit_in_sosi_arr : t_dp_sosi_arr(c_sdp_P_pfb-1 DOWNTO 0) := (OTHERS => c_dp_sosi_rst); + SIGNAL scope_sosi_arr : t_dp_sosi_integer_arr(c_sdp_S_pn-1 DOWNTO 0); BEGIN --------------------------------------------------------------- @@ -98,9 +88,9 @@ BEGIN --------------------------------------------------------------- u_si_arr : ENTITY si_lib.si_arr GENERIC MAP ( - g_nof_streams => g_nof_streams, + g_nof_streams => c_sdp_S_pn, g_pipeline => 1, - g_dat_w => c_in_dat_w + g_dat_w => c_sdp_W_adc ) PORT MAP( in_sosi_arr => in_sosi_arr, @@ -121,7 +111,7 @@ BEGIN -- Connect the 12 ADC streams to the re and im fields of the PFB input. p_pfb_streams : PROCESS(si_sosi_arr) BEGIN - FOR I IN 0 TO c_wpfb_lofar_subbands.nof_wb_streams-1 LOOP + FOR I IN 0 TO c_sdp_P_pfb-1 LOOP wpfb_unit_in_sosi_arr(I) <= si_sosi_arr(2*I); wpfb_unit_in_sosi_arr(I).re <= RESIZE_DP_DSP_DATA(si_sosi_arr(2*I).data); wpfb_unit_in_sosi_arr(I).im <= RESIZE_DP_DSP_DATA(si_sosi_arr(2*I+1).data); @@ -131,7 +121,7 @@ BEGIN -- PFB u_wpfb_unit_dev : ENTITY wpfb_lib.wpfb_unit_dev GENERIC MAP ( - g_wpfb => c_wpfb_lofar_subbands, + g_wpfb => c_sdp_wpfb_subbands, g_use_prefilter => TRUE, g_stats_ena => FALSE, g_use_bg => FALSE, @@ -157,13 +147,13 @@ BEGIN --------------------------------------------------------------- -- SUBBAND STATISTICS --------------------------------------------------------------- - gen_stats_streams: FOR I IN 0 TO c_wpfb_lofar_subbands.nof_wb_streams-1 GENERATE + gen_stats_streams: FOR I IN 0 TO c_sdp_P_pfb-1 GENERATE u_subband_stats : ENTITY st_lib.st_sst GENERIC MAP( - g_nof_stat => c_wpfb_lofar_subbands.nof_points, - g_in_data_w => c_wpfb_lofar_subbands.fft_out_dat_w, - g_stat_data_w => c_wpfb_lofar_subbands.stat_data_w, - g_stat_data_sz => c_wpfb_lofar_subbands.stat_data_sz + g_nof_stat => c_sdp_N_fft, + g_in_data_w => c_sdp_W_subband, + g_stat_data_w => c_sdp_wpfb_subbands.stat_data_w, + g_stat_data_sz => c_sdp_wpfb_subbands.stat_data_sz ) PORT MAP ( mm_rst => mm_rst, @@ -183,8 +173,8 @@ BEGIN -- statistics to one array. u_mem_mux_sst : ENTITY common_lib.common_mem_mux GENERIC MAP ( - g_nof_mosi => c_wpfb_lofar_subbands.nof_wb_streams, - g_mult_addr_w => ceil_log2(c_wpfb_lofar_subbands.stat_data_sz*c_wpfb_lofar_subbands.nof_points) + g_nof_mosi => c_sdp_P_pfb, + g_mult_addr_w => ceil_log2(c_sdp_N_fft*c_sdp_wpfb_subbands.stat_data_sz) ) PORT MAP ( mosi => ram_st_sst_mosi, @@ -196,17 +186,14 @@ BEGIN --------------------------------------------------------------- -- SIGNAL SCOPE --------------------------------------------------------------- - u_dp_wideband_sp_arr_scope : ENTITY dp_lib.dp_wideband_sp_arr_scope + u_sdp_scope : ENTITY work.sdp_scope GENERIC MAP ( - g_sim => g_sim, - g_use_sclk => FALSE, - g_complex => TRUE, - g_nof_streams => c_wpfb_lofar_subbands.nof_wb_streams, - g_wideband_factor => 1, - g_dat_w => c_out_dat_w + g_sim => g_sim, + g_selected_subband => g_scope_selected_subband ) PORT MAP ( - DCLK => dp_clk, + clk => dp_clk, + rst => dp_rst, sp_sosi_arr => wpfb_unit_out_sosi_arr, scope_sosi_arr => scope_sosi_arr ); diff --git a/applications/lofar2/libraries/sdp/src/vhdl/sdp_pkg.vhd b/applications/lofar2/libraries/sdp/src/vhdl/sdp_pkg.vhd new file mode 100644 index 0000000000000000000000000000000000000000..08de4349383765eb7a69717ca89e920df2dc315d --- /dev/null +++ b/applications/lofar2/libraries/sdp/src/vhdl/sdp_pkg.vhd @@ -0,0 +1,68 @@ +------------------------------------------------------------------------------- +-- +-- Copyright 2020 +-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> +-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +------------------------------------------------------------------------------- + +------------------------------------------------------------------------------- +-- +-- Author: R. van der Walle +-- Purpose: +-- . This package contains sdp specific constants. +-- Description: +-- Remark: +-- . See Document: L3 SDP Decision: SDP Parameter definitions. +------------------------------------------------------------------------------- +LIBRARY ieee, common_lib, rTwoSDF_lib, fft_lib, filter_lib, wpfb_lib; +USE IEEE.std_logic_1164.ALL; +USE common_lib.common_pkg.ALL; +USE rTwoSDF_lib.rTwoSDFPkg.ALL; +USE fft_lib.fft_pkg.ALL; +USE filter_lib.fil_pkg.ALL; +USE wpfb_lib.wpfb_pkg.ALL; + +PACKAGE sdp_pkg is + ------------------------------------------------- + -- SDP specific parameters as defined in: + -- L3 SDP Decision: SDP Parameter definitions + ------------------------------------------------- + CONSTANT c_sdp_N_fft : NATURAL := 1024; + CONSTANT c_sdp_S_pn : NATURAL := 12; + CONSTANT c_sdp_Q_fft : NATURAL := 2; + CONSTANT c_sdp_N_taps : NATURAL := 16; + CONSTANT c_sdp_W_adc : NATURAL := 14; + CONSTANT c_sdp_W_fir_coef : NATURAL := 16; + CONSTANT c_sdp_W_subband : NATURAL := 18; + CONSTANT c_sdp_P_pfb : NATURAL := c_sdp_S_pn/c_sdp_Q_fft; + + + -- In SDP c_nof_channels = 2**nof_chan = 1 and wb_factor = 1, + -- therefore these parameters are not explicitly used in calculation of derived constants + CONSTANT c_sdp_wpfb_subbands : t_wpfb := + (1, c_sdp_N_fft, 0, c_sdp_P_pfb, + c_sdp_N_taps, 1, c_sdp_W_adc, 16, c_sdp_W_fir_coef, + true, false, true, 16, c_sdp_W_subband, 1, 18, 2, + true, 54, 2, 195313, c_fft_pipeline, c_fft_pipeline, + c_fil_ppf_pipeline); + +END PACKAGE sdp_pkg; + +PACKAGE BODY sdp_pkg IS + + +END sdp_pkg; + diff --git a/applications/lofar2/libraries/sdp/src/vhdl/sdp_scope.vhd b/applications/lofar2/libraries/sdp/src/vhdl/sdp_scope.vhd new file mode 100644 index 0000000000000000000000000000000000000000..3eafe568e04c8c0a7c14169afd5553d649a54413 --- /dev/null +++ b/applications/lofar2/libraries/sdp/src/vhdl/sdp_scope.vhd @@ -0,0 +1,130 @@ +------------------------------------------------------------------------------- +-- +-- Copyright 2020 +-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> +-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +------------------------------------------------------------------------------- + +------------------------------------------------------------------------------- +-- +-- Author: R. van der Walle + +-- Purpose: +-- . Scope component to show the desired subband from the PFB output in the wave +-- window. +-- Description: +-- Remark: +-- . Only for simulation. +-- . g_selected_subband can be 0 - 511. +------------------------------------------------------------------------------- + +LIBRARY IEEE, common_lib, dp_lib; +USE IEEE.STD_LOGIC_1164.ALL; +USE common_lib.common_pkg.ALL; +USE dp_lib.dp_stream_pkg.ALL; +USE work.sdp_pkg.ALL; + +ENTITY sdp_scope IS + GENERIC ( + g_sim : BOOLEAN := FALSE; + g_selected_subband : NATURAL := 0 + ); + PORT ( + clk : IN STD_LOGIC; + rst : IN STD_LOGIC; + + -- Streaming input samples for g_nof_streams + sp_sosi_arr : IN t_dp_sosi_arr(c_sdp_P_pfb-1 DOWNTO 0); -- = [3:0] = Signal Paths [D,C,B,A] + + -- Scope output samples for g_nof_streams + scope_sosi_arr : OUT t_dp_sosi_integer_arr(c_sdp_S_pn-1 DOWNTO 0) + ); +END sdp_scope; + + +ARCHITECTURE str OF sdp_scope IS + + SIGNAL cnt_arr : t_natural_arr(c_sdp_S_pn-1 DOWNTO 0); + SIGNAL deinterleaved_sosi_arr : t_dp_sosi_arr(c_sdp_S_pn-1 DOWNTO 0); + SIGNAL subband_sosi_arr : t_dp_sosi_arr(c_sdp_S_pn-1 DOWNTO 0) := (OTHERS=>c_dp_sosi_rst); + +BEGIN + + sim_only : IF g_sim=TRUE GENERATE + + gen_deinterleave : FOR I IN 0 TO c_sdp_P_pfb-1 GENERATE + u_dp_deinterleave : ENTITY dp_lib.dp_deinterleave_one_to_n + GENERIC MAP( + g_pipeline => 0, + g_nof_outputs => c_sdp_Q_fft + ) + PORT MAP( + rst => rst, + clk => clk, + + snk_in => sp_sosi_arr(I), + src_out_arr(0) => deinterleaved_sosi_arr(2*I), + src_out_arr(1) => deinterleaved_sosi_arr(2*I+1) + ); + END GENERATE; + + p_cnt : PROCESS(rst, clk) + BEGIN + IF rst = '1' THEN + cnt_arr <= (OTHERS => 0); + ELSIF rising_edge(clk) THEN + FOR I IN 0 TO c_sdp_S_pn-1 LOOP + IF deinterleaved_sosi_arr(I).valid = '1' THEN + IF deinterleaved_sosi_arr(I).eop = '1' THEN + cnt_arr(I) <= 0; + ELSE + cnt_arr(I) <= cnt_arr(I) + 1; + END IF; + END IF; + END LOOP; + END IF; + END PROCESS; + + p_select_subband : PROCESS(cnt_arr, deinterleaved_sosi_arr) + BEGIN + subband_sosi_arr <= deinterleaved_sosi_arr; + FOR I IN 0 TO c_sdp_S_pn-1 LOOP + IF cnt_arr(I) /= g_selected_subband THEN + subband_sosi_arr(I).valid <= '0'; + END IF; + END LOOP; + END PROCESS; + + + --------------------------------------------------------------- + -- SIGNAL SCOPE + --------------------------------------------------------------- + u_dp_wideband_sp_arr_scope : ENTITY dp_lib.dp_wideband_sp_arr_scope + GENERIC MAP ( + g_sim => g_sim, + g_use_sclk => FALSE, + g_complex => TRUE, + g_nof_streams => c_sdp_S_pn, + g_wideband_factor => 1, + g_dat_w => c_sdp_W_subband + ) + PORT MAP ( + DCLK => clk, + sp_sosi_arr => subband_sosi_arr, + scope_sosi_arr => scope_sosi_arr + ); + END GENERATE; +END str;