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.

74 lines
4.1KB

  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. -- NOTE:
  8. -- The number of in/output samples must be a 2^n factor of 5, < 160
  9. PACKAGE FIVEn_DFT_PKG IS
  10. CONSTANT cst_w_in_5ndft : natural := cst_w_polyfir_out_dft_in_pfb; -- input_bitwidth
  11. CONSTANT cst_w_out_5ndft : natural := cst_w_out_pfb; -- output bitwidth, must be < 30
  12. CONSTANT cst_nb_samples_in_5ndft : natural := cst_nb_subfilters_pfb; -- must be 5*n
  13. CONSTANT cst_w_precision_winograd5_coeffs_5ndft : natural := cst_w_precision_winograd5_coeffs_pfb; -- must be <= 32 and >= 3, sign bit included. Ideal is >= 8
  14. CONSTANT cst_w_precision_radix2_coeffs_5ndft : natural := cst_w_precision_radix2_coeffs_pfb; -- must be <= 32 and >= 3, sign bit included. Ideal is >= 8
  15. -- CALCULATIONS --
  16. CONSTANT cst_nb_parallel_winograd5 : natural := cst_nb_samples_in_5ndft/5;
  17. CONSTANT cst_log2_nb_parallel_winograd5 : natural := cst_log2_nb_parallel_winograd_pfb; -- = log2(cst_nb_parallel_winograd5)
  18. CONSTANT cst_w_winograd_added : natural := cst_w_precision_winograd5_coeffs_5ndft+6; -- 6 is the number of addition stages in the winograd5 blk
  19. CONSTANT cst_w_radix2_added : natural := cst_w_precision_radix2_coeffs_5ndft+2;
  20. CONSTANT cst_dft_w_out_5ndft : natural := cst_w_in_5ndft+cst_w_winograd_added+(cst_log2_nb_parallel_winograd5*cst_w_radix2_added);
  21. CONSTANT cst_winograd5_w_out_5ndft : natural := cst_w_in_5ndft+cst_w_winograd_added; -- 6 is the number of addition stages in the winograd5 blk
  22. CONSTANT cst_nb_wn_coeffs : natural := cst_nb_samples_in_5ndft/2;
  23. -- TYPES --
  24. SUBTYPE smpl_in_5ndft IS smpl_real_imag_polyfir_out_dft_in_pfb;
  25. SUBTYPE smpl_out_5ndft IS smpl_real_imag_dft_out_pfb; --std_logic_vector(cst_w_out_5ndft-1 DOWNTO 0);
  26. TYPE vect_dft_input IS ARRAY (0 TO cst_nb_samples_in_5ndft-1) OF smpl_in_5ndft;
  27. SUBTYPE vect_dft_output IS vect_dft_output_pfb; --ARRAY (0 TO cst_nb_samples_in_5ndft-1) OF smpl_out_5ndft;
  28. -- winograd5
  29. SUBTYPE smpl_out_winograd5_5ndft IS std_logic_vector(cst_winograd5_w_out_5ndft-1 DOWNTO 0);
  30. SUBTYPE smpl_out_winograd5_signed_5ndft IS signed(cst_winograd5_w_out_5ndft-1 DOWNTO 0);
  31. TYPE vect_input_winograd5_5ndft IS ARRAY (0 TO 4) OF smpl_in_5ndft;
  32. TYPE vect_output_winograd5_5ndft IS ARRAY (0 TO 4) OF smpl_out_winograd5_5ndft;
  33. TYPE vect_total_output_winograd5_cells IS ARRAY (0 TO cst_nb_samples_in_5ndft-1) OF smpl_out_winograd5_5ndft;
  34. TYPE vect_winograd5_generic_stage IS ARRAY (0 TO 5) OF smpl_out_winograd5_5ndft;
  35. TYPE matrix_winograd5_generic_stages IS ARRAY (0 TO 7) OF vect_winograd5_generic_stage;
  36. SUBTYPE smpl_mult_factor_w_multipliers IS std_logic_vector(cst_w_precision_winograd5_coeffs_5ndft-1 DOWNTO 0);
  37. SUBTYPE smpl_mult_factor_w_multipliers_signed IS signed(cst_w_precision_winograd5_coeffs_5ndft-1 DOWNTO 0);
  38. TYPE vect_mult_factors_32b IS ARRAY (1 TO 5) OF std_logic_vector(31 DOWNTO 0);
  39. TYPE vect_mult_factor_w_multipliers IS ARRAY (1 TO 5) OF smpl_mult_factor_w_multipliers;
  40. --radix2
  41. SUBTYPE smpl_cos_sin_wb IS std_logic_vector(cst_w_precision_radix2_coeffs_5ndft-1 DOWNTO 0);
  42. SUBTYPE smpl_cos_sin_signed_wb IS signed(cst_w_precision_radix2_coeffs_5ndft-1 DOWNTO 0);
  43. TYPE vect_cos_sin_k_pi_over_5_32b IS ARRAY(0 TO 4) OF std_logic_vector(31 DOWNTO 0);
  44. TYPE vect_cos_sin_k_pi_over_5_wb IS ARRAY(0 TO 4) OF smpl_cos_sin_wb;
  45. TYPE vect_cos_sin_k_pi_over_80_32b IS ARRAY (0 TO cst_nb_wn_coeffs-1) OF std_logic_vector(31 DOWNTO 0);
  46. SUBTYPE smpl_out_radix2 IS std_logic_vector(cst_dft_w_out_5ndft-1 DOWNTO 0);
  47. SUBTYPE smpl_out_signed_radix2 IS signed(cst_dft_w_out_5ndft-1 DOWNTO 0);
  48. TYPE vect_radix2_fft_line IS ARRAY (0 TO cst_log2_nb_parallel_winograd5) OF smpl_out_radix2;
  49. TYPE vect_radix2_line IS ARRAY (0 TO 3) OF smpl_out_radix2;
  50. TYPE matrix_radix2_cell IS ARRAY (0 TO 1) OF vect_radix2_line;
  51. -- whole fft
  52. TYPE matrix_fft_stages IS ARRAY (0 TO cst_nb_samples_in_5ndft-1) OF vect_radix2_fft_line; -- inputs and outputs of radix2 cells
  53. END;