【问题标题】:VHDL Error [no choices for 'U' to 'X]' & [can't match character literal..]VHDL 错误 [没有选择 'U' 到 'X]' & [无法匹配字符文字..]
【发布时间】:2021-02-25 19:11:55
【问题描述】:

我是 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

编辑:我将 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;

【问题讨论】:

  • case 语句并未涵盖所有可能的etat 组合,即std_logic。使用case others =&gt; 覆盖std_logic 的所有可能状态
  • 这个错误的原因 - ha.vhdl:20:79:error: can't match character literal '0' with type integer - 如果你比较第 20 行和第 19 行,就很清楚了。
  • 感谢您的回复,我将 signal etat : std_logic 更改为 signal etat : bit 消除了其他可能性。现在的问题是 gtkwave 没有显示任何内容(我已经编辑了帖子并包含了屏幕截图)
  • @Matthew Taylor 请看一下编辑先生
  • 您编辑了您的问题,删除了minimal reproducible example。问题中的代码不再重复问题。

标签: vhdl fpga ghdl


【解决方案1】:

感谢@Matthew Taylor 和@Rakend

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

我没有使用case others =&gt; 覆盖std_logic 的所有可能状态,而是将signal etat : std_logic 更改为signal etat : bit 消除了其他可能性,这意味着该信号仅采用两种可能性0 或1。因此,手头的问题是解决了。​​

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-11-12
    • 1970-01-01
    • 1970-01-01
    • 2017-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多