Simulation files of Polyphase Filter in VHDL for FPGA.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

86 linhas
2.6KB

  1. LIBRARY ieee;
  2. USE ieee.std_logic_1164.ALL;
  3. USE ieee.numeric_std.ALL;
  4. USE work.POLY_FIR_PKG.ALL;
  5. ENTITY PARTIAL_FIR IS
  6. PORT(i_clk : IN std_logic;
  7. i_coeffs : IN vect_fir_coeffs_in;
  8. i_data : IN vect_fir_data_in;
  9. o_data : OUT smpl_fir_adder_data_out
  10. );
  11. END PARTIAL_FIR;
  12. ARCHITECTURE Adder_Tree OF PARTIAL_FIR IS
  13. SIGNAL matrix_adder_tree : matrix_adder_generic := (OTHERS => (OTHERS => (OTHERS => '0')));
  14. --SIGNAL matrix_adder_tree_signed : matrix_adder_generic_signed := (OTHERS => (OTHERS => (OTHERS => '0')));
  15. SIGNAL vect_i_coeffs : vect_fir_coeffs_in;
  16. SIGNAL mult_out : vect_mult_data_out := (OTHERS => (OTHERS => '0'));
  17. BEGIN
  18. -- purpose: assign the filter in a decreasing order
  19. in_assignment : FOR i IN 0 TO cst_nb_coeffs_subfilter_in-1 GENERATE
  20. vect_i_coeffs(i) <= i_coeffs(cst_nb_coeffs_subfilter_in-1-i);
  21. END GENERATE in_assignment;
  22. -- instanciation of MULT_BLK(Mult_Path), multiplying each element from i_data
  23. -- with the correct coefficient in vect_i_coeffs
  24. mult_inst : ENTITY work.MULT_BLK(Mult_Path)
  25. PORT MAP(i_clk => i_clk,
  26. i_data => i_data,
  27. i_coeffs => vect_i_coeffs,
  28. o_data => mult_out
  29. );
  30. -- purpose: fill the input (which is the result of multiplication) of the addition tree matrix
  31. -- inputs: mult_out
  32. -- outputs: matrix_adder_tree(0)
  33. mult_out_wire : FOR i IN 0 TO cst_nb_coeffs_subfilter_in-1 GENERATE
  34. matrix_adder_tree(0)(i)(cst_w_mult_out-1 DOWNTO 0) <= mult_out(i)(cst_w_mult_out-1 DOWNTO 0);
  35. END GENERATE mult_out_wire;
  36. -- purpose: wiring: construct the adder tree. Construction:
  37. --
  38. -- 0-+--+----+->
  39. -- 1/ / /
  40. -- 2-+/ /
  41. -- 3/ /
  42. -- 4-+--+/
  43. -- 5/ /
  44. -- 6-+/
  45. -- 7/
  46. --
  47. -- inputs: matrix_adder_tree(0)
  48. -- outputs: matrix_adder_tree(cst_log2_adder_stages)
  49. stages_loop : FOR stage IN 1 TO cst_log2_adder_stages GENERATE
  50. cell_loops : FOR cell IN 0 TO 2**(cst_log2_adder_stages-stage)-1 GENERATE
  51. add_inst : ENTITY work.add_blk(add)
  52. GENERIC MAP(w_out => cst_w_mult_out+stage-1)
  53. PORT MAP(i_clk => i_clk,
  54. i_data1 => matrix_adder_tree(stage-1)((2**(stage-1))*2*cell),
  55. i_data2 => matrix_adder_tree(stage-1)((2**(stage-1))*(2*cell+1)),
  56. o_data => matrix_adder_tree(stage)((2**stage)*cell)
  57. );
  58. END GENERATE cell_loops;
  59. END GENERATE stages_loop;
  60. -- take the result when adder tree finished
  61. o_data <= matrix_adder_tree(cst_log2_adder_stages)(0);
  62. END Adder_Tree;