【发布时间】:2019-07-31 09:16:09
【问题描述】:
我一直在尝试编译这个程序,并尝试根据我对增加错误数量的错误消息的理解进行编辑。这是我编写的第二个 VHDL 代码,我不确定我还能做什么
这是代码:
entity maashro3o is
port (Q: out bit_vector (0 to 7);
A: in bit_vector(2 down to 0);
en: in bit);
end maashro3o;
architecture maashro3o of maashro3o is
begin
process(A, en)
begin
if (en = "1")
then
if (A = "000")
then
Q <= "10000000";
else if (A = "001") then
Q <= "01000000";
else if (A = "010") then
Q <= "00100000";
else if (A = "011") then
Q <= "00010000";
else if (A = "100") then
Q <= "00001000";
else if (A = "101") then
Q <= "00000100";
else if (A = "110") then
Q <= "00000010";
else if (A = "111") then
Q <= "00000001";
END If;
else
Q <= "00000000";
End If;
end process;
end maashro3o
更新
我将else if 分别更改为elsif 和else。
我试图从 else 中删除 then,但我遇到了类似的错误
entity maashro3o is
port (Q: out bit_vector (0 to 7);
A: in bit_vector(2 downto 0);
en: in bit);
end maashro3o;
architecture maashro3o of maashro3o is
begin
process(A, en)
begin
if (en = '1')
then
if (A = "000")
then
Q <= "10000000";
elsif (A = "001") then
Q <= "01000000";
else (A = "010") then
Q <= "00100000";
elsif (A = "011") then
Q <= "00010000";
else (A = "100") then
Q <= "00001000";
elsif (A = "101") then
Q <= "00000100";
else (A = "110") then
Q <= "00000010";
elsif(A = "111") then
Q <= "00000001";
END If;
else
Q <= "00000000";
End If;
end process;
end maashro3o;
【问题讨论】:
-
语法错误:1) 第 3 行,
downto是单个保留字 2) 第 14 行,en不是复合数组类型;使用'1'而不是"1"3) 第 19、21、23、25、27、29、31 行,elsif而不是else if4) 第 41 行,缺少最后的分号。 -
请注意,模拟器通常比合成器提供更好的错误消息。
-
@user1155120 非常感谢!我进行了更改,但现在我遇到了更多错误。我不确定是
then还是括号 -
您的代码中没有任何括号,只有括号和some of those aren't needed。
-
这些
elsees:else (A = "010") then、else (A = "100") then、else (A = "110") then应该是elsifs。您应该能够通过校对找到所有这些语法错误。
标签: if-statement syntax vhdl decoder