Simulation files of Polyphase Filter in VHDL for FPGA.
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

83 Zeilen
3.6KB

  1. LIBRARY ieee;
  2. USE ieee.std_logic_1164.ALL;
  3. USE work.POLY_FIR_PKG.ALL;
  4. ENTITY POLY_SHIFT_REG IS
  5. PORT(i_clk : IN std_logic;
  6. i_data : IN vect_adc_data_out;
  7. o_data : OUT matrix3D_reg_data_out
  8. );
  9. END POLY_SHIFT_REG;
  10. ARCHITECTURE Fill_Matrix OF POLY_SHIFT_REG IS
  11. TYPE vect_i_data_temp IS ARRAY (0 TO cst_nb_subfilters-1) OF smpl_adc_data_in;
  12. SIGNAL data_matrix : matrix3D_reg_data_out;
  13. --SIGNAL data_temp : vect_reg_data := (OTHERS =>(OTHERS => '0'));
  14. SIGNAL data_temp : matrix_reg_data := (OTHERS => (OTHERS => (OTHERS => '0')));
  15. SIGNAL reg_i_data_temp : vect_i_data_temp := (OTHERS => (OTHERS => '0'));
  16. BEGIN
  17. -- purpose: fill a 3D matrix from a register. Each row is the input of the
  18. -- input of a partial filter; each 2D matrix rows-columns is the input for a
  19. -- subfilter
  20. -- inputs: reg_i_data_temp, i_data
  21. -- outputs: data_temp (3D matrix of std_logic_vectors)
  22. PROCESS (i_clk) IS
  23. VARIABLE subfilter_nb : natural := 0;
  24. VARIABLE data_subfilter_nb : natural := 0;
  25. BEGIN -- PROCESS
  26. IF rising_edge(i_clk) THEN -- rising clock edge
  27. -- add the new data to the register
  28. FOR i IN 0 TO cst_nb_subfilters-1 LOOP -- register to store previous data
  29. reg_i_data_temp(i) <= i_data(cst_nb_samples_adc_in-cst_nb_subfilters+i);
  30. END LOOP; -- i
  31. -- shifting the old samples towards reg_i_data_temp(0)
  32. FOR i IN 0 TO cst_nb_subfilters-1 LOOP
  33. data_temp(i)(0 TO cst_nb_samples_shiftreg_temp_in-cst_nb_parallel_firs-1) <= data_temp(i)(cst_nb_parallel_firs TO cst_nb_samples_shiftreg_temp_in-1);
  34. END LOOP; -- i
  35. -- fill a temp 2D matrix for each subfilter (equivalent to filling a temp
  36. -- vector for 1 filter)
  37. parallel_fir_for : FOR parallel_fir_nb IN 0 TO cst_nb_parallel_firs-1 LOOP
  38. fill_data_temp : FOR data_nb IN 0 TO cst_nb_subfilters-1 LOOP -- fill data and copy previous content
  39. IF(data_nb < cst_downsampling_factor) THEN
  40. data_temp(cst_nb_subfilters-1-((parallel_fir_nb*cst_downsampling_factor+data_nb) MOD cst_nb_subfilters))(cst_nb_samples_shiftreg_temp_in-cst_nb_parallel_firs+parallel_fir_nb) <= i_data(cst_downsampling_factor*parallel_fir_nb+data_nb);
  41. ELSE
  42. IF((parallel_fir_nb*cst_downsampling_factor+data_nb)-cst_nb_subfilters < 0) THEN
  43. data_temp(cst_nb_subfilters-1-((parallel_fir_nb*cst_downsampling_factor+data_nb) MOD cst_nb_subfilters))(cst_nb_samples_shiftreg_temp_in-cst_nb_parallel_firs+parallel_fir_nb) <= reg_i_data_temp(data_nb);
  44. ELSE
  45. data_temp(cst_nb_subfilters-1-((parallel_fir_nb*cst_downsampling_factor+data_nb) MOD cst_nb_subfilters))(cst_nb_samples_shiftreg_temp_in-cst_nb_parallel_firs+parallel_fir_nb) <= i_data(cst_downsampling_factor*parallel_fir_nb+data_nb-cst_nb_subfilters);
  46. END IF;
  47. END IF;
  48. END LOOP fill_data_temp;
  49. END LOOP parallel_fir_for; -- parallel_fir_nb
  50. o_data <= data_matrix;
  51. END IF;
  52. END PROCESS;
  53. -- purpose: wiring (filling the 3D out matrix) for each line, for each subfilter
  54. third_dimension : FOR subfilter_nb IN 0 TO cst_nb_subfilters-1 GENERATE
  55. second_dimension : FOR parallel_fir IN 0 TO cst_nb_parallel_firs-1 GENERATE
  56. first_dimension : FOR data_nb IN 0 TO cst_nb_coeffs_subfilter_in-1 GENERATE
  57. data_matrix(subfilter_nb)(parallel_fir)(data_nb) <= data_temp(subfilter_nb)(data_nb+parallel_fir);
  58. END GENERATE first_dimension; -- data_nb
  59. END GENERATE second_dimension; -- parallel_fir
  60. END GENERATE third_dimension; -- subfilter_nb
  61. END Fill_Matrix;