diff --git a/libraries/base/diag/tb/vhdl/tb_diag_pkg.vhd b/libraries/base/diag/tb/vhdl/tb_diag_pkg.vhd index 11f7d9339f33f213db43c747f32fab7f79f61359..715f1aed9445436ae06116c7bf2520068d03015e 100644 --- a/libraries/base/diag/tb/vhdl/tb_diag_pkg.vhd +++ b/libraries/base/diag/tb/vhdl/tb_diag_pkg.vhd @@ -118,8 +118,12 @@ PACKAGE tb_diag_pkg IS SIGNAL in_dat : IN STD_LOGIC_VECTOR; SIGNAL in_start : IN STD_LOGIC; -- start of interval, e.g. sop or sync SIGNAL in_val : IN STD_LOGIC; + SIGNAL track_max : INOUT REAL; -- store local tracker in signal + SIGNAL track_min : INOUT REAL; -- store local tracker in signal SIGNAL accum_mean : INOUT REAL; -- store local accumulator in signal SIGNAL accum_power : INOUT REAL; -- store local accumulator in signal + SIGNAL measured_max : OUT REAL; -- maximum sample value + SIGNAL measured_min : OUT REAL; -- minimum sample value SIGNAL measured_mean : OUT REAL; -- average sample value (DC) SIGNAL measured_power : OUT REAL; -- average sample power SIGNAL measured_ampl : OUT REAL); -- corresponding sine amplitude @@ -462,8 +466,12 @@ PACKAGE BODY tb_diag_pkg IS SIGNAL in_dat : IN STD_LOGIC_VECTOR; SIGNAL in_start : IN STD_LOGIC; -- start of interval, e.g. sop or sync SIGNAL in_val : IN STD_LOGIC; + SIGNAL track_max : INOUT REAL; -- store local tracker in signal + SIGNAL track_min : INOUT REAL; -- store local tracker in signal SIGNAL accum_mean : INOUT REAL; -- store local accumulator in signal SIGNAL accum_power : INOUT REAL; -- store local accumulator in signal + SIGNAL measured_max : OUT REAL; -- maximum sample value + SIGNAL measured_min : OUT REAL; -- minimum sample value SIGNAL measured_mean : OUT REAL; -- average sample value (DC) SIGNAL measured_power : OUT REAL; -- average sample power SIGNAL measured_ampl : OUT REAL) IS -- corresponding sine amplitude @@ -475,14 +483,20 @@ PACKAGE BODY tb_diag_pkg IS BEGIN IF rising_edge(dp_clk) THEN IF in_start='1' THEN - -- Hold last interval accumulation + -- Hold last interval max, min and accumulation + measured_max <= track_max; + measured_min <= track_min; measured_power <= c_power; measured_ampl <= c_ampl; -- Start new interval accumulation + track_max <= REAL'LOW; + track_min <= REAL'HIGH; accum_mean <= c_dat; accum_power <= (ABS(c_dat))**2.0; -- Must use ABS() with ** of real, because (negative)**2.0 yields error and value 0.0, also must use brackets (ABS()) to avoid compile error ELSIF in_val='1' THEN - -- Accumulate during interval + -- Detect and accumulate during interval + track_max <= largest(track_max, c_dat); + track_min <= smallest(track_min, c_dat); accum_mean <= accum_mean + c_dat; accum_power <= accum_power + (ABS(c_dat))**2.0; END IF; diff --git a/libraries/dsp/wpfb/tb/vhdl/tb_wpfb_unit_dev_wg.vhd b/libraries/dsp/wpfb/tb/vhdl/tb_wpfb_unit_dev_wg.vhd index b780f16e3e9c143e2724f24d76b2b83d49bd489b..37e347a735953aa67a3f79c59f48ce8f46ca91e6 100644 --- a/libraries/dsp/wpfb/tb/vhdl/tb_wpfb_unit_dev_wg.vhd +++ b/libraries/dsp/wpfb/tb/vhdl/tb_wpfb_unit_dev_wg.vhd @@ -91,9 +91,9 @@ ENTITY tb_wpfb_unit_dev_wg IS GENERIC ( g_tb_index : NATURAL := 0; -- use g_tb_index to identify and separate print_str() loggings from multi tb -- WG - g_subband_index_a : REAL := 61.0; -- 0:511 + g_subband_index_a : REAL := 61.5; -- 0:511 g_subband_index_b : REAL := 61.0; -- 0:511 - g_amplitude_a : REAL := 1.0; -- 1.0 is full scale + g_amplitude_a : REAL := 0.9; -- 1.0 is full scale g_amplitude_b : REAL := 0.0; -- 1.0 is full scale g_phase_a : REAL := 0.0; -- 0:360 degrees g_phase_b : REAL := 0.0; -- 0:360 degrees @@ -284,14 +284,22 @@ ARCHITECTURE tb OF tb_wpfb_unit_dev_wg IS -- Input power measurement -- . signal input A + SIGNAL input_track_max_a : REAL := 0.0; -- track sample max + SIGNAL input_track_min_a : REAL := 0.0; -- track sample min SIGNAL input_accum_mean_a : REAL := 0.0; -- accumulate sample mean (DC) SIGNAL input_accum_power_a : REAL := 0.0; -- accumulate sample power + SIGNAL input_max_a : REAL := 0.0; -- measured sample max + SIGNAL input_min_a : REAL := 0.0; -- measured sample min SIGNAL input_mean_a : REAL := 0.0; -- measured average input sample mean (DC) based on AST SIGNAL input_power_a : REAL := 0.0; -- measured average input sample power based on AST SIGNAL input_ampl_a : REAL := 0.0; -- measured input amplitude based on AST -- . signal input B + SIGNAL input_track_max_b : REAL := 0.0; -- track sample max + SIGNAL input_track_min_b : REAL := 0.0; -- track sample min SIGNAL input_accum_mean_b : REAL := 0.0; -- accumulate sample mean (DC) SIGNAL input_accum_power_b : REAL := 0.0; -- accumulate sample power + SIGNAL input_max_b : REAL := 0.0; -- measured sample max + SIGNAL input_min_b : REAL := 0.0; -- measured sample min SIGNAL input_mean_b : REAL := 0.0; -- measured average input sample mean (DC) based on AST SIGNAL input_power_b : REAL := 0.0; -- measured average input sample power based on AST SIGNAL input_ampl_b : REAL := 0.0; -- measured input amplitude based on AST @@ -331,14 +339,22 @@ ARCHITECTURE tb OF tb_wpfb_unit_dev_wg IS -- FIR filter output power measurement -- . signal input A + SIGNAL fir_track_max_a : REAL := 0.0; -- track sample max + SIGNAL fir_track_min_a : REAL := 0.0; -- track sample min SIGNAL fir_accum_mean_a : REAL := 0.0; -- accumulate sample mean (DC) SIGNAL fir_accum_power_a : REAL := 0.0; -- accumulate sample power + SIGNAL fir_max_a : REAL := 0.0; -- measured sample max + SIGNAL fir_min_a : REAL := 0.0; -- measured sample min SIGNAL fir_mean_a : REAL := 0.0; -- measured average input sample mean (DC) based on AST SIGNAL fir_power_a : REAL := 0.0; -- measured average input sample power based on AST SIGNAL fir_ampl_a : REAL := 0.0; -- measured input amplitude based on AST -- . signal input B + SIGNAL fir_track_max_b : REAL := 0.0; -- track sample max + SIGNAL fir_track_min_b : REAL := 0.0; -- track sample min SIGNAL fir_accum_mean_b : REAL := 0.0; -- accumulate sample mean (DC) SIGNAL fir_accum_power_b : REAL := 0.0; -- accumulate sample power + SIGNAL fir_max_b : REAL := 0.0; -- measured sample max + SIGNAL fir_min_b : REAL := 0.0; -- measured sample min SIGNAL fir_mean_b : REAL := 0.0; -- measured average input sample mean (DC) based on AST SIGNAL fir_power_b : REAL := 0.0; -- measured average input sample power based on AST SIGNAL fir_ampl_b : REAL := 0.0; -- measured input amplitude based on AST @@ -690,8 +706,8 @@ BEGIN --------------------------------------------------------------------------- -- Measure ADC/WG input mean (DC) and power, and determine sine amplitude --------------------------------------------------------------------------- - proc_diag_measure_cw_statistics(c_N_samples, dp_clk, in_sosi.re, in_sosi.sync, in_sosi.valid, input_accum_mean_a, input_accum_power_a, input_mean_a, input_power_a, input_ampl_a); - proc_diag_measure_cw_statistics(c_N_samples, dp_clk, in_sosi.im, in_sosi.sync, in_sosi.valid, input_accum_mean_b, input_accum_power_b, input_mean_b, input_power_b, input_ampl_b); + proc_diag_measure_cw_statistics(c_N_samples, dp_clk, in_sosi.re, in_sosi.sync, in_sosi.valid, input_track_max_a, input_track_min_a, input_accum_mean_a, input_accum_power_a, input_max_a, input_min_a, input_mean_a, input_power_a, input_ampl_a); + proc_diag_measure_cw_statistics(c_N_samples, dp_clk, in_sosi.im, in_sosi.sync, in_sosi.valid, input_track_max_b, input_track_min_b, input_accum_mean_b, input_accum_power_b, input_max_b, input_min_b, input_mean_b, input_power_b, input_ampl_b); --------------------------------------------------------------------------- -- Measure WG amplitude and phase using local I = sin and Q = cos @@ -713,8 +729,8 @@ BEGIN --------------------------------------------------------------------------- -- Measure FIR filter output mean (DC) and power, and determine sine amplitude --------------------------------------------------------------------------- - proc_diag_measure_cw_statistics(c_N_samples, dp_clk, fil_sosi.re, fil_sosi.sync, fil_sosi.valid, fir_accum_mean_a, fir_accum_power_a, fir_mean_a, fir_power_a, fir_ampl_a); -- use fir_ to distinguish from similar fil_ signal - proc_diag_measure_cw_statistics(c_N_samples, dp_clk, fil_sosi.im, fil_sosi.sync, fil_sosi.valid, fir_accum_mean_b, fir_accum_power_b, fir_mean_b, fir_power_b, fir_ampl_b); -- use fir_ to distinguish from similar fil_ signal + proc_diag_measure_cw_statistics(c_N_samples, dp_clk, fil_sosi.re, fil_sosi.sync, fil_sosi.valid, fir_track_max_a, fir_track_min_a, fir_accum_mean_a, fir_accum_power_a, fir_max_a, fir_min_a, fir_mean_a, fir_power_a, fir_ampl_a); -- use fir_ to distinguish from similar fil_ signal + proc_diag_measure_cw_statistics(c_N_samples, dp_clk, fil_sosi.im, fil_sosi.sync, fil_sosi.valid, fir_track_max_b, fir_track_min_b, fir_accum_mean_b, fir_accum_power_b, fir_max_b, fir_min_b, fir_mean_b, fir_power_b, fir_ampl_b); -- use fir_ to distinguish from similar fil_ signal --------------------------------------------------------------------------- -- Measure FIR filter output amplitude and phase using local I = sin and Q = cos @@ -862,16 +878,20 @@ BEGIN print_str(". g_amplitude_a = " & real_to_str(g_amplitude_a, 5, 3)); print_str(". g_phase_a = " & real_to_str(g_phase_a, 6, 1) & " degrees"); print_str(""); - print_str("DC levels"); + print_str("DC, min, max levels"); + print_str(". input_min_a = " & real_to_str(input_min_a, 10, 3)); + print_str(". input_max_a = " & real_to_str(input_max_a, 10, 3)); print_str(". input_mean_a = " & real_to_str(input_mean_a, 10, 3)); + print_str(". fir_min_a = " & real_to_str(fir_min_a, 10, 3)); + print_str(". fir_max_a = " & real_to_str(fir_max_a, 10, 3)); print_str(". fir_mean_a = " & real_to_str(fir_mean_a, 10, 3)); print_str(""); print_str("Amplitudes:"); print_str(". c_wg_ampl_a = " & int_to_str(NATURAL(c_wg_ampl_a))); print_str(". input_ampl_a = " & real_to_str(input_ampl_a, 10, 3)); print_str(". cw_ampl_a = " & real_to_str(cw_ampl_a, 10, 3)); - print_str(". fir_ampl_a = " & real_to_str(fir_ampl_a, 10, 3)); IF NOT c_bin_a_frac_en THEN + print_str(". fir_ampl_a = " & real_to_str(fir_ampl_a, 10, 3)); print_str(". fil_ampl_a = " & real_to_str(fil_ampl_a, 10, 3)); END IF; print_str(". sub_a_re = " & int_to_str(sub_a_re)); @@ -887,7 +907,9 @@ BEGIN print_str("SNR and WPFB processing gain:"); print_str(". c_wg_snr_a_dB = " & real_to_str(c_wg_snr_a_dB, 7, 2) & " [dB]"); print_str(". wg_measured_snr_a_dB = " & real_to_str(wg_measured_snr_a_dB, 7, 2) & " [dB]"); - print_str(". fil_measured_snr_a_dB = " & real_to_str(fil_measured_snr_a_dB, 7, 2) & " [dB]"); + IF NOT c_bin_a_frac_en THEN + print_str(". fil_measured_snr_a_dB = " & real_to_str(fil_measured_snr_a_dB, 7, 2) & " [dB]"); + END IF; print_str(". sst_measured_snr_a_dB = " & real_to_str(sst_measured_snr_a_dB, 7, 2) & " [dB]"); print_str(". wpfb_measured_proc_gain_a_dB = " & real_to_str(wpfb_measured_proc_gain_a_dB, 7, 2) & " [dB]"); print_str(""); @@ -897,16 +919,20 @@ BEGIN print_str(". g_amplitude_b = " & real_to_str(g_amplitude_b, 5, 3)); print_str(". g_phase_b = " & real_to_str(g_phase_b, 6, 1) & " degrees"); print_str(""); - print_str("DC levels"); + print_str("DC, min, max levels"); + print_str(". input_min_b = " & real_to_str(input_min_b, 10, 3)); + print_str(". input_max_b = " & real_to_str(input_max_b, 10, 3)); print_str(". input_mean_b = " & real_to_str(input_mean_b, 10, 3)); + print_str(". fir_min_b = " & real_to_str(fir_min_b, 10, 3)); + print_str(". fir_max_b = " & real_to_str(fir_max_b, 10, 3)); print_str(". fir_mean_b = " & real_to_str(fir_mean_b, 10, 3)); print_str(""); print_str("Amplitudes:"); print_str(". c_wg_ampl_b = " & int_to_str(NATURAL(c_wg_ampl_b))); print_str(". input_ampl_b = " & real_to_str(input_ampl_b, 10, 3)); print_str(". cw_ampl_b = " & real_to_str(cw_ampl_b, 10, 3)); - print_str(". fir_ampl_b = " & real_to_str(fir_ampl_b, 10, 3)); IF NOT c_bin_b_frac_en THEN + print_str(". fir_ampl_b = " & real_to_str(fir_ampl_b, 10, 3)); print_str(". fil_ampl_b = " & real_to_str(fil_ampl_b, 10, 3)); END IF; print_str(". sub_b_re = " & int_to_str(sub_b_re)); @@ -922,7 +948,9 @@ BEGIN print_str("SNR and WPFB processing gain:"); print_str(". c_wg_snr_b_dB = " & real_to_str(c_wg_snr_b_dB, 7, 2) & " [dB]"); print_str(". wg_measured_snr_b_dB = " & real_to_str(wg_measured_snr_b_dB, 7, 2) & " [dB]"); - print_str(". fil_measured_snr_b_dB = " & real_to_str(fil_measured_snr_b_dB, 7, 2) & " [dB]"); + IF NOT c_bin_b_frac_en THEN + print_str(". fil_measured_snr_b_dB = " & real_to_str(fil_measured_snr_b_dB, 7, 2) & " [dB]"); + END IF; print_str(". sst_measured_snr_b_dB = " & real_to_str(sst_measured_snr_b_dB, 7, 2) & " [dB]"); print_str(". wpfb_measured_proc_gain_b_dB = " & real_to_str(wpfb_measured_proc_gain_b_dB, 7, 2) & " [dB]"); print_str("");