CCWO Embedded Space

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

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

VHDLのテストベンチのテンプレートです。
テストベンチを毎回Transcriptから対話型でやっていたら時間がかかってしまうので、doファイルのテンプレートを作って実行するのが効率的です。このやり方の場合は毎度すべて再コンパイルするのでファイルが大きくなってきたら一度doファイルですべてコンパイルし、その後は必要に応じて変更したファイルを再コンパイルするというやりかたが良いと思います。

# Echoing of Commands Executed in a Macro File
transcript on

# if Design Unit Exists, Delete the Design Unit from a Specified Library.
if {[file exists rtl_work]} {
	vdel -lib rtl_work -all
}

# Create a Design Library
vlib rtl_work

# Define a Mapping between a Logical Library Name and a Directory
vmap work rtl_work

# Compile HDL Source
# Define Path Specification
# Relative Path Specification
vcom -93 -work rtl_work {../../../../src/vhdl/top.vhd}
vcom -93 -work rtl_work {tb_top.vhd}

# Invoke VSIM Simulator
vsim -t 1ps -lib rtl_work tb_top

# Prepare Wave Display
add wave -position end  sim:/tb_top/U_TOP/rst
add wave -position end  sim:/tb_top/U_TOP/clk

# quit -force

# Loading all Signals in WLF file
log -r *

# Run Simulation until $stop or $finish
run -all

私の場合は、Quartusのプロジェクトのフォルダ構造も自分で決めているので毎回ディレクトリの相対パスも変更しなくていいのですが、自身のプロジェクトでシミュレーションする場合はパスを合わせてつかってみてください。