A simple vhdl fir description.
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.

58 lines
2.3KB

  1. LIBRARY ieee;
  2. USE ieee.std_logic_1164.ALL;
  3. USE ieee.numeric_std.ALL;
  4. USE work.GENERAL_INCLUDES.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. in_assignment : FOR i IN 0 TO cst_nb_coeffs_subfilter_in-1 GENERATE
  19. vect_i_coeffs(i) <= i_coeffs(cst_nb_coeffs_subfilter_in-1-i);
  20. END GENERATE in_assignment;
  21. mult_inst : ENTITY work.MULT_BLK(Mult_Path)
  22. PORT MAP( i_clk => i_clk,
  23. i_data => i_data,
  24. i_coeffs => vect_i_coeffs,
  25. o_data => mult_out(0 TO cst_nb_coeffs_subfilter_in-1)
  26. );
  27. mult_out_wire : FOR i IN 0 TO cst_nb_coeffs_subfilter_in-1 GENERATE
  28. matrix_adder_tree(0)(i)(cst_w_mult_out-1 DOWNTO 0) <= mult_out(i)(cst_w_mult_out-1 DOWNTO 0);
  29. END GENERATE mult_out_wire;
  30. stages_loop : FOR stage IN 1 TO cst_log2_adder_stages GENERATE
  31. cell_loops : FOR cell IN 0 TO 2**(cst_log2_adder_stages-stage)-1 GENERATE
  32. matrix_adder_tree_signed(stage)((2**stage)*cell)(cst_w_mult_out+stage-1 DOWNTO 0) <= signed(matrix_adder_tree(stage-1)((2**stage)*cell)(cst_w_mult_out+stage-2)&matrix_adder_tree(stage-1)((2**stage)*cell)(cst_w_mult_out+stage-2 DOWNTO 0))+signed(matrix_adder_tree(stage-1)((2**(stage-1))*(2*cell+1))(cst_w_mult_out+stage-2)&matrix_adder_tree(stage-1)((2**(stage-1))*(2*cell+1))(cst_w_mult_out+stage-2 DOWNTO 0));
  33. matrix_adder_tree(stage)((2**stage)*cell)(cst_w_mult_out+stage-1 DOWNTO 0) <= std_logic_vector(unsigned(matrix_adder_tree_signed(stage)((2**stage)*cell)(cst_w_mult_out+stage-1 DOWNTO 0)));
  34. END GENERATE cell_loops;
  35. END GENERATE stages_loop;
  36. adder_tree_process : PROCESS(i_clk)
  37. BEGIN
  38. IF(rising_edge(i_clk)) THEN
  39. o_data <= matrix_adder_tree(cst_log2_adder_stages)(0);
  40. END IF;
  41. END PROCESS;
  42. END Adder_Tree;