我有一个VHDL问题:对于家庭作业,我们必须为我们设计的电路编写一个带有断言的测试平台。我们应该测试每一个信号组合为位比较器。我想用for循环来解决这个问题,如下所示:
architecture ts of testbench is
signal a: std_logic_vector(3 downto 0) := "0000";
signal b: std_logic_vector(3 downto 0) := "1011";
signal c1, c0: std_logic := '0';
begin
TEST: entity forBitVergleicher port map(a, b, c1, c0);
for i in 0 to 2**n loop
k for k in 0 to 2**n loop
a <= std_logic_vector(i); b <= std_logic_vector(k);
assert(unsigned(a) > unsigned(b) and (c1 = '0' or c0 =
'1') and (c1 = '0' and c0 = '0') and (c1 = '1' and c0 =
'0'))
report "error";
assert(unsigned(b) > unsigned(a) and (c1 = '1' and c0 =
'0' or c1 = '0' and c0 = '0' or c1 = '1' and c0 = '0'))
report "error";
assert(a = b and ((c1 = '1' and c0 = '1') or (c1 /= c0)))
report "error";首先,我测试了这个想法(用于循环等)。在Python中,检查它是否有效(它确实起了作用)。现在我不知道为什么我的VHDL代码不工作了。我有很多错误报告,这在我的脑海里是没有意义的。有什么主意吗?
COMP96 ERROR COMP96_0329:"Generate语句必须有标签。“"testbench.vhd“18 3 COMP96错误COMP96_0019:”关键字‘生成’预期。“"testbench.vhd“18 22 COMP96 COMP96_0661:”不允许包含不同逻辑运算符序列的表达式。包含和,或,xor和xnor运算符的Parenthesize子表达式。“"testbench.vhd“28 9 COMP96 COMP96_0016:”预期设计单元声明“。"testbench.vhd“35 4
如果您需要,我有一个完整的VHDL代码的链接:https://www.edaplayground.com/x/4c2n
发布于 2019-12-25 09:59:13
不能在进程(或函数/过程)之外使用for ... loop。您应该将for ... loop放在一个进程(或函数/过程)中,或者使用一个for ... generate循环。
但是,如果您使用for ... generate循环(在进程之外),那么请注意它必须有一个标签(正如您的错误消息之一所描述的)。例如:
loop_label : for i in 0 to 2**n generate
...
end generate;在您的具体情况下,我建议在进程中使用for ... loop (最后使用wait语句)。
您的代码还有很多其他问题,但是这至少可以帮助您克服第一个错误。
其他一些需要研究的问题:
n没有被defined.k for k in ...,应该是for k in ...0 to 2**n将循环2**n +1次。您可能希望0 to 2**n-1.std_logic_vector(i)和std_logic_vector(k)是非法的。您可能需要std_logic_vector(to_unsigned(i, 4))等severity。例如,assert <something> report "error" severity failure;for i in 0 to 2**n-1 loop for k in 0 to 2**n-1 loop a <= std_logic_vector(to_unsigned(i, 4)); b <= std_logic_vector(to_unsigned(k, 4)); ... end loop; end loop;
<a> and <b> or <c> )毫无意义,将被编译器拒绝。你是说(<a> and <b>) or <c>还是<a> and (<b> or <c>)。理解您想要的语言是很重要的,括号大小的appropriately.
https://stackoverflow.com/questions/59477193
复制相似问题