VHDL 错误 [没有选择“U”到“X]”&[无法匹配字符文字..]

问题描述

我是 VHDL 的新手,我正在尝试生成这些脉冲 compt、etat、SORTIE,代码如下:

Library ieee; Use ieee.std_logic_1164.all;
Use ieee.numeric_std.all;

entity EXO is
port (CLK,EN: in bit; SORTIE: out bit);
end entity;

architecture EXXO of EXO is

signal compt : integer range 0 to 7 ;
signal etat : std_logic;

begin

    process (CLK)
    begin
        if CLK'event and CLK = '1' then
            if EN = '1' then compt <= compt + 1;
                case etat is
                    when '0' => if compt = 3 then compt <= '0'; SORTIE <= '1'; etat <= '1'; end if;
                    when '1' => if compt = 2 then compt <= 0; SORTIE <= '0'; etat <= '0'; end if;
                end case;
            end if;
        end if;
    end process;

end architecture;

当我在终端中运行 ghdl -s ha.vhdl 时,出现此错误

ha.vhdl:20:40:error: no choices for 'U' to 'X'
ha.vhdl:19:32:error: no choices for 'Z' to '-'
ha.vhdl:20:79:error: can't match character literal '0' with type integer

EDIT:我将 signal etat : std_logic 更改为 signal etat : bit 以消除其他可能性。问题解决了,现在 gtkwave 不显示任何内容

Screenshot of GTKWAVE after edit

Library ieee; Use ieee.std_logic_1164.all;
Use ieee.numeric_std.all;

entity EXO1 is
port (CLK,EN: in bit; SORTIE: out bit);
end entity;

architecture EXXO of EXO1 is

signal compt : integer range 0 to 7 ;
signal etat : bit;

begin

    process (CLK)
    begin
        if CLK'event and CLK = '1' then
            if EN = '1' then
                compt <= compt + 1;
                case etat is
                    when '0' => if compt = 3 then compt <= 0; SORTIE <= '1'; etat <= '1'; end if;
                    when '1' => if compt = 2 then compt <= 0; SORTIE <= '0'; etat <= '0'; end if;
                end case;
            end if;
        end if;
    end process;

end architecture;

解决方法

感谢@Matthew Taylor 和@Rakend

case 语句未涵盖 etat 的所有可能组合,即 std_logic

我没有使用 case others => 来覆盖 std_logic 的所有可能状态,而是将 signal etat : std_logic 更改为 signal etat : bit 以消除其他可能性,这意味着信号只需要两种可能性 0 或1. 这样手头的问题就解决了。