0

我在终端中使用GHDL模拟了这个VHDL代码,没有发生错误,但是当我将.vcd文件导入GTKWAVE时没有显示信号。

GTKWAVE 的屏幕截图

设计代码:

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 : 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;

编辑: 我是 VHDL 的新手,所以请多多包涵。

我需要完成这个 计时码表。给出了设计代码。我试图为它创建一个测试台,结果如下: GTKWAVE Screenshot 2这显然是一个彻底的失败(无法显示 compt、etat、SORTIE)。

试验台:

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

entity EXOtb is
end entity;

architecture EXXOtb of EXOtb is
    component EXO
    port (CLK, EN: in bit; SORTIE: out bit);
    end component;
    signal CLKtb, ENtb: bit;
    signal SORTIEtb: bit;


begin
    DUT: EXO port map (CLK => CLKtb, EN => ENtb, SORTIE => SORTIEtb ); 
    STIMULUS: process 
    
    begin
    CLKtb <= '0'; ENtb <= '0'; wait for 10 ns; 
    CLKtb <= '0'; ENtb <= '1'; wait for 10 ns; 
    CLKtb <= '1'; ENtb <= '1'; wait for 10 ns; 
    CLKtb <= '1'; ENtb <= '1'; wait for 10 ns; 


    assert false report "Reached End of test";
    wait;
    end process;

end architecture;

编辑 3:感谢@user1155120 的详细回答,我相信我已经解决了这个问题。

  • 我没有手动声明 CLK 值,而是为它创建了一个适当的函数。
  • 出于某种原因,为了在 GTKWAVE 中显示内部信号,您还需要在测试台中声明它们,老实说我不知道​​为什么。
  • 通过仔细查看设计代码,输入EN似乎引用了一些启用属性,并且代码只有在EN为真时才会运行,所以在测试台中我给它的值是 1。另外,这if EN = '1' then似乎是多余的,并且有不需要因为EN总是1。我保持原样。

新的设计规范:

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity EX is
    Port ( CLK : in  STD_LOGIC;
           EN : in  STD_LOGIC;
           SORTIE : out  STD_LOGIC);
end EX;

architecture Behavioral of EX is

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

begin    -- Stimulus process
    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 Behavioral;

试验台:

LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
 

 
ENTITY EXTB IS
END EXTB;
 
ARCHITECTURE behavior OF EXTB IS 
 
    -- Component Declaration for the Unit Under Test (UUT)

    COMPONENT EX
    PORT(
         CLK : IN  std_logic;
         EN : IN  std_logic;
         SORTIE : OUT  std_logic
        );
    END COMPONENT;
        

    --Inputs
    signal CLK : std_logic := '0';
    signal EN : std_logic := '1';

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

    --Outputs
    signal SORTIE : std_logic;

    -- Clock period definitions
     constant CLK_period : time := 10 ns;
 
BEGIN
 
    -- Instantiate the Unit Under Test (UUT)
    uut: EX PORT MAP (
          CLK => CLK,
          EN => EN,
          SORTIE => SORTIE
        );

    -- Clock process definitions
    CLK_process :process
    begin
        CLK <= '0';
        wait for CLK_period/2;
        CLK <= '1';
        wait for CLK_period/2;
    end process;
     

    -- Stimulus process
    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;

GTKWAVE 结果(所有信号在作业中按要求显示)

4

0 回答 0