Skip to content
Snippets Groups Projects
Commit 6eb369ae authored by Eric Kooistra's avatar Eric Kooistra
Browse files

Improved logging.

parent add79007
No related branches found
No related tags found
1 merge request!198Clarified reading one WPFB unit into sp_subband_powers_arr2. Updated comments....
......@@ -33,7 +33,7 @@
-- 2) Read current BSN from reg_bsn_scheduler_wg and write reg_bsn_scheduler_wg
-- to trigger start of WG at BSN.
--
-- 3) Read subband statistics (SST) via MM and verify with exp_subband_power at g_subband.
-- 3) Read subband statistics (SST) via MM and verify with exp_subband_sst at g_subband.
-- . use weighted subbands (default selected by MM)
--
-- 4) View in wave window
......@@ -42,14 +42,16 @@
-- - WG amplitude = 8191 (is full scale - 1) when wg_ampl = 1.0
-- . pfb_sosi_arr(c_pfb_index).im/re and fsub_sosi_arr(c_pfb_index).im/re
-- in u_fsub in decimal radix and analog format to check that subband
-- phase is g_subband_phase phase as set by the subband weight.
-- phase is g_subband_weight_phase phase as set by the subband weight.
-- - Raw: pfb_sosi_arr = atan2(-65195 / 0) = -90 degrees
-- - Weighted: fsub_sosi_arr = atan2(-56457 / 32598) = -60 degrees
-- --> rotated expected g_subband_phase = -60 - -90 = +30 degrees.
-- --> rotated expected g_subband_weight_phase = -60 - -90 = +30 degrees.
--
-- Usage:
-- > as 7 # default
-- > as 12 # for detailed debugging
-- add wave -position insertpoint \
-- sim:/tb_lofar2_unb2b_sdp_station_fsub/sp_subband_ssts_arr2
-- > run -a
-- # Takes about 40 m
--
......@@ -71,11 +73,11 @@ USE unb2b_board_lib.unb2b_board_pkg.ALL;
ENTITY tb_lofar2_unb2b_sdp_station_fsub IS
GENERIC (
g_sp : NATURAL := 3; -- signal path index in range(S_pn = 12)
g_wg_ampl : REAL := 1.0; -- WG normalized amplitude
g_subband : NATURAL := 102; -- select subband at index 102 = 102/1024 * 200MHz = 19.921875 MHz
g_subband_gain : REAL := 1.0; -- subband weight normalized gain
g_subband_phase : REAL := 30.0 -- subband weight phase rotation in degrees
g_sp : NATURAL := 3; -- signal path index in range(S_pn = 12)
g_wg_ampl : REAL := 1.0; -- WG normalized amplitude
g_subband : NATURAL := 102; -- select subband at index 102 = 102/1024 * 200MHz = 19.921875 MHz
g_subband_weight_gain : REAL := 1.0; -- subband weight normalized gain
g_subband_weight_phase : REAL := 30.0 -- subband weight phase rotation in degrees
);
END tb_lofar2_unb2b_sdp_station_fsub;
......@@ -97,7 +99,7 @@ ARCHITECTURE tb OF tb_lofar2_unb2b_sdp_station_fsub IS
CONSTANT c_tb_clk_period : TIME := 100 ps; -- use fast tb_clk to speed up M&C
CONSTANT c_nof_block_per_sync : NATURAL := 16;
CONSTANT c_nof_clk_per_sync : NATURAL := c_nof_block_per_sync*c_sdp_N_fft - (c_sdp_N_fft/2); --15.5 block per sync
CONSTANT c_nof_clk_per_sync : NATURAL := c_nof_block_per_sync * c_sdp_N_fft;
CONSTANT c_pps_period : NATURAL := c_nof_clk_per_sync;
CONSTANT c_wpfb_sim : t_wpfb := func_wpfb_set_nof_block_per_sync(c_sdp_wpfb_subbands, c_nof_block_per_sync);
CONSTANT c_stat_data_sz : NATURAL := c_wpfb_sim.stat_data_sz; -- = 2
......@@ -112,7 +114,8 @@ ARCHITECTURE tb OF tb_lofar2_unb2b_sdp_station_fsub IS
CONSTANT c_wg_ampl_full_scale : NATURAL := 2**(c_sdp_W_adc-1); -- full scale (FS) of WG, will just cause clipping of +FS to +FS-1
CONSTANT c_wg_ampl_lsb : REAL := c_diag_wg_ampl_unit / REAL(c_wg_ampl_full_scale); -- amplitude in number of LSbit resolution steps
CONSTANT c_wg_ampl : NATURAL := NATURAL(g_wg_ampl * REAL(c_wg_ampl_full_scale)); -- in number of lsb
CONSTANT c_exp_wg_power_sp : REAL := REAL(c_wg_ampl**2)/2.0 * REAL(c_nof_clk_per_sync);
CONSTANT c_exp_sp_power : REAL := REAL(c_wg_ampl**2) / 2.0;
CONSTANT c_exp_sp_ast : REAL := c_exp_sp_power * REAL(c_nof_clk_per_sync);
-- . phase
CONSTANT c_subband_phase : REAL := 0.0; -- wanted subband phase in degrees = WG phase at sop
CONSTANT c_subband_freq : REAL := REAL(g_subband) / REAL(c_sdp_N_fft); -- normalized by fs = f_adc = 200 MHz is dp_clk
......@@ -126,20 +129,25 @@ ARCHITECTURE tb OF tb_lofar2_unb2b_sdp_station_fsub IS
-- . WPFB
CONSTANT c_pol_index : NATURAL := g_sp MOD c_sdp_Q_fft;
CONSTANT c_pfb_index : NATURAL := g_sp / c_sdp_Q_fft; -- only read used WPFB unit out of range(c_sdp_P_pfb = 6)
CONSTANT c_exp_subband_sp_power_ratio : REAL := 1.0/8.0; -- subband power / SP power, depends on internal WPFB quantization and FIR coefficients
CONSTANT c_exp_subband_power_raw : REAL := c_exp_wg_power_sp * c_exp_subband_sp_power_ratio;
CONSTANT c_exp_subband_power_weighted : REAL := c_exp_subband_power_raw * g_subband_gain**2.0;
-- . expected limit values, obtained with print_str() for g_subband = 102
CONSTANT c_exp_subband_power_leakage_snr_dB : REAL := 75.0; -- < 76.372
CONSTANT c_exp_subband_power_crosstalk_snr_dB : REAL := 95.0; -- < 96.284
CONSTANT c_exp_subband_sp_ampl_ratio : REAL := 7.96; -- ~= 8 for unit FIR DC gain, depends on internal WPFB quantization and FIR coefficients
CONSTANT c_exp_subband_ampl_raw : REAL := REAL(c_wg_ampl) * c_exp_subband_sp_ampl_ratio;
CONSTANT c_exp_subband_ampl_weighted : REAL := c_exp_subband_ampl_raw * g_subband_weight_gain;
CONSTANT c_exp_subband_power_raw : REAL := c_exp_subband_ampl_raw**2.0; -- complex, so no divide by 2
CONSTANT c_exp_subband_power_weighted : REAL := c_exp_subband_ampl_weighted**2.0; -- complex, so no divide by 2
CONSTANT c_exp_subband_sst_raw : REAL := c_exp_subband_power_raw * REAL(c_nof_block_per_sync);
CONSTANT c_exp_subband_sst_weighted : REAL := c_exp_subband_power_weighted * REAL(c_nof_block_per_sync);
-- . expected limit values, obtained with print_str() for g_subband = 102,
-- g_wg_ampl = 1.0, g_subband_weight_gain = 1.0, g_subband_weight_phase = 30.0
CONSTANT c_exp_subband_sst_leakage_snr_dB : REAL := 70.0; -- < 74.913
CONSTANT c_exp_subband_sst_crosstalk_snr_dB : REAL := 90.0; -- < 96.284
TYPE t_real_arr IS ARRAY (INTEGER RANGE <>) OF REAL;
TyPE t_slv_64_subbands_arr IS ARRAY (INTEGER RANGE <>) OF t_slv_64_arr(0 TO c_sdp_N_sub-1);
-- . Subband weights for selected g_sp
CONSTANT c_subband_weight_re : INTEGER := INTEGER(g_subband_gain * REAL(c_sdp_unit_sub_weight) * COS(g_subband_phase * MATH_2_PI / 360.0));
CONSTANT c_subband_weight_im : INTEGER := INTEGER(g_subband_gain * REAL(c_sdp_unit_sub_weight) * SIN(g_subband_phase * MATH_2_PI / 360.0));
CONSTANT c_subband_weight_re : INTEGER := INTEGER(g_subband_weight_gain * REAL(c_sdp_unit_sub_weight) * COS(g_subband_weight_phase * MATH_2_PI / 360.0));
CONSTANT c_subband_weight_im : INTEGER := INTEGER(g_subband_weight_gain * REAL(c_sdp_unit_sub_weight) * SIN(g_subband_weight_phase * MATH_2_PI / 360.0));
-- MM
-- . Address widths of a single MM instance
......@@ -168,15 +176,18 @@ ARCHITECTURE tb OF tb_lofar2_unb2b_sdp_station_fsub IS
-- FSUB
-- . WPFB
SIGNAL sp_subband_powers_arr2 : t_slv_64_subbands_arr(c_sdp_N_pol-1 DOWNTO 0); -- [pol][sub]
SIGNAL sp_subband_power_sum_arr : t_real_arr(c_sdp_N_pol-1 DOWNTO 0) := (OTHERS => 0.0);
SIGNAL sp_subband_power : REAL := 0.0;
SIGNAL sp_subband_power_leakage : REAL := 0.0;
SIGNAL sp_subband_power_leakage_snr_dB : REAL := 0.0; -- signal to noise (leakage) ratio
SIGNAL sp_subband_power_crosstalk : REAL := 0.0;
SIGNAL sp_subband_power_crosstalk_snr_dB : REAL := 0.0; -- signal to noise (crosstalk) ration
SIGNAL exp_subband_power : REAL := 0.0;
SIGNAL sp_subband_ssts_arr2 : t_slv_64_subbands_arr(c_sdp_N_pol-1 DOWNTO 0); -- [pol][sub]
SIGNAL sp_subband_sst_sum_arr : t_real_arr(c_sdp_N_pol-1 DOWNTO 0) := (OTHERS => 0.0);
SIGNAL sp_subband_sst : REAL := 0.0;
SIGNAL sp_subband_sst_leakage : REAL := 0.0;
SIGNAL sp_subband_sst_leakage_snr_dB : REAL := 0.0; -- signal to noise (leakage) ratio
SIGNAL sp_subband_sst_crosstalk : REAL := 0.0;
SIGNAL sp_subband_sst_crosstalk_snr_dB : REAL := 0.0; -- signal to noise (crosstalk) ration
SIGNAL exp_subband_ampl : REAL := 0.0;
SIGNAL exp_subband_power : REAL := 0.0;
SIGNAL exp_subband_sst : REAL := 0.0;
SIGNAL stat_data : STD_LOGIC_VECTOR(c_longword_w-1 DOWNTO 0);
-- . Selector
SIGNAL sst_offload_weighted_subbands : STD_LOGIC;
......@@ -287,7 +298,10 @@ BEGIN
JESD204B_SYNC_N => jesd204b_sync_n
);
-- Raw or weighted subbands
exp_subband_ampl <= sel_a_b(sst_offload_weighted_subbands = '0', c_exp_subband_ampl_raw, c_exp_subband_ampl_weighted);
exp_subband_power <= sel_a_b(sst_offload_weighted_subbands = '0', c_exp_subband_power_raw, c_exp_subband_power_weighted);
exp_subband_sst <= sel_a_b(sst_offload_weighted_subbands = '0', c_exp_subband_sst_raw, c_exp_subband_sst_weighted);
------------------------------------------------------------------------------
-- MM slave accesses via file IO
......@@ -412,38 +426,39 @@ BEGIN
v_data_hi := rd_data;
v_stat_data := v_data_hi & v_data_lo;
sp_subband_powers_arr2(v_P)(v_B) <= v_stat_data;
sp_subband_ssts_arr2(v_P)(v_B) <= v_stat_data;
stat_data <= v_stat_data; -- for time series view in Wave window
-- sum of all subband powers per pol
sp_subband_power_sum_arr(v_P) <= sp_subband_power_sum_arr(v_P) + TO_UREAL(v_stat_data);
sp_subband_sst_sum_arr(v_P) <= sp_subband_sst_sum_arr(v_P) + TO_UREAL(v_stat_data);
END IF;
END LOOP;
-- Subband power of g_subband in g_sp
-- . For the selected g_subband in g_sp the sp_subband_power will be close
-- to sp_subband_power_sum_arr(c_pol_index), because the input is a
-- . For the selected g_subband in g_sp the sp_subband_sst will be close
-- to sp_subband_sst_sum_arr(c_pol_index), because the input is a
-- sinus, so most power will be in 1 subband.
sp_subband_power <= TO_UREAL(sp_subband_powers_arr2(c_pol_index)(g_subband));
sp_subband_sst <= TO_UREAL(sp_subband_ssts_arr2(c_pol_index)(g_subband));
proc_common_wait_some_cycles(tb_clk, 1);
-- The sp_subband_power_leakage shows how much power from the input sinus at a specific
-- The sp_subband_sst_leakage shows how much power from the input sinus at a specific
-- subband has leaked into the N_sub-1 = 511 other subbands. The power ratio yields an
-- indication of the SNR, although that also depends on the SNR of the WG sinus.
v_power := sp_subband_power_sum_arr(c_pol_index) - sp_subband_power;
sp_subband_power_leakage <= v_power;
v_power := sp_subband_sst_sum_arr(c_pol_index) - sp_subband_sst;
sp_subband_sst_leakage <= v_power;
IF v_power > 0.0 THEN
sp_subband_power_leakage_snr_dB <= 10.0 * LOG10(sp_subband_power / v_power);
sp_subband_sst_leakage_snr_dB <= 10.0 * LOG10(sp_subband_sst / v_power);
ELSE
REPORT "Wrong, zero leakage is unexpected for SP-" & NATURAL'IMAGE(g_sp) SEVERITY ERROR;
END IF;
-- The sp_subband_power_crosstalk shows how much power from one WPFB input cross talks
-- The sp_subband_sst_crosstalk shows how much power from one WPFB input cross talks
-- into the other output, due to quantization cross talk in the complex FFT. The power
-- ration indicates the suppression, provided that the other input was zero.
v_power := sp_subband_power_sum_arr(not_int(c_pol_index));
sp_subband_power_crosstalk <= v_power;
v_power := sp_subband_sst_sum_arr(not_int(c_pol_index));
sp_subband_sst_crosstalk <= v_power;
IF v_power > 0.0 THEN
sp_subband_power_crosstalk_snr_dB <= 10.0 * LOG10(sp_subband_power / v_power);
sp_subband_sst_crosstalk_snr_dB <= 10.0 * LOG10(sp_subband_sst / v_power);
ELSE
REPORT "Wrong, zero crosstalk is unexpected for SP-" & NATURAL'IMAGE(g_sp) SEVERITY ERROR;
END IF;
......@@ -451,36 +466,51 @@ BEGIN
proc_common_wait_some_cycles(tb_clk, 1);
---------------------------------------------------------------------------
-- Log subband statistics
-- Log WG, subband statistics
---------------------------------------------------------------------------
-- Log selector
print_str("sst_offload_weighted_subbands = " & sl_to_str(sst_offload_weighted_subbands));
-- Log subband weight
print_str("sp_subband_weight_gain = " & real_to_str(sp_subband_weight_gain, 20, 6));
print_str("sp_subband_weight_phase = " & real_to_str(sp_subband_weight_phase, 20, 6));
-- Log SST
print_str("sp_subband_power = " & real_to_str(sp_subband_power, 20, 0));
print_str("sp_subband_power / exp_subband_power = " & real_to_str(sp_subband_power / exp_subband_power, 20, 0));
print_str("");
print_str("WG:");
print_str(". c_wg_ampl = " & int_to_str(c_wg_ampl));
print_str(". c_exp_sp_power = " & real_to_str(c_exp_sp_power, 20, 1));
print_str(". c_exp_sp_ast = " & real_to_str(c_exp_sp_ast, 20, 1));
print_str("");
print_str("Subband selector:");
print_str(". sst_offload_weighted_subbands = " & sl_to_str(sst_offload_weighted_subbands));
print_str("");
print_str("Subband weight:");
print_str(". sp_subband_weight_gain = " & real_to_str(sp_subband_weight_gain, 20, 6));
print_str(". sp_subband_weight_phase = " & real_to_str(sp_subband_weight_phase, 20, 6));
print_str("");
print_str("SST results:");
print_str(". exp_subband_ampl = " & int_to_str(NATURAL(exp_subband_ampl)));
print_str(". exp_subband_power = " & real_to_str(exp_subband_power, 20, 1));
print_str(". exp_subband_sst = " & real_to_str(exp_subband_sst, 20, 1));
print_str("");
print_str(". sp_subband_sst = " & real_to_str(sp_subband_sst, 20, 1));
print_str(". sp_subband_sst / exp_subband_sst = " & real_to_str(sp_subband_sst / exp_subband_sst, 20, 6));
-- Log WPFB details, these are allready verified in tb of wpfb_unit_dev.vhd, so here
-- quality indicators like leakage and crosstalk are also reported out of interest.
print_str("sp_subband_power_leakage = " & real_to_str(sp_subband_power_leakage, 20, 0));
print_str("sp_subband_power_leakage_snr_dB = " & real_to_str(sp_subband_power_leakage_snr_dB, 20, 3));
print_str("sp_subband_power_crosstalk = " & real_to_str(sp_subband_power_crosstalk, 20, 0));
print_str("sp_subband_power_crosstalk_snr_db = " & real_to_str(sp_subband_power_crosstalk_snr_db, 20, 3));
print_str("");
print_str("SST quality indicators");
print_str(". sp_subband_sst_leakage = " & real_to_str(sp_subband_sst_leakage, 20, 0));
print_str(". sp_subband_sst_leakage_snr_dB = " & real_to_str(sp_subband_sst_leakage_snr_dB, 20, 3));
print_str(". sp_subband_sst_crosstalk = " & real_to_str(sp_subband_sst_crosstalk, 20, 0));
print_str(". sp_subband_sst_crosstalk_snr_db = " & real_to_str(sp_subband_sst_crosstalk_snr_db, 20, 3));
---------------------------------------------------------------------------
-- Verify subband statistics
---------------------------------------------------------------------------
-- Verify SST
---------------------------------------------------------------------------
-- verify expected subband power based on WG power
ASSERT sp_subband_power > c_lo_factor * exp_subband_power REPORT "Wrong subband power for SP " & NATURAL'IMAGE(g_sp) SEVERITY ERROR;
ASSERT sp_subband_power < c_hi_factor * exp_subband_power REPORT "Wrong subband power for SP " & NATURAL'IMAGE(g_sp) SEVERITY ERROR;
ASSERT sp_subband_sst > c_lo_factor * exp_subband_sst REPORT "Wrong subband power for SP " & NATURAL'IMAGE(g_sp) SEVERITY ERROR;
ASSERT sp_subband_sst < c_hi_factor * exp_subband_sst REPORT "Wrong subband power for SP " & NATURAL'IMAGE(g_sp) SEVERITY ERROR;
-- Verify expected SNR quality measures
ASSERT sp_subband_power_leakage_snr_dB > c_exp_subband_power_leakage_snr_dB REPORT "Wrong to much leakage for SP " & NATURAL'IMAGE(g_sp) SEVERITY ERROR;
ASSERT sp_subband_power_crosstalk_snr_dB > c_exp_subband_power_crosstalk_snr_dB REPORT "Wrong to much crosstalk for SP " & NATURAL'IMAGE(g_sp) SEVERITY ERROR;
ASSERT sp_subband_sst_leakage_snr_dB > c_exp_subband_sst_leakage_snr_dB REPORT "Wrong to much leakage for SP " & NATURAL'IMAGE(g_sp) SEVERITY ERROR;
ASSERT sp_subband_sst_crosstalk_snr_dB > c_exp_subband_sst_crosstalk_snr_dB REPORT "Wrong to much crosstalk for SP " & NATURAL'IMAGE(g_sp) SEVERITY ERROR;
---------------------------------------------------------------------------
-- End Simulation
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment