vhdl - 如何使用存储在 BRAM 中的数据初始化 STD_LOGIC_VECTOR(15 down to 0) 数组
问题描述
我在 BRAM 中有一些滤波器系数,这些系数需要写入数组来执行卷积。我使用类型创建了一个数组并将其分配给一个信号。该信号我已将端口映射到 BRAM 的 DATA_OUT。它给出了一个错误“期望 STD_LOGIC_VECTOR”
我尝试使用 for 循环将数据写入数组。它会导致错误“索引不是 STD_LOGIC_VECTOR”
我的类型声明
TYPE coeff_pipe IS ARRAY(0 TO 15) OF std_logic_vector(7 downto 0);
Signal coeff:coeff_pipe;
我的for循环是这样的
for i in 0 to loop
coeff(i) <= data_out_BRAM(i); end loop;
帮助我对代码进行适当的更改以使其正常工作
解决方案
您可以在编码语言 (C) 和硬件描述语言 (VHDL) 中混合使用for 循环行为。在编码语言中,如果您编写一个for 循环,处理器将按顺序(一个接一个)依次执行循环的内容多次。在 HDL 中,for 循环用于多次实例化具有不同输入/输出的相同电路。for 循环中没有时间概念。
在您的情况下,您必须使用顺序过程并增加您的 BRAM 地址:
process(clk, rst)
begin
if rst = '1' then
addr_BRAM <= (others => '0');
addr_BRAM_d <= (others => '0');
ram_init_en <= '1';
ram_init_en_d <= '0';
coeff <= (others => (others => '0'));
elsif rising_edge(clk) then
addr_BRAM_d <= addr_BRAM ; -- Delay of 1 clk cycle
ram_init_en_d <= ram_init_en; -- Delay of 1 clk cycle
-- Init done
if addr_BRAM = x"1111" then
ram_init_en <= '0';
end if;
-- Increment BRAM address
if ram_init_en = '1' then
addr_BRAM <= std_logic_vector(unsigned(addr_BRAM) + 1);
end if;
-- Get data one cycle after set address because a BRAM doesn't answer instant, it answers in one clk cycle.
if ram_init_en_d = '1' then
coeff(to_integer(unsigned(addr_BRAM_d))) <= data_out_BRAM;
end if;
end if;
end process;
推荐阅读
- javascript - 使用 jest 使用链式方法模拟节点外部模块默认值
- reactjs - 反应引导模式不呈现更新的数据
- python - 无法从 Django 视图发出 POST 请求
- json - 为时间插入 NULL。从 JSON 解码的时间
- python - 如何将海龟的 y 坐标提取为浮点数 - Python 3.x
- c# - 需要一个随机数生成器
- c++ - 找不到程序 .dll 文件
- javascript - 程序运行后如何修复未定义的变量
- python - django.core.exceptions.ImproperlyConfigured:包含的 URLconf '' 似乎没有任何模式
- apache - 如何在 symfony 4 上强制 https 和 www