这是什么
我正在尝试创建一个简单的FIR滤波器。我要介绍的是,您可能不是FIR过滤器,因为我正在逐渐增加我的教育需求项目的复杂性,直到它达到预期的功能为止。
它应该做什么
基本上,它目前应该做的是:
=1之后卸载处理过的数据(这是样本与相应系数相乘的乘积)。
失败的地方,
然而,据我注意到,它无法将数据加载到寄存器中。看起来像锁存器一样工作,因为在load下降到0之后,输入端口上的最后一个向量值被锁在寄存器中。但我可能错了,它只是在模拟中像这样工作而已。前后综合功能仿真正在工作!只有合成后的时间不能按要求工作!
我试过什么
。
模拟图片
预合成功能- https://imgur.com/0TaNQyn
后合成时序- https://imgur.com/mEOv67t
程序
我用的是Vivado 2020.2 webpack
Testbench
这里的Testbench代码:https://pastebin.pl/view/d2f9a4ad
主代码
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.numeric_std.ALL;
entity fir is
Port (
clk: in std_logic;
data_in: in unsigned(7 downto 0);
data_out: out unsigned(7 downto 0);
en: in std_logic;
load: in std_logic;
start: in std_logic;
reset: in std_logic
);
end fir;
architecture Behavioral of fir is
-- type coeff_array is array (0 to 7) of integer range 0 to 255;
constant reg_size: integer := 8;
constant filter_order: integer := 7;
type samples_reg is array (0 to reg_size-1) of unsigned(7 downto 0);
type coeffs_reg is array (0 to filter_order) of unsigned(7 downto 0);
begin
process(clk, reset)
-- variable coeffs: coeff_array := (0,0,0,0,0,0,0,0);
--variable b0: unsigned(7 downto 0) := 8D"0";
variable b0: unsigned(7 downto 0) := to_unsigned(1,8);
variable b1: unsigned(7 downto 0) := to_unsigned(2,8);
variable b2: unsigned(7 downto 0) := to_unsigned(3,8);
variable b3: unsigned(7 downto 0) := to_unsigned(4,8);
variable b4: unsigned(7 downto 0) := to_unsigned(5,8);
variable b5: unsigned(7 downto 0) := to_unsigned(6,8);
variable b6: unsigned(7 downto 0) := to_unsigned(7,8);
variable b7: unsigned(7 downto 0) := to_unsigned(8,8);
variable i: integer range 0 to reg_size := 0;
variable samples: samples_reg := (others => (others => '0'));
variable coeffs: coeffs_reg := (b0,b1,b2,b3,b4,b5,b6,b7);
variable data_processed: unsigned(15 downto 0) := (others => '0');
-- variable reg_element:
-- signal s1 : signed(47 downto 0) := 48D"46137344123";
begin
if reset = '1' then
-- data_out <= (others => '0');
samples := (others => (others => '0'));
data_processed := (others => '0');
i := 0;
-- synch part
elsif rising_edge(clk) and en = '1' then
samples := samples;
-- loading data
if load = '1' then
samples(i) := data_in;
i := i+1;
else null;
end if;
-- deloading data
if start = '1' then
data_processed := samples(i)*coeffs(i);
i := i+1;
else null;
end if;
-- reset counter after overflow
if(i = reg_size) then
i := 0;
else null;
end if;
-- reset counter if no data is being transferred
if load = '0' and start = '0' then
i := 0;
data_processed := (others => '0');
else null;
end if;
end if;
data_out <= data_processed(7 downto 0);
end process;
end Behavioral;
其他信息
发布于 2021-01-14 21:25:17
结果,在计时模拟中,我必须给设备至少100 ns的热身时间。
时间模拟似乎考虑了一些与设备启动相关的因素--无论如何,我不确定解释,但我相信上面的解决方案。
我重新定义了标题,这样其他人就可以通过搜索本例中的核心问题找到这篇文章。
祝你好运:)
https://stackoverflow.com/questions/65689231
复制相似问题