インテル® Quartus® Prime プロ・エディション ユーザーガイド: スクリプティング

ID 683432
日付 9/24/2018
Public
ドキュメント目次

1.10.5.1. cmdlineパッケージの使用

より堅固で自己文書化されたコマンドライン引数の引渡しには、 インテル® Quartus® Prime開発ソフトウェアに含まれるcmdlineパッケージを使用することができます。cmdlineパッケージは、-<option><value> の形式のコマンドライン引数をサポートしています。

cmdlineパッケージ

package require cmdline
variable ::argv0 $::quartus(args)
set options {
   { "project.arg" "" "Project name" }
   { "frequency.arg" "" "Frequency" }
}
set usage "You need to specify options and values"
array set optshash [::cmdline::getoptions ::argv $options $usage]
puts "The project name is $optshash(project)"
puts "The frequency is $optshash(frequency)"

これらのコマンドをprint_cmd_args.tclという名前のTclスクリプトに保存した場合、次に示すコマンドをコマンドプロンプトで入力したとき、次の出力が表示されます。

スクリプトへのコマンドライン引数の引渡し

quartus_sh -t print_cmd_args.tcl -project my_project -frequency 100MHz
The project name is my_project
The frequency is 100MHz

実質的に、すべての インテル® Quartus® Prime Tclスクリプトは、プロジェクトを開くことを必要とします。プロジェクトを開き、オプションで、次の例のようなコードでリビジョン名を指定することができます。この例では、指定したプロジェクトが存在するかどうかを確認します。存在する場合は、現在のリビジョン、または指定したリビジョンを開きます。

フル機能でプロジェクトを開くための方法

package require cmdline
variable ::argv0 $::quartus(args)
set options { \
{ "project.arg" "" "Project Name" } \
{ "revision.arg" "" "Revision Name" } \
}
array set optshash [::cmdline::getoptions ::argv0 $options]
# Ensure the project exists before trying to open it
if {[project_exists $optshash(project)]} {
	if {[string equal "" $optshash(revision)]} {
		# There is no revision name specified, so default
		# to the current revision
		project_open $optshash(project) -current_revision
	} else {
		# There is a revision name specified, so open the
		# project with that revision
		project_open $optshash(project) -revision \
			$optshash(revision)
	}
} else {
	puts "Project $optshash(project) does not exist"
	exit 1
}
# The rest of your script goes here

このような柔軟性またはエラー・チェックが必要ない場合、次に示すように、単純にproject_openコマンドを使用することもできます。

簡単にプロジェクトを開くための方法

set proj_name [lindex $argv 0]
project_open $proj_name