FPGAで計測アプリを作るときに、お客様によってフィルタを入れたり、トリガの構成が異なったりという細かな違いはよくあることでしょう。
そういう顧客ニーズによって少しずつ構成が変わるようなデザインをVivadoで作りたい・・と思い、「Vivadoのプロジェクトを自動生成する方法」をアルバイトの学生さんに編み出してもらいました。
まず、top_script.cmdというバッチファイルと、project_generator.tclというTCLファイルを用意します。
top_script.cmdの中身は
C:\Xilinx\Vivado\2016.4\bin\vivado -mode batch -nojournal -nolog -notrace -source ./project_generator.tcl
です。これはVivadoをバッチモードで起動して、TCLファイルを読みだしているだけです。
起動してみると、
このようなメッセージが出て、何やらVivadoのプロジェクトができています。
起動してみると、こんなBlock Designができていました。
project_generator.tclの中では、まず、プロジェクト用のディレクトリと、プロジェクトファイルを生成しています。
file mkdir bd_gen_test00
cd ./bd_gen_test00
create_project bd_gen_test00 . -part xc7z010clg400-1
set_property target_language VHDL [current_project]
create_bd_design "design_1"
create_bd_cell -type hier hier_0
次にRTLのソースファイルをデザインに追加します。
add_files ../../src/moduleA.vhd
add_files ../../src/moduleB.v
create_bd_cell -type module -reference moduleA moduleA_0
create_bd_cell -type module -reference moduleB moduleB_0
RTLモジュールBを階層の中へ移動
move_bd_cells [get_bd_cells hier_0] [get_bd_cells moduleB_0]
RTLモジュールBの中のピンC_iとモジュールAのAA_oを接続
connect_bd_net [get_bd_pins moduleA_0/AA_o] [get_bd_pins hier_0/moduleB_0/C_i]
レポジトリのディレクトリを指定
set_property ip_repo_paths ../../ip_repo [current_project]
IPカタログを更新
update_ip_catalog
自分のIPを追加
startgroup
create_bd_cell -type ip -vlnv xilinx.com:user:myip_AXI_S_master:1.0 myip_AXI_S_master_0
create_bd_cell -type ip -vlnv xilinx.com:user:myip_AXI_S_slave:1.0 myip_AXI_S_slave_0
追加したIPを階層の中へ移動
move_bd_cells [get_bd_cells hier_0] [get_bd_cells myip_AXI_S_slave_0]
モジュール間の配線を行う
connect_bd_intf_net [get_bd_intf_pins myip_AXI_S_master_0/M00_AXIS] [get_bd_intf_pins hier_0/myip_AXI_S_slave_0/S00_AXIS]
外部接続ピンを作成し、接続
create_bd_port -dir I -type rst m00_axis_aresetn
connect_bd_net [get_bd_pins /myip_AXI_S_master_0/m00_axis_aresetn] [get_bd_ports m00_axis_aresetn]
create_bd_port -dir I -type clk m00_axis_aclk
connect_bd_net [get_bd_pins /myip_AXI_S_master_0/m00_axis_aclk] [get_bd_ports m00_axis_aclk]
connect_bd_net [get_bd_pins myip_AXI_S_master_0/m00_axis_aresetn] [get_bd_pins hier_0/myip_AXI_S_slave_0/s00_axis_aresetn]
connect_bd_net [get_bd_pins hier_0/myip_AXI_S_slave_0/s00_axis_aclk] [get_bd_pins myip_AXI_S_master_0/m00_axis_aclk]
endgroup
レイアウトを再生成
regenerate_bd_layout
トップのラッパファイルを作成
make_wrapper -files [get_files ./bd_gen_test00.srcs/sources_1/bd/design_1/design_1.bd] -top
add_files -norecurse ./bd_gen_test00.srcs/sources_1/bd/design_1/hdl/design_1_wrapper.vhd
要するに、人が手作業でBlockDesignを作るときのやり方をtclファイルにして、それを実行させているのです。Tckコマンドの与え方は、VivadoでTcl Consoleを見ているとわかります。
やり方がわかってくれば、Tclのコマンドをテキストエディタでコピペして作ることができるようになって、こんなデザインでも自動的に作れるようになります。
最近のコメント