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 は初めてなので、ご容赦ください。

このクロノグラムを完成させる必要があり ます。デザインコードを掲載しています。そのためのテスト ベンチを作成しようとしましたが、結果は次の とおりです。

テストベンチ:

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は が true の場合にのみ実行されるため、テスト ベンチで値 1 を指定しました。また、これif EN = '1' thenは冗長なようで、 sinceENは常に 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