如何解决输入数据未加载到寄存器中 - 仅在综合后时序仿真 [VHDL][Vivado] 中出现问题已解决
这是什么
我正在尝试创建一个简单的 FIR 滤波器。我要向您展示的内容可能并不完全是 FIR 滤波器,因为我正在逐渐增加用于教育目的的项目的复杂性,直到达到所需的功能。
应该做什么
到目前为止它应该做的基本上是:
- 在应用 load = 1 后将数据加载到寄存器,
- 在应用 start = 1 后卸载处理过的数据(它是样本与相应系数的乘积)。
失败的地方
然而,据我所知,它无法将数据加载到寄存器中。似乎像锁存器一样工作,因为在 load 下降到 0 后,输入端口的最后一个向量值被锁存到寄存器中。但我可能错了,它在模拟中似乎是这样工作的。 综合前和综合后功能模拟正在发挥作用!只有合成后的时序无法按预期工作!
我的尝试
- 将 DONT_TOUCH 参数添加到其 .vhd 文件中的实体声明,
- 在将数据传输到寄存器的 data_in 端口之后添加某种缓冲区(无符号变量) - 但它在综合后甚至没有出现在原理图中,也许 DONT_TOUCH 不起作用?
模拟图片
预合成功能 - https://imgur.com/0TaNQyn
合成后时序 - https://imgur.com/mEOv67t
计划
我使用的是 Vivado 2020.2 webpack
测试平台
此处的测试平台代码: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);
--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;
其他信息
- 我刚刚注意到我将 load = 1 保持在一个过长的循环中,这就是为什么最高的数字首先出现。
- 系数为:1、2、3、4、5、6、7、8。
- 在查看 UUT 后的合成后模拟中,我注意到采样寄存器没有加载数据(除了最后一个,正如我之前提到的),i正在增加,其余部分似乎工作正常。
- 除了问题解决方案之外,我很高兴听到关于我的代码的一些改进!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。