diff --git a/applications/lofar2/libraries/sdp/hdllib.cfg b/applications/lofar2/libraries/sdp/hdllib.cfg index fde47b5a6693f416929357bc89a3eb18bc5b2ee5..a1e0d5853c6bc74858f1a4f75a4a722b02a275d0 100644 --- a/applications/lofar2/libraries/sdp/hdllib.cfg +++ b/applications/lofar2/libraries/sdp/hdllib.cfg @@ -8,6 +8,7 @@ synth_files = src/vhdl/sdp_pkg.vhd src/vhdl/sdp_scope.vhd src/vhdl/sdp_subband_equalizer.vhd + src/vhdl/sdp_bf_weights.vhd src/vhdl/node_sdp_adc_input_and_timing.vhd src/vhdl/node_sdp_filterbank.vhd test_bench_files = diff --git a/applications/lofar2/libraries/sdp/src/vhdl/sdp_bf_weights.vhd b/applications/lofar2/libraries/sdp/src/vhdl/sdp_bf_weights.vhd new file mode 100644 index 0000000000000000000000000000000000000000..b45c93678ca17a5051418c5736b7ba2586592a4f --- /dev/null +++ b/applications/lofar2/libraries/sdp/src/vhdl/sdp_bf_weights.vhd @@ -0,0 +1,140 @@ +------------------------------------------------------------------------------- +-- +-- 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 sdp_bf_weights in the beamformer (BF) of +-- the LOFAR2 SDPFW design. +-- Description: +-- The sdp_bf_weights.vhd consists of mms_dp_gain_serial_arr.vhd and +-- some address counter logic to select the address of the subband weight. +-- Remark: +-- . sdp_bf_weights.vhd is similar to sdp_subband_equalizer.vhd. The +-- difference is that they have a different purpose and that the +-- sdp_subband_equalizer requantizes the output. +------------------------------------------------------------------------------- + +LIBRARY IEEE, common_lib, dp_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 work.sdp_pkg.ALL; + +ENTITY sdp_bf_weights IS + GENERIC ( + g_gains_file_name : STRING := "UNUSED" + ); + PORT ( + dp_clk : IN STD_LOGIC; + dp_rst : IN STD_LOGIC; + + in_sosi_arr : IN t_dp_sosi_arr(c_sdp_N_pol * c_sdp_P_pfb-1 DOWNTO 0); + out_sosi_arr : OUT t_dp_sosi_arr(c_sdp_N_pol * c_sdp_P_pfb-1 DOWNTO 0); + + mm_rst : IN STD_LOGIC; + mm_clk : IN STD_LOGIC; + + ram_gains_mosi : IN t_mem_mosi := c_mem_mosi_rst; + ram_gains_miso : OUT t_mem_miso + ); +END sdp_bf_weights; + +ARCHITECTURE str OF sdp_bf_weights IS + + CONSTANT c_gain_addr_w : NATURAL := ceil_log2(c_sdp_Q_fft * c_sdp_S_sub_bf); + CONSTANT c_gain_out_dat_w : NATURAL := c_sdp_W_bf_weight + c_sdp_W_subband -1; + + SIGNAL cnt : NATURAL RANGE 0 TO c_sdp_Q_fft * c_sdp_S_sub_bf-1; + SIGNAL gains_rd_address : STD_LOGIC_VECTOR(c_gain_addr_w-1 DOWNTO 0); + SIGNAL dp_gain_serial_out_sosi_arr : t_dp_sosi_arr(c_sdp_P_pfb-1 DOWNTO 0); + +BEGIN + --------------------------------------------------------------- + -- Counter + --------------------------------------------------------------- + -- The BF weigths per PN are stored as + -- (cint16)subband_weights[N_pol][S_pn/Q_fft]_[Q_fft][S_sub_bf], but have + -- to be applied according the subband data order + -- [N_pol][S_pn/Q_fft]_[S_sub_bf][Q_fft]. Therefore this counter + -- has to account for this difference in order. + p_cnt : PROCESS(dp_clk, dp_rst) + VARIABLE v_Q_fft, v_S_sub_bf : NATURAL; + BEGIN + IF dp_rst = '1' THEN + cnt <= 0; + v_Q_fft := 0; + v_S_sub_bf := 0; + ELSIF rising_edge(dp_clk) THEN + IF in_sosi_arr(0).eop = '1' THEN + v_Q_fft := 0; + v_S_sub_bf := 0; + ELSE + IF v_Q_fft >= c_sdp_Q_fft-1 THEN + v_Q_fft := 0; + IF v_S_sub_bf >= c_sdp_S_sub_bf-1 THEN + v_S_sub_bf := 0; + ELSE + v_S_sub_bf := v_S_sub_bf + 1; + END IF; + ELSE + v_Q_fft := v_Q_fft + 1; + END IF; + END IF; + cnt <= v_Q_fft * c_sdp_S_sub_bf + v_S_sub_bf; + END IF; + END PROCESS; + gains_rd_address <= TO_UVEC(cnt, c_gain_addr_w); + + --------------------------------------------------------------- + -- Gain + --------------------------------------------------------------- + u_mms_dp_gain_serial_arr : ENTITY dp_lib.mms_dp_gain_serial_arr + GENERIC MAP ( + g_nof_streams => c_sdp_N_pol * c_sdp_P_pfb, + g_nof_gains => c_sdp_Q_fft * c_sdp_S_sub_bf, + g_complex_data => TRUE, + g_complex_gain => TRUE, + g_gain_w => c_sdp_W_bf_weight, + g_in_dat_w => c_sdp_W_subband, + g_out_dat_w => c_gain_out_dat_w, + g_gains_file_name => g_gains_file_name + ) + PORT MAP ( + -- System + mm_rst => mm_rst, + mm_clk => mm_clk, + dp_rst => dp_rst, + dp_clk => dp_clk, + + -- MM interface + ram_gains_mosi => ram_gains_mosi, + ram_gains_miso => ram_gains_miso, + + -- ST interface + gains_rd_address => gains_rd_address, + + in_sosi_arr => in_sosi_arr, + out_sosi_arr => out_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 index 655269d069cf4a442f935799e46a9f5e3c92a671..f24c7902a16ff4efb86082da850975d5baf827c7 100644 --- a/applications/lofar2/libraries/sdp/src/vhdl/sdp_pkg.vhd +++ b/applications/lofar2/libraries/sdp/src/vhdl/sdp_pkg.vhd @@ -40,6 +40,7 @@ PACKAGE sdp_pkg is -- SDP specific parameters as defined in: -- L3 SDP Decision: SDP Parameter definitions ------------------------------------------------- + CONSTANT c_sdp_N_pol : NATURAL := 2; CONSTANT c_sdp_N_sub : NATURAL := 512; CONSTANT c_sdp_N_fft : NATURAL := 1024; CONSTANT c_sdp_S_pn : NATURAL := 12; @@ -49,12 +50,16 @@ PACKAGE sdp_pkg is 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; + CONSTANT c_sdp_S_sub_bf : NATURAL := 488; CONSTANT c_sdp_f_adc_MHz : NATURAL := 200; CONSTANT c_sdp_T_adc : TIME := (10**6/c_sdp_f_adc_MHz) * 1 ps; CONSTANT c_sdp_T_sub : TIME := c_sdp_N_fft * c_sdp_T_adc; CONSTANT c_sdp_W_sub_weight : NATURAL := 16; CONSTANT c_sdp_W_sub_magnitude : NATURAL := 2; CONSTANT c_sdp_W_sub_fraction : NATURAL := c_sdp_W_sub_weight - c_sdp_W_sub_magnitude -1; + CONSTANT c_sdp_W_bf_weight : NATURAL := 16; + CONSTANT c_sdp_W_bf_magnitude : NATURAL := 1; + CONSTANT c_sdp_W_bf_fraction : NATURAL := c_sdp_W_bf_weight - c_sdp_W_bf_magnitude -1; CONSTANT c_sdp_ait_buf_nof_data_jesd : NATURAL := 1024; -- 1024 14 bit samples fit in one M20k BRAM CONSTANT c_sdp_ait_buf_nof_data_bsn : NATURAL := 1024; -- 1024 14 bit samples fit in one M20k BRAM