CCWO Embedded Space

CCWOの日々の開発を発信するブログ

テストベンチ VHDL ファイル テンプレート

テストベンチのVHDLのテンプレートです。
私が使っているのはこんな感じです。

-----------
-- library
-----------
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_misc.all;
use IEEE.std_logic_textio.all;
use std.textio.all;


entity tb_top is
  -- empty
end tb_top;


architecture SIM of tb_top is

  component top is
  port(
    rst          : in  std_logic;        -- system reset
    clk          : in  std_logic;        -- system clock
  );
  end component;

  -- SIM
  constant system_clock_period : time := 20 ns; -- 50MHz

  signal tb_clk  : std_logic;
  signal tb_rst  : std_logic;

begin

  ---------------------------
  -- asynchronous processing
  ---------------------------
  SYSTEM_CLOCK : process
  begin
    tb_clk <= '0'; wait for system_clock_period / 2;
    tb_clk <= '1'; wait for system_clock_period / 2;
  end process ; -- SYSTEM_CLOCK

  SYSTEM_RESET : process
  begin
    tb_rst <= '1'; wait for 50 ns;
    tb_rst <= '0'; wait for 50 ns;
    tb_rst <= '1'; wait for 50 ns;
    wait;
  end process;

  ALWAYS : process
  begin

    wait for 1000 ns;

    -------------------------------------------< end simulation
    assert (false) report "Simulation end!" severity failure;
  end process ; -- ALWAYS

  U_TOP: top
  port map(
    clk   => tb_clk,
    rst   => tb_rst
  );

end SIM; -- SIM

というようなシンプルなものです。CLKとRSTをもつTopファイルを前提に作っています。
非同期でCLKとRSTの信号だけ作成して、あとはALWAYSプロセスでシーケンスに書くやりかたが多いかなと思います。