2

D フリップフロップの VHDL コードと、それを構造的に使用する T フリップフロップがあります。これは、クロックである Q と T Xored された D 入力を持つ DFF で構成されています。しかし、私のシミュレーションでは、赤い直線 'U' のみを出力する波形が得られます。QからDへのフィードバックが原因だと思いますが、最初は初期化されていません。でもそれ以外の書き方がわかりません。これはコードです:

-- これは DFF です。

    library IEEE;
use IEEE.STD_LOGIC_1164.all;

entity d_flip_flop is
     port(
         clk : in STD_LOGIC;
         din : in STD_LOGIC;
         reset : in STD_LOGIC;
         dout : out STD_LOGIC
         );
end d_flip_flop;

architecture d_flip_flop_arc of d_flip_flop is    
begin

    dff : process (din,clk,reset) is
    begin
        if (reset='1') then
            dout <= '0';
        elsif (rising_edge (clk)) then
            dout <= din;
        end if;
    end process dff;


end d_flip_flop_arc;

--TFF:

    library IEEE;
use IEEE.STD_LOGIC_1164.all;

entity tff_using_dff is
     port(
         clk : in STD_LOGIC;
         t : in STD_LOGIC;
         reset : in STD_LOGIC;
         dout : out STD_LOGIC
         );
end tff_using_dff;

architecture tff_using_dff_arc of tff_using_dff is    

component d_flip_flop is
     port(
         clk : in STD_LOGIC;
         din : in STD_LOGIC;
         reset : in STD_LOGIC;
         dout : out STD_LOGIC
         );
end component d_flip_flop;

signal ip : std_logic;
signal op : std_logic;    

begin

    ip <= op xor t ;
    u0 : d_flip_flop port map (clk => clk,
                            din => ip,
                            reset => reset,
                            dout => op);

    dout <= op;


end tff_using_dff_arc;

-- そして現在のテストベンチ:

 library IEEE;
use IEEE.STD_LOGIC_1164.all;

entity T_FF_tb is
end T_FF_tb;

architecture T_FF_tb of T_FF_tb is
component tff_using_dff is 
     port(
         clk : in STD_LOGIC;
         t : in STD_LOGIC;
         reset : in STD_LOGIC;
         dout : out STD_LOGIC
         );
end component;

signal clk,t,reset: std_logic:='0';
signal dout: std_logic:='0';
begin
U0: tff_using_dff port map(clk,t,reset,dout);
clk<=not clk after 5 ns;
t<= not t after 30 ns;

end T_FF_tb;
4

2 に答える 2