I am trying to implement a transposed form FIR filter of order 4.I am attaching the code and the waveform alongwith.In the first clock cycle, I have given a reset signal which will initialize the adder_output to 0.Input data is loaded in the second clock cycle.Input is written in a register.So the input is loaded at third clock cycle and the multiplication result of the input and filter coefficient is obtained in the third clock cycle.But at the same clock cycle, the adder output becomes dont care.Hence I am not getting the output for the first 3 clock cycles and after that the output is correct.
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_signed.all;
use ieee.numeric_std.all;
entity bpf is
port
(
rst :in std_logic;
clk : in std_logic;
bpf_enable : in std_logic;
bpf_input : in std_logic_vector(14 downto 0);
bpf_output : out std_logic_vector(14 downto 0);
bpf_ready : out std_logic
);
end bpf;
architecture bpf_behav OF bpf is
component multiplier is
port(
in1 :in std_logic_vector(14 downto 0);
in2 :in std_logic_vector(12 downto 0);
product:out std_logic_vector(27 downto 0)
);
end component;
type coeff_array is array(0 to 3) of std_logic_vector(12 downto 0);
type product_array is array(0 to 3) of std_logic_vector(27 downto 0);
type adder_array is array(0 to 3) of std_logic_vector(34 downto 0);
signal input_data :std_logic_vector(14 downto 0);
signal output_data:std_logic_vector(14 downto 0);
signal coefficient : coeff_array; -- Coefficient array
signal product :product_array;
signal adder_out: adder_array; -- Adder array
signal multiplier_en:std_logic;
begin
coefficient(0)<=std_logic_vector(to_signed(250,13));
coefficient(1)<=std_logic_vector(to_signed(608,13));
coefficient(2)<=std_logic_vector(to_signed(1530,13));
coefficient(3)<=std_logic_vector(to_signed(2603,13));
data_load:process(clk)
begin
if(rising_edge(clk)) then
if(bpf_enable='1') then
input_data<= bpf_input;
end if;
end if;
end process data_load;
mulgen :for index1 in 0 to 3 generate
u_multiplier:multiplier port map
(
in1=>input_data,
in2=>coefficient(index1),
product=>product(index1)
);
end generate;
adder:process(clk)
begin
if(rst='1') then
adder_out<=(others=>(others=>'0'));
elsif(rising_edge(clk)) then
for index1 in 0 to 2 loop
adder_out(index1)<=((34 downto 28=>product(index1)(27)) & product(index1))+adder_out(index1+1);
end loop;
adder_out(3)<=(34 downto 28=>product(3)(27)) & product(3);
end if;
end process adder;
bpf_output<=adder_out(0)(29 downto 15);
end bpf_behav;
entity multiplier is
port
(
in1: in std_logic_vector(14 downto 0);
in2:in std_logic_vector(12 downto 0);
product:out std_logic_vector(27 downto 0)
);
end multiplier;
architecture multiplier_behav of multiplier is
begin
product<=in1*in2;
end multiplier_behav;