在进程中使用 if/then 语句时出现 VHDL 语法错误



我收到第 16 行的这条消息:靠近"'":语法错误。 我不确定我的错误是什么。 任何帮助将不胜感激!

library IEEE;
use IEEE.std_logic_1164.all;
entity SystemI is
    port (ABCD : in std_logic_vector(3 downto 0);
          F    : out std_logic);
end entity;
architecture SystemI_arch of SystemI is
begin
    process (ABCD)
        begin
            if (ABCD='0001') then
                F <= '1';
            elsif (ABCD='0011') then
                F <= '1';
            elsif (ABCD='1001') then
                F <= '1';
            elsif (ABCD='1011') then
                F <= '1';
            else
                F <= '0';
            end if;
    end process;
end architecture;

您在比较中使用单引号 ( ' ),用于单位/字符文字。对于向量,您需要使用 " .

将所有 if/elsif 语句的比较更改为 (ABCD="0001")

编辑:

此外,您可以将整个过程替换为等效的选定信号分配:

with ABCD select 
    F <= '1' when "0001" | "0011" | "1001" | "1011", '0' when others;

最新更新