diff --git a/applications/lofar2/libraries/sdp/hdllib.cfg b/applications/lofar2/libraries/sdp/hdllib.cfg new file mode 100644 index 0000000000000000000000000000000000000000..bb9487754ada43e78e013659a77aace61681ab4c --- /dev/null +++ b/applications/lofar2/libraries/sdp/hdllib.cfg @@ -0,0 +1,21 @@ +hdl_lib_name = lofar2_sdp +hdl_library_clause_name = lofar2_sdp_lib +hdl_lib_uses_synth = common dp wpfb rTwoSDF filter si st +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 = + +regression_test_vhdl = + + +[modelsim_project_file] + + +[quartus_project_file] + diff --git a/applications/lofar2/libraries/sdp/src/vhdl/node_sdp_filterbank.vhd b/applications/lofar2/libraries/sdp/src/vhdl/node_sdp_filterbank.vhd new file mode 100644 index 0000000000000000000000000000000000000000..0ca713bb2c374871edd6654c8eb6de3926c2ea0c --- /dev/null +++ b/applications/lofar2/libraries/sdp/src/vhdl/node_sdp_filterbank.vhd @@ -0,0 +1,201 @@ +------------------------------------------------------------------------------- +-- +-- 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: +-- . Implements the functionality of the subband filterbank (Fsub) in the +-- LOFAR2 SDPFW design. +-- Description: +-- . The subband filterbank seperates the incoming timestamped ADC samples into +-- 512 frequency bands called subbands. +-- . It implements a critically sampled poly-phase filterbank (PFB). The PFB consists of a +-- poly-phase finite impulse response (PFIR) filter per real input and a +-- complex fast fourier transform (FFT) per 2 real inputs. +-- . The number of points of the FFT is 1024. +-- Remark: +-- . +------------------------------------------------------------------------------- + +LIBRARY IEEE, common_lib, dp_lib, rTwoSDF_lib, wpfb_lib, filter_lib, si_lib, st_lib; +USE IEEE.STD_LOGIC_1164.ALL; +USE common_lib.common_pkg.ALL; +USE common_lib.common_mem_pkg.ALL; +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_scope_selected_subband : NATURAL := 0 + ); + PORT ( + dp_clk : IN STD_LOGIC; + dp_rst : IN STD_LOGIC; + + 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; + + reg_si_mosi : IN t_mem_mosi := c_mem_mosi_rst; + reg_si_miso : OUT t_mem_miso; + ram_st_sst_mosi : IN t_mem_mosi := c_mem_mosi_rst; + ram_st_sst_miso : OUT t_mem_miso; + ram_fil_coefs_mosi : IN t_mem_mosi := c_mem_mosi_rst; + ram_fil_coefs_miso : OUT t_mem_miso + ); +END node_sdp_filterbank; + +ARCHITECTURE str OF node_sdp_filterbank IS + + CONSTANT c_coefs_file_prefix : STRING := "UNUSED"; --"data/coefs_wide"; + + 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(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 + --------------------------------------------------------------- + -- SPECTRAL INVERSION + --------------------------------------------------------------- + u_si_arr : ENTITY si_lib.si_arr + GENERIC MAP ( + g_nof_streams => c_sdp_S_pn, + g_pipeline => 1, + g_dat_w => c_sdp_W_adc + ) + PORT MAP( + in_sosi_arr => in_sosi_arr, + out_sosi_arr => si_sosi_arr, + + reg_si_mosi => reg_si_mosi, + reg_si_miso => reg_si_miso, + + mm_rst => mm_rst, + mm_clk => mm_clk, + dp_clk => dp_clk, + dp_rst => dp_rst + ); + + --------------------------------------------------------------- + -- POLY-PHASE FILTERBANK + --------------------------------------------------------------- + -- 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_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); + END LOOP; + END PROCESS; + + -- PFB + u_wpfb_unit_dev : ENTITY wpfb_lib.wpfb_unit_dev + GENERIC MAP ( + g_wpfb => c_sdp_wpfb_subbands, + g_use_prefilter => TRUE, + g_stats_ena => FALSE, + g_use_bg => FALSE, + g_coefs_file_prefix => c_coefs_file_prefix + ) + PORT MAP ( + dp_rst => dp_rst, + dp_clk => dp_clk, + mm_rst => mm_rst, + mm_clk => mm_clk, + + ram_fil_coefs_mosi => ram_fil_coefs_mosi, + ram_fil_coefs_miso => ram_fil_coefs_miso, + + in_sosi_arr => wpfb_unit_in_sosi_arr, + fil_sosi_arr => wpfb_unit_fil_sosi_arr, + out_sosi_arr => wpfb_unit_out_sosi_arr + ); + + -- Output PFB streams + pfb_sosi_arr <= wpfb_unit_out_sosi_arr; + + --------------------------------------------------------------- + -- SUBBAND STATISTICS + --------------------------------------------------------------- + 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_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, + mm_clk => mm_clk, + dp_rst => dp_rst, + dp_clk => dp_clk, + in_complex => wpfb_unit_out_sosi_arr(I), + ram_st_sst_mosi => ram_st_sst_mosi_arr(I), + ram_st_sst_miso => ram_st_sst_miso_arr(I) + ); + END GENERATE; + + --------------------------------------------------------------- + -- COMBINE MEMORY MAPPED INTERFACES + --------------------------------------------------------------- + -- Combine the internal array of mm interfaces for the subband + -- statistics to one array. + u_mem_mux_sst : ENTITY common_lib.common_mem_mux + GENERIC MAP ( + g_nof_mosi => c_sdp_P_pfb, + g_mult_addr_w => ceil_log2(c_sdp_N_sub*c_sdp_Q_fft*c_sdp_wpfb_subbands.stat_data_sz) + ) + PORT MAP ( + mosi => ram_st_sst_mosi, + miso => ram_st_sst_miso, + mosi_arr => ram_st_sst_mosi_arr, + miso_arr => ram_st_sst_miso_arr + ); + + --------------------------------------------------------------- + -- SIGNAL SCOPE + --------------------------------------------------------------- + u_sdp_scope : ENTITY work.sdp_scope + GENERIC MAP ( + g_sim => g_sim, + g_selected_subband => g_scope_selected_subband + ) + PORT MAP ( + clk => dp_clk, + rst => dp_rst, + sp_sosi_arr => wpfb_unit_out_sosi_arr, + scope_sosi_arr => scope_sosi_arr + ); + +END str; 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..2b5882b9c72f7be1633db46206cdf1ce416212f9 --- /dev/null +++ b/applications/lofar2/libraries/sdp/src/vhdl/sdp_pkg.vhd @@ -0,0 +1,69 @@ +------------------------------------------------------------------------------- +-- +-- 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_sub : NATURAL := 512; + 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..ace7425094185772a6addeb3769c373a061eff09 --- /dev/null +++ b/applications/lofar2/libraries/sdp/src/vhdl/sdp_scope.vhd @@ -0,0 +1,120 @@ +------------------------------------------------------------------------------- +-- +-- 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 for P_pfb complex streams + sp_sosi_arr : IN t_dp_sosi_arr(c_sdp_P_pfb-1 DOWNTO 0); + + -- Scope output for S_pn 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 : NATURAL; + 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 <= 0; + ELSIF rising_edge(clk) THEN + IF deinterleaved_sosi_arr(0).valid = '1' THEN + IF deinterleaved_sosi_arr(0).eop = '1' THEN + cnt <= 0; + ELSE + cnt <= cnt + 1; + END IF; + END IF; + END IF; + END PROCESS; + + -- Select subband + subband_sosi_arr <= deinterleaved_sosi_arr WHEN cnt = g_selected_subband; + + --------------------------------------------------------------- + -- 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; diff --git a/libraries/dsp/wpfb/src/vhdl/wpfb_unit_dev.vhd b/libraries/dsp/wpfb/src/vhdl/wpfb_unit_dev.vhd index 4654f302ed22f40cc0a64d73d9037e5b2dc2af7c..8ce1683177a1d182ac838b7688556aefcd3723ff 100644 --- a/libraries/dsp/wpfb/src/vhdl/wpfb_unit_dev.vhd +++ b/libraries/dsp/wpfb/src/vhdl/wpfb_unit_dev.vhd @@ -371,13 +371,13 @@ entity wpfb_unit_dev is dp_clk : in std_logic; mm_rst : in std_logic; mm_clk : in std_logic; - ram_fil_coefs_mosi : in t_mem_mosi; - ram_fil_coefs_miso : out t_mem_miso := c_mem_miso_rst; - ram_st_sst_mosi : in t_mem_mosi; -- Subband statistics registers - ram_st_sst_miso : out t_mem_miso := c_mem_miso_rst; - reg_bg_ctrl_mosi : in t_mem_mosi; + ram_fil_coefs_mosi : in t_mem_mosi := c_mem_mosi_rst; + ram_fil_coefs_miso : out t_mem_miso; + ram_st_sst_mosi : in t_mem_mosi := c_mem_mosi_rst; -- Subband statistics registers + ram_st_sst_miso : out t_mem_miso; + reg_bg_ctrl_mosi : in t_mem_mosi := c_mem_mosi_rst; reg_bg_ctrl_miso : out t_mem_miso; - ram_bg_data_mosi : in t_mem_mosi; + ram_bg_data_mosi : in t_mem_mosi := c_mem_mosi_rst; ram_bg_data_miso : out t_mem_miso; in_sosi_arr : in t_dp_sosi_arr(g_wpfb.nof_wb_streams*g_wpfb.wb_factor-1 downto 0); fil_sosi_arr : out t_dp_sosi_arr(g_wpfb.nof_wb_streams*g_wpfb.wb_factor-1 downto 0);