Filter FIR滤波器的有限状态机模型

Filter FIR滤波器的有限状态机模型,filter,filtering,vhdl,digital-filter,Filter,Filtering,Vhdl,Digital Filter,我想做一个FIR的FSM模型,因为我需要在FSM实现中编写FIR计算代码行 以下是FIR的实际正确代码 entity fir_4tap is port( Clk : in std_logic; --clock signal Clk_fast : in std_logic; -- Xin : in signed(7 downto 0); --input signal bit_in : in std_logic;

我想做一个FIR的FSM模型,因为我需要在FSM实现中编写FIR计算代码行

以下是FIR的实际正确代码

entity fir_4tap is
  port(   Clk : in std_logic; --clock signal
          Clk_fast : in std_logic;
          --  Xin : in signed(7 downto 0); --input signal
          bit_in : in std_logic;
          bit_out : out std_logic;
          Yout : out signed(15 downto 0)  --filter output
  );
end fir_4tap;

architecture Behavioral of fir_4tap is
  signal add_out3 : signed(15 downto 0) := (others => '0');
  signal index : unsigned(2 downto 0) := (others =>'0');
  signal counter : unsigned(3 downto 0) := (others => '0');
  signal p : unsigned(1 downto 0) := (others => '0');
  signal k : unsigned(1 downto 0) := (others => '0');
  signal j : unsigned(1 downto 0) := (others => '0');
  type array_signed is array(8 downto 0) of signed(7 downto 0);
  signal z : array_signed := (others => "00000000");
  type array_signed1 is array(3 downto 0) of signed(7 downto 0);
  signal H : array_signed1 := (others => "00000000");
  signal Xin : array_signed1 := (others => "00000000");
begin
  z(0) <= to_signed(-3,8);
  z(1) <= to_signed(1,8); 
  z(2) <= to_signed(0,8);
  z(3) <= to_signed(-2,8);
  z(4) <= to_signed(-1,8); 
  z(5) <= to_signed(4,8); 
  z(6) <= to_signed(-5,8);
  z(7) <= to_signed(6,8); 
  z(8) <= to_signed(0,8);
  H(0) <= to_signed(-2,8);
  H(1) <= to_signed(-1,8);
  H(2) <= to_signed(3,8);
  H(3) <= to_signed(4,8);

  process (clk) 
  begin
    if (rising_edge(Clk)) then 
      index <= index +1;
      if (index = "111") then 
        Xin(to_integer(p)) <= z(to_integer(counter));                                              k <= p;
        p <= p + 1;
        ***-- This part of the code has problem, I want to write the line which is summing --up for add_out3 in a for loop.***
        add_out3 <= (others => '0');
        add_out3 <=  Xin(to_integer(k))*H(to_integer(j)) + Xin(to_integer(k-1))*H(to_integer(j+1)) + Xin(to_integer(k-2))*H(to_integer(j+2)) + Xin(to_integer(k-3))*H(to_integer(j+3));
        Yout <= add_out3;
      end if;
    end if;
  end process;
end Behavioral;
实体fir\u 4tap为
端口(时钟:在标准逻辑中;--时钟信号
时钟快速:在标准逻辑中;
--Xin:有符号(7到0);--输入信号
位输入:在标准逻辑中;
位输出:输出标准逻辑;
Yout:out signed(15到0)--过滤器输出
);
末端fir_4tap;
fir_4tap的体系结构是
信号加法输出3:有符号(15到0):=(其他=>“0”);
信号索引:无符号(2到0):=(其他=>'0');
信号计数器:无符号(3到0):=(其他=>“0”);
信号p:无符号(从1到0):=(其他=>'0');
信号k:无符号(从1到0):=(其他=>'0');
信号j:无符号(从1到0):=(其他=>'0');
类型array_signed是有符号(7到0)的数组(8到0);
信号z:array_signed:=(其他=>“00000000”);
类型数组_signed1是有符号(7到0)的数组(3到0);
信号H:array_signed1:=(其他=>“00000000”);
信号Xin:array_signed1:=(其他=>“00000000”);
开始
z(0)此答案是针对问题的初始版本,但现在问题已更改。
使add_out3成为变量而不是信号

for i in 0 to 3 loop 
add_out3 := add_out3 + Xin(k-i)*H(i); 
end loop;
在for循环中是否进行了上述更改?它工作正常。 因此,我的问题中的代码是FIR的正确代码,工作也很顺利。
了解到在使用信号或变量时需要非常小心。所有信号在同一时间(即在时钟周期结束时)获得一个新值,而在变量中,值在进程内被更新为指定值。尝试一步一步地运行模拟并解决问题。

您需要了解信号和变量之间的差异,尤其是在时钟过程中。很好。现在想想for循环中信号分配对j和k的影响……没有理由期望减少LUT的使用,因为循环被有效地展开以在单个循环中运行。如果您可以容忍花费更多的周期来产生结果,那么可以通过每个周期执行一次mult/add来减少硬件使用。要做到这一点,下一步要学习的是。。。国家机器。或者;您的FPGA有硬件乘法器吗?可能有什么东西阻止了synth工具使用它们……是的,所以当需要时间生成样本时,我在FSM中添加了一个条件,在看到模拟后,对于64个周期,什么都不做,等待输入,因为较慢的时钟在16个周期内生成输出,在此期间,64个周期的快速时钟运行比率为4。然后从64到76 FSM运行并生成输出,然后当FSM_监视器为76时,我也通过单个进程将其再次置零,你是指灵敏度列表只有一个变量的进程吗?
for i in 0 to 3 loop 
add_out3 := add_out3 + Xin(k-i)*H(i); 
end loop;