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.

109 lines
4.7KB

  1. LIBRARY ieee;
  2. USE ieee.std_logic_1164.ALL;
  3. USE ieee.numeric_std.ALL;
  4. USE ieee.std_logic_unsigned.ALL;
  5. USE ieee.std_logic_signed.ALL;
  6. USE work.PFB_PKG.ALL;
  7. PACKAGE POLY_FIR_PKG IS
  8. -- NOTES and PACKAGE INSTRUCTIONS :
  9. -- cst_downsampling_factor must be a multiplier OF cst_nb_samples_adc_in
  10. -- and cst_nb_subfilters/cst_nb_samples_adc_in*cst_downsampling_factor must be an integer
  11. -- with cst_downsampling_factor < or = cst_nb_subfilters.
  12. --
  13. -- INPUT : vector of samples (cst_nb_samples_adc_in samples);
  14. -- OUTPUT : 2D matrix of samples (matrix_fir_data_out(y)(x), with y the
  15. -- subfilter number, and x the xth parallel fir);
  16. --
  17. -- the lower parallel fir, the older result.
  18. -- -- CONSTANTS -- --
  19. -- ADC
  20. CONSTANT cst_w_in : natural := cst_w_in_pfb ; -- ADC in bitwidth
  21. CONSTANT cst_w_out : natural := cst_w_polyfir_out_dft_in_pfb;
  22. CONSTANT cst_nb_samples_adc_in : natural := cst_nb_samples_adc_in_pfb; -- ADC in nb samples
  23. -- FILTER
  24. --coefficients
  25. CONSTANT cst_w_coeff : natural := cst_w_coeffs_polyfir_pfb; -- coeffs bitwidth
  26. CONSTANT cst_nb_coeffs_filter_in : natural := cst_nb_coeffs_polyfir_pfb;
  27. -- FIR
  28. CONSTANT cst_downsampling_factor : natural := cst_polyfir_downsampling_factor_pfb;
  29. -- POLYPHASE FILTER
  30. CONSTANT cst_nb_subfilters : natural := cst_nb_subfilters_pfb;
  31. -- -- CALCULATIONS -- --
  32. -- SHIFT REG
  33. CONSTANT cst_nb_coeffs_subfilter_in : natural := cst_nb_coeffs_filter_in/cst_nb_subfilters;
  34. CONSTANT cst_log2_sup_nb_coeffs_subfilter_in : natural := cst_log2_sup_nb_coeffs_subfilter_pfb;
  35. CONSTANT cst_nb_samples_shiftreg_temp_in : natural := cst_nb_coeffs_subfilter_in + cst_nb_samples_adc_in/cst_downsampling_factor;
  36. -- mult
  37. CONSTANT cst_w_mult_out : natural := cst_w_coeff+cst_w_in;
  38. -- adder
  39. CONSTANT cst_log2_adder_stages : natural := cst_log2_sup_nb_coeffs_subfilter_in;
  40. -- fir
  41. CONSTANT cst_w_fir_adder_out : natural := cst_w_mult_out+cst_log2_adder_stages;
  42. CONSTANT cst_nb_parallel_firs : natural := cst_nb_parallel_firs_dfts_pfb;
  43. -- TYPES
  44. -- ADC
  45. SUBTYPE smpl_adc_data_in IS smpl_real_imag_adc_data_in_pfb;
  46. SUBTYPE smpl_fir_data_out IS smpl_real_imag_polyfir_out_dft_in_pfb;
  47. -- SHIFT REG
  48. TYPE vect_adc_data_out IS ARRAY (0 TO cst_nb_samples_adc_in-1) OF smpl_adc_data_in;
  49. TYPE vect_fir_data_in IS ARRAY(0 TO cst_nb_coeffs_subfilter_in-1) OF smpl_adc_data_in;
  50. TYPE vect_reg_data IS ARRAY(0 TO cst_nb_samples_shiftreg_temp_in-1) OF smpl_adc_data_in;
  51. TYPE matrix_reg_data IS ARRAY(0 TO cst_nb_subfilters-1) OF vect_reg_data;
  52. TYPE matrix_reg_data_out IS ARRAY(0 TO cst_nb_parallel_firs-1) OF vect_fir_data_in;
  53. TYPE matrix3D_reg_data_out IS ARRAY (0 TO cst_nb_subfilters-1) OF matrix_reg_data_out;
  54. -- FILTER
  55. SUBTYPE smpl_coeff IS std_logic_vector(cst_w_coeff-1 DOWNTO 0);
  56. -- mult
  57. SUBTYPE smpl_mult_data_out IS std_logic_vector(cst_w_mult_out-1 DOWNTO 0);
  58. SUBTYPE smpl_mult_data_out_signed IS signed(cst_w_mult_out-1 DOWNTO 0);
  59. SUBTYPE smpl_coeffs_signed IS signed(cst_w_coeff-1 DOWNTO 0);
  60. SUBTYPE smpl_mult_data_in_signed IS signed(cst_w_in-1 DOWNTO 0);
  61. TYPE vect_polyfir_coeffs_in IS ARRAY (0 TO cst_nb_coeffs_filter_in-1) OF smpl_coeff;
  62. TYPE vect_data_mult_in_signed IS ARRAY(0 TO cst_nb_coeffs_subfilter_in-1) OF smpl_mult_data_in_signed;
  63. TYPE vect_fir_coeffs_in IS ARRAY(0 TO cst_nb_coeffs_subfilter_in-1) OF smpl_coeff;
  64. TYPE vect_mult_coeffs_signed IS ARRAY(0 TO cst_nb_coeffs_subfilter_in-1) OF smpl_coeffs_signed;
  65. TYPE vect_mult_data_out IS ARRAY(0 TO cst_nb_coeffs_subfilter_in-1) OF smpl_mult_data_out;
  66. TYPE vect_mult_data_out_signed IS ARRAY(0 TO cst_nb_coeffs_subfilter_in-1) OF smpl_mult_data_out_signed;
  67. TYPE matrix_fir_coeffs_in IS ARRAY (0 TO cst_nb_subfilters-1) OF vect_fir_coeffs_in;
  68. -- adder
  69. TYPE vect_adder_generic IS ARRAY(0 TO 2**(cst_log2_adder_stages)-1) OF std_logic_vector(cst_w_fir_adder_out-1 DOWNTO 0);
  70. TYPE vect_adder_generic_signed IS ARRAY(0 TO 2**(cst_log2_adder_stages)-1) OF signed(cst_w_fir_adder_out-1 DOWNTO 0);
  71. TYPE matrix_adder_generic IS ARRAY(0 TO cst_log2_adder_stages) OF vect_adder_generic;
  72. TYPE matrix_adder_generic_signed IS ARRAY(0 TO cst_log2_adder_stages) OF vect_adder_generic_signed;
  73. -- fir
  74. SUBTYPE smpl_fir_adder_data_out IS std_logic_vector(cst_w_fir_adder_out-1 DOWNTO 0);
  75. TYPE vect_fir_adder_data_out IS ARRAY (0 TO cst_nb_parallel_firs-1) OF smpl_fir_adder_data_out;
  76. TYPE vect_fir_data_out IS ARRAY(0 TO cst_nb_parallel_firs-1) OF smpl_fir_data_out;
  77. -- POLYPHASE FILTER
  78. TYPE matrix_fir_data_out IS ARRAY (0 TO cst_nb_subfilters-1) OF vect_fir_data_out;
  79. END;