我试图将std_logic_vector的某些部分复制到另一个位置(索引),具体取决于输入 . 这可以在Vivado中合成,但我想使用另一个工具(SymbiYosys,https://github.com/YosysHQ/SymbiYosys)进行形式验证 . SymbiYosys可以使用Verific作为前端来处理VHDL,但Verific不接受这一点 . 这是一小段代码,可以重现问题 . Verific抱怨"left range bound is not constant" . 那么,是否有一种解决方法可以让Verific接受这样的可变范围分配?
我已经找到了这篇文章VHDL: slice a various part of an array,它建议使用一个循环并为每位分配值,但我宁愿不改变我的代码,因为它适用于Vivado . 此外,我认为这样的循环会损害代码的可读性,也许会影响实现效率 . 因此,我正在寻找一种不同的方法(可能是将此错误转换为警告或不太严格的代码修改的方法) .
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.NUMERIC_STD.all;
entity test is
port(
clk : in std_logic;
prefix : in std_logic_vector( 8*8 -1 downto 0);
msgIn : in std_logic_vector(128*8 -1 downto 0);
msgLength : in integer range 1 to 128;
test_out : out std_logic_vector((128+8)*8 -1 downto 0)
);
end test;
architecture behav of test is
begin
process (clk)
begin
if rising_edge(clk) then
test_out <= (others => '0');
test_out((msgLength+8)*8 -1 downto msgLength*8) <= prefix;
test_out( msgLength *8 -1 downto 0) <= msgIn(msgLength*8 -1 downto 0);
end if;
end process;
end behav;
1 回答
应该进行一些转换(如果你的工具支持
srl
和sll
运算符) . 首先左对齐你的消息(左移),用你的前缀左边填充它,最后右移它:备注:
std_logic_vector
上的srl
和sll
运算符,请尝试使用bit_vector
.srl
和sll
已于1993年在标准中引入 . 示例:合成结果可能是巨大而缓慢的,因为这个1088位桶形移位器具有128种可能的不同移位是一种怪物 .
如果你有时间(我的意思是几个时钟周期),那么可能会有更小更高效的解决方案 .