VHDL implementation of a polyphase filter bank with polyphase filter and 5ndft
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
2.8KB

  1. LIBRARY ieee;
  2. USE ieee.std_logic_1164.ALL;
  3. USE ieee.std_logic_signed.ALL;
  4. USE ieee.numeric_std.ALL;
  5. USE work.used_functions_pkg.ALL;
  6. PACKAGE PFB_PKG IS
  7. -- NOTES and PACKAGES INSTRUCTIONS :
  8. -- please cf. sub_packages instructions
  9. --
  10. -- this block takes real and imaginary part every other sample, for a total
  11. -- of 2*cst_nb_samples_adc_in_pfb samples in input.
  12. -- does not work yet for 20 subfilters (fir to be re-tested?)
  13. -- input
  14. CONSTANT cst_w_in_pfb : natural := 6;
  15. CONSTANT cst_w_out_pfb : natural := 6;
  16. CONSTANT cst_nb_samples_adc_in_pfb : natural := 80; -- a complete sample is a real AND an imag (both following)
  17. -- polyphase filter
  18. CONSTANT cst_w_coeffs_polyfir_pfb : natural := 8; -- polyfir coeffs bitwidth
  19. CONSTANT cst_nb_coeffs_polyfir_pfb : natural := 200;
  20. CONSTANT cst_polyfir_downsampling_factor_pfb : natural := 8;
  21. -- dft
  22. CONSTANT cst_nb_subfilters_pfb : natural := 10;
  23. CONSTANT cst_w_precision_winograd5_coeffs_pfb : natural := 8; -- dft winograd coeffs bitwidth
  24. CONSTANT cst_w_precision_radix2_coeffs_pfb : natural := 8; -- dft butterfly coeffs bitwidth
  25. CONSTANT cst_nb_bits_shift_round_pfb : natural := 19; -- the number of MSBs to avoid (sign bits) before rounding. For cst_nb_subfilters_pfb=10, 19 works well; for cst_nb_subfilters_pfb=20, 23 should work well. See bellow for a potential correct formula, but please test for your application, don't trust this formula.
  26. -- calculations --
  27. CONSTANT cst_log2_sup_nb_coeffs_subfilter_pfb : natural := log2_sup_integer(number => cst_nb_coeffs_polyfir_pfb/cst_nb_subfilters_pfb);
  28. CONSTANT cst_w_polyfir_out_dft_in_pfb : natural := cst_w_in_pfb + cst_w_coeffs_polyfir_pfb+cst_log2_sup_nb_coeffs_subfilter_pfb;
  29. CONSTANT cst_log2_nb_parallel_winograd_pfb : natural := log2_sup_integer(number => cst_nb_subfilters_pfb/5);
  30. CONSTANT cst_nb_parallel_firs_dfts_pfb : natural := cst_nb_samples_adc_in_pfb/cst_polyfir_downsampling_factor_pfb;
  31. --CONSTANT cst_nb_bits_shift_round_pfb : natural := 15+4*cst_log2_nb_parallel_winograd_pfb; -- potential corect formula
  32. -- TYPES
  33. SUBTYPE smpl_real_imag_adc_data_in_pfb IS std_logic_vector(cst_w_in_pfb-1 DOWNTO 0);
  34. SUBTYPE smpl_real_imag_polyfir_out_dft_in_pfb IS std_logic_vector(cst_w_polyfir_out_dft_in_pfb-1 DOWNTO 0);
  35. SUBTYPE smpl_real_imag_dft_out_pfb IS std_logic_vector(cst_w_out_pfb-1 DOWNTO 0);
  36. --TYPE vect_fir_out_dft_in_pfb IS ARRAY (0 TO cst_nb_subfilters_pfb-1) OF smpl_real_imag_polyfir_out_dft_in_pfb;
  37. TYPE vect_adc_data_out_pfb IS ARRAY (0 TO 2*cst_nb_samples_adc_in_pfb-1) OF smpl_real_imag_adc_data_in_pfb;
  38. TYPE vect_dft_output_pfb IS ARRAY (0 TO 2*cst_nb_parallel_firs_dfts_pfb*cst_nb_subfilters_pfb-1) OF smpl_real_imag_dft_out_pfb;
  39. END PACKAGE PFB_PKG;