【发布时间】: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 =>覆盖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。问题中的代码不再重复问题。