library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; use ieee.fixed_float_types.all; use ieee.fixed_pkg.all; entity low_pass_filter is generic (integer_bits : integer; fraction_bits : integer); port (clock : in std_logic; reset : in std_logic; sample : in sfixed(integer_bits-1 downto -fraction_bits); sample_ready : in std_logic; output : out sfixed(integer_bits-1 downto -fraction_bits); output_ready : out std_logic); end; architecture behaviour of low_pass_filter is constant order : natural := 16; constant counter_bits : natural := 5; -- coefficient store subtype coeff_type is sfixed(1 downto -32); type coeff_array_type is array (natural range 0 to order) of coeff_type; constant coefficients : coeff_array_type := ( B"00_00001001011011111101001111001101", -- 0.0368626 B"00_00000101000000101101011101110001", -- 0.019574609 B"11_11111010000100001100010110000010", -- -0.023181587 B"11_11110000111000101111010111011001", -- -0.05903686 B"11_11110011011010110101111110100000", -- -0.04914286 B"00_00000110000111010110010111000001", -- 0.02388607 B"00_00100011100101110101010001000101", -- 0.13902785 B"00_00111110100110010011100100100010", -- 0.2445255 B"00_01001001100000101010101111101100", -- 0.28715014 B"00_00111110100110010011100100100010", -- 0.2445255 B"00_00100011100101110101010001000101", -- 0.13902785 B"00_00000110000111010110010111000001", -- 0.02388607 B"11_11110011011010110101111110100000", -- -0.04914286 B"11_11110000111000101111010111011001", -- -0.05903686 B"11_11111010000100001100010110000010", -- -0.023181587 B"00_00000101000000101101011101110001", -- 0.019574609 B"00_00001001011011111101001111001101" -- 0.0368626 ); -- internal signals signal address : unsigned(counter_bits-1 downto 0) := (others => '0'); signal coefficient : sfixed(integer_bits-1 downto -fraction_bits); begin filter : entity work.filter_core generic map(integer_bits, fraction_bits, counter_bits, order) port map (clock, reset, sample, sample_ready, address, coefficient, output, output_ready); coefficient <= resize(coefficients(to_integer(address)), coefficient); end;