LoginSignup
17
15

More than 3 years have passed since last update.

Vivadoで論理合成と配置配線を実行するTclスクリプト

Last updated at Posted at 2016-01-14

はじめに

Xilinx 社のFPGA開発環境の Vivado、いちいち GUI でマウスボタンをポチポチするのは面倒です。
Vivado は Tcl スクリプトでバッチ処理が出来るので、決まり切った仕事なら Tcl スクリプトを書いて処理させたほうが楽です。
この記事では、Vivado で論理合成と配置配線を実行するTclスクリプトを解説します。

環境

  • Xilinx Vivado 2015.4
  • Xilinx Vivado 2016.4
  • Xilinx Vivado 2017.1
  • Xilinx Vivado 2017.2
  • Xilinx Vivado 2018.3
  • Xilinx Vivado 2019.1
  • Xilinx Vivado 2019.2 (Vitis)

Tclスクリプトの説明

1 プロジェクトを開く

このスクリプトではすでにプロジェクトが作られていることを前提にしています。
変数 project_name にプロジェクト名を、変数 project_directory にプロジェクトのあるディレクトリを設定しておきます。
この例では、project_name に "project" を、project_directory にTclスクリプトのあるディレクトリを指定しています。
project_directory をカレントディレクトリにしておいた方が、間違いがなくて良いでしょう。

implementation.tcl
set project_directory   [file dirname [info script]]
set project_name        "project"

cd $project_directory
open_project [file join $project_directory $project_name]

2 論理合成(Synthesis)を行う

Vivado では論理合成(Synthesis)と配置配線(Implementation)の各工程を Design Run という単位で管理しています。
ここではプロジェクト生成時に作っておいた論理合成用の Design Run synth_1 を実行します。

なお、launch_runs コマンドは指定した Design Run をバックグラウンドで実行するように指示するだけで、指示し終えたらすぐに戻ってきます。論理合成が終わってからでないと次の工程(配置配線)に進めないので、wait_on_run コマンドで Design Run synth_1 が終了するのを待ちます。

implementation.tcl
launch_runs synth_1
wait_on_run synth_1

3 配置配線(Implementation)を行う

論理合成(Synthesis)と同じように Design Run impl_1 を実行します。

implementation.tcl
launch_runs impl_1
wait_on_run impl_1

4 配置配線(Implementation)の結果をレポートする

配置配線(Implementation)後にタイミング違反や使用したリソースを確認したい場合は次のようにしてレポートを出力します。
特にタイミング違反をチェックするのは重要です。

implementation.tcl
open_run    impl_1
report_utilization -file [file join $project_directory "project.rpt" ]
report_timing      -file [file join $project_directory "project.rpt" ] -append

5 ビットストリームファイルを生成する

ビットストリームの生成は Design Run impl_1 を -to_step write_bitstream オプションをつけて実行することで行います。

implementation.tcl
launch_runs impl_1 -to_step write_bitstream -job 4
wait_on_run impl_1

6 プロジェクトを閉じる

implementation.tcl
close_project

Tclスクリプトの実行

Vivado のバッチモードで実行する

Tclスクリプトを Vivado のバッチモードで実行する場合は次のようにします。

shell% vivado -mode batch -source implementation.tcl

Vivado の GUIモードから実行する

Tclスクリプトを Vivado のGUIモードから動かす場合は次のようにします。

Vivado > Tools > Run Tcl Script... > implementation.tcl

Tclスクリプトサンプル

implementation.tcl
#
# implementation.tcl  Tcl script for implementation
#
set     project_directory   [file dirname [info script]]
set     project_name        "project"
#
# Open Project
#
open_project [file join $project_directory $project_name]
#
# Run Synthesis
#
launch_runs synth_1
wait_on_run synth_1
#
# Run Implementation
#
launch_runs impl_1
wait_on_run impl_1
open_run    impl_1
report_utilization -file [file join $project_directory "project.rpt" ]
report_timing      -file [file join $project_directory "project.rpt" ] -append
#
# Write Bitstream File
#
launch_runs impl_1 -to_step write_bitstream -job 4
wait_on_run impl_1
#
# Close Project
#
close_project

参考

17
15
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
17
15