GUIめんどくさい.
Quartusはコマンドラインからの操作をサポートしている[1]. しかしコンパイルやタイミング解析などでそれぞれのコマンドに分かれているうえ, ひとつひとつのコマンドが長くてめんどくさい. そこでシェルスクリプトでもっと使いやすくする. 各コマンドの詳細は参考[2]にあるので省く.
ちなみに動作環境はWindows版QuartusにWSLだ. バッチファイルは本当に使いづらいのでWSL使えるの最高.
プロジェクトの生成
プロジェクトの生成はquartus_sh --tcl_eval project_new <プロジェクト名>
でできる. プロジェクト名を指定してプロジェクトを生成し, カレントディレクトリにあるソースファイルをプロジェクトに登録している.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
quartus_sh=$(find <Quartus installation directory> -name quartus_sh.exe) | |
read -p "Enter project name:" project | |
quartussh−−tclevalprojectnewproject | |
echo -e >> $project.qsf | |
echo -e set_global_assignment -name PROJECT_OUTPUT_DIRECTORY output_files >> $project.qsf | |
find -name *.vhd | grep -v '\._' | xargs -I% echo set_global_assignment -name VHDL_FILE % >> $project.qsf | |
find -name *.bdf | grep -v '\._' | xargs -I% echo set_global_assignment -name BDF_FILE % >> $project.qsf | |
find -name *.qip | grep -v '\._' | xargs -I% echo set_global_assignment -name QIP_FILE % >> $project.qsf | |
find -name *.qsys | grep -v '\._' | xargs -I% echo set_global_assignment -name QSYS_FILE % >> $project.qsf |
verilogを含んでいないのは個人的に使わないからというだけ. grep -v '\._'
はOSX環境のせいでなぜか生成される先頭に._
がついたファイルを除外するため. 純粋なWindows機なら必要ない.
コンパイルなど
プロジェクト生成後のデバッグに必要なコマンドを一つのスクリプトにまとめた. 引数によって
- Quartus GUIの起動
- コンパイル
- シミュレーション
ができる. プロジェクト名の引数なしでプロジェクトを検索できる. 一つのディレクトリにプロジェクトを複数置く事があるのでプロジェクト名を指定できるようにもしてある.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#------------------------------------------------------------------------------ | |
# quartus | |
# Quartus command line tool on WSL | |
# | |
# Copyright (c) 2019 toms74209200 | |
# | |
# This software is released under the MIT License. | |
# http://opensource.org/licenses/mit-license.php | |
#------------------------------------------------------------------------------ | |
quartus_bin="<Quartus installation directory>" | |
if [ $# = 0 ]; then | |
if [ -f *.qpf ]; then | |
project=(find−name"∗.qpf"−printf′//' | head -1) | |
quartusbin/quartus.exeproject & | |
else | |
$quartus_bin/quartus.exe & | |
fi | |
elif [ $# = 1 ]; then | |
if [ $1 = "sh" ]; then | |
if [ -f *.qpf ]; then | |
project=(find−name"∗.qpf"−printf′//' | head -1) | |
quartusbin/quartussh.exe−−flowcompileproject | |
else | |
echo "Project is not found." | |
fi | |
elif [ $1 = "sim" ]; then | |
if [ -f *.qpf ]; then | |
project=(find−name"∗.qpf"−printf′//' | head -1) | |
quartusbin/quartussim.exeproject | |
else | |
echo "Project is not found." | |
fi | |
else | |
if [ -f $1.qpf ]; then | |
quartusbin/quartus.exe1 & | |
else | |
echo "Project is not found." | |
fi | |
fi | |
elif [ $# = 2 ]; then | |
if [ $1 = "sh" ]; then | |
if [ -f $2.qpf ]; then | |
quartusbin/quartussh.exe−−flowcompile2 | |
else | |
echo "Project is not found." | |
fi | |
elif [ $1 = "sim" ]; then | |
if [ -f $2.qpf ]; then | |
quartusbin/quartussim.exe2 | |
else | |
echo "Project is not found." | |
fi | |
else | |
echo "Invalid argument" | |
fi | |
fi |
0 件のコメント:
コメントを投稿