Xilinx VivadoによるVHDLモジュールのシミュレーション

VHDLで回路モジュールを書いた後、テストベンチでシミュレーションする方法を説明する。

テストベンチの新規作成

  • シミュレーションしたい.vhdファイルを右クリック「Add Sources」
  • 「Add or create simulation sources」をチェックし「Next」
  • 「Create File」
  • File type:「VHDL」、File name:「tb_test」(適当な名前)として「OK」
  • 「Include all design sources for simulation」をチェックし「Finish」
  • 「OK」
  • 「Yes」
  • Simulation Sourcesの中にtb_test.vhdが追加されていることを確認
  • 他のテストベンチがTop階層になっている場合、tb_test.vhdを右クリック「Set as Top」
  • 試しに「Run Simulation」「Run Behavioral Simulation」

テストベンチ(tb_test.vhd)を編集

  • テストベンチを記述
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;

entity tb_test is
end tb_test;

architecture Behavioral of tb_test is

-- シミュレーション対象のモジュールを宣言
component test
 Port (
 in_1 : in STD_LOGIC_VECTOR(7 downto 0);
 in_2 : in STD_LOGIC_VECTOR(7 downto 0);
 clk: in STD_LOGIC;
 out_1 : out STD_LOGIC_VECTOR(7 downto 0);
 );
end component;

-- モニタしたい信号と初期値を宣言
signal in_1_sim : STD_LOGIC_VECTOR(7 downto 0) := x'00';
signal in_2_sim : STD_LOGIC_VECTOR(7 downto 0) := x'00';
signal clk_sim : STD_LOGIC := '0';
signal out_1_sim : STD_LOGIC_VECTOR(7 downto 0);

begin

inst: test PORT MAP(
in_1 => in_1_sim,
in_2 => in_2_sim,
clk => clk_sim,
out_1 => out_1_sim
);

gen_clk_pix : process
begin
 clk_sim <= '1';
 wait for 10 ns;
 clk_sim <= '0';
 wait for 10 ns;
end process;

gen_ : process
begin
 out_1_sim <= out_1_sim + x"01";
 out_1_sim <= out_1_sim + x"02";
 wait for 20 ns;
end process;

end Behavioral;

シミュレーション

  • 「Run Simulation」を右クリック「Simulation Settings」
  • 「Simulation」タブで「xsim.simulate.runtime」で実行する時間を指定
  • 「Run Simulation」「Run Behavioral Simulation」