1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Vunitでのテスト実行ファイルの作成

Posted at

はじめに

Vunitのテスト実行ファイルの作り方になります
開発環境は過去記事と同様です

ディレクトリの構造

私は下記のようなディレクトリ構造にしています

今回はベンダIPライブラリとしてXilinx ISEを使用しています
コンパイルの仕方は"GHDLでベンダのVHDLライブラリをコンパイルする"を参考にしてください

テストの実行とは無関係ですが、以下のような命名規則にしています

  • パッケージファイルはpkg_*
  • テストベンチファイルはtb_*_{test_num}
ディレクトリ構造
root
├─ run.py # テスト実行ファイル
├─ src 
│  ├─ foo
│  │  ├─ pkg_foo.vhd
│  │  ├─ name1.vhd
│  │  └─ name2.vhd
│  └─ bar
│     ├─ pkg_bar.vhd
│     ├─ name3.vhd
│     └─ name4.vhd
├─ test
│  ├─ foo
│  │  ├─ tb_name1_0.vhd
│  │  ├─ tb_name1_1.vhd
│  │  └─ tb_name2_0.vhd
│  └─ bar
│     ├─ tb_name3_0.vhd
│     └─ tb_name4_0.vhd
├─ vendors # ベンダIP
│  └─ xilinx-ise # GHDLで事前に必要なベンダIPをコンパイルする
└─ vunit_out # テスト結果

実行ファイルの書き方

Vunit - User Guideとほぼ同じ内容です

ベンダIPライブラリを追加する場合はadd_external_libraryを使います

run.py
from os.path import join, dirname
from vunit import VUnit

root = dirname(__file__)
project = VUnit.from_argv()

# ベンダIPライブラリを追加 
project.add_external_library("xilinx-ise", join(root, "vendors", "xilinx-ise"))

# コードをライブラリに追加
lib = project.add_library("lib")
lib.add_source_files(join(root, "src", "*", "*.vhd"))
lib.add_source_files(join(root, "test", "*", "*.vhd"))

# テスト実行
project.main() 

参考

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?