step1:使用creat_project指令創(chuàng)建一個項目設(shè)計,產(chǎn)生這個項目的目錄,以及有關(guān)的子目錄。
具體使用的指令是create_project tcl_first //這里的tcl_first是你的項目名稱。
在你建好的項目中,有.xpr,.data,.srcs和.runs的目錄。其中.xpr和.data保存著全部項目管理的信息和狀態(tài)。在.srcs目錄下的就是源文件:RTL(verilog,VHDL,system verilog);IP核(利用import_file指令將文件放到Source_1的目錄下,或者add File);約束文件集在constrs_1:包含設(shè)計所需的全部約束文件(時序約束和物理約束);仿真文件:testbench和測試案例。使用get_filesets指令可以找到文件集,利用get_files指令可以找到文件。
step2:項目運行管理器:輸出文件的位置:DIRECTORY。
利用的工具:FLOW。
綜合運行:XST可以作為綜合工具。
運行之后可以在TCL看要求的特性:get_property。
以上是一些可能用到的指令。
利用creat_run指令產(chǎn)生運行,synth_1和impl_1的運行是自動產(chǎn)生的。
利用set_property設(shè)置運行對象的特性來配置運行。利用launch_runs指令啟動運行,利用-next_step或-to_step選項可以控制哪個步驟運行。
利用-pre_launch_script指令和-post_launch_script選項可以在進程進行之前或之后運行Tcl腳本。
利用reset_runs指令可以進行復(fù)位運行。
利用wait_on_run指令主要的vivado設(shè)計套件的進程可以等待一個運行完成。
使用open_design可以看你的設(shè)計!
step3:約束管理: 當使用launch_runs的時候啟動一個進程,后臺在開始之前讀入約束。在交互模式下,約束存放在存儲器中,可以利用report_time和report_summmary產(chǎn)生時序報告。
step4:進入實戰(zhàn),了解了這么多概念,接下來試試利用基于項目的設(shè)計流程通過產(chǎn)生設(shè)計項目,添加源文件,設(shè)置項目變量進行進程特性和實現(xiàn)設(shè)計項目四個步驟實現(xiàn)wavegen項目。
利用Tcl
修改Tcl文件
在指定位置添加Tcl命令
產(chǎn)生設(shè)計項目
DO_build.tcl
#source $script_dir / create_proj.tcl
create_proj.tcl
create_project wave_gen -part $device
set_property
target_language Verilog [current_project]
添加源文件
Do_build.tcl
#source_files $script_dir/load_files.tcl
Load_files.tcl
import_files [glob $src_dir / *]
import_files -fileset [get_fileset constrs_1] $xdc_dir / wave_gen_timing.xdc
get_timing.xdc
設(shè)置項目變量
Do_build.tcl
"#source $ script_dir/set_props.tcl"
進行進程特征
Set_props.tcl
set_property steps.synth_design. args. flatten_hierarchy full [get_runs synth_1]
實現(xiàn)設(shè)計項目
Do_build.tcl
"#source $ script_dir/implement.tcl"
Implement.tcl
wait_on_run synth_1
Do_build.tcl文件:
# This script will form the basis of a repeatable, scripted build process
# that can be used to generate complete projects.
#
# While completely scripted, the end result is an Vivado project that can be
# viewed and even manipulated by the Vivado IDE.
#
# This script will
# - Create a new directory for the build
# - the name will be build_YYMMDD_HHMMSS where YYMMDD_HHMMSS is the
#
current time
# - Change directory into that directory
# - Create a new Vivado project
# - Set the main project properties for the target device
# - Load all the # source files
# - Set appropriate process properties
# - Implement the design
#
# Get the current date/time. The result is a machine readable version of the
# the date/time (number of seconds since the epoch started)
set time_raw [clock seconds];
# Format the raw time to a date string
set date_string [clock format $time_raw -format "%y%m%d_%H%M%S"]
# Set the directory name to be build_YYMMDD_HHMMSS
set proj_dir "build_$date_string"
# Create the new build directory
puts "Creating build directory $proj_dir"
file mkdir $proj_dir
# The remaining TCL scripts live in this directory. Remember
# the path before we change directories
set script_dir [pwd]
set src_dir [pwd]/wave_gen/src
set core_dir [pwd]/wave_gen/cores
set xdc_dir [pwd]/wave_gen/constraints
# Change directories to the new build directory
puts "Changing directory to $proj_dir"
cd $proj_dir
# Source the script that will create the new project
source $script_dir/create_proj.tcl
# Source the script that will imports all the files required for the build
source $script_dir/load_files.tcl
# Source the script that will set all the process properties necessary
source $script_dir/set_props.tcl
# Source the script that will regenerate the cores and run the implementation
# process
source $script_dir/implement.tcl
以上是Tcl的模板,根據(jù)上面step4的要求對這個進行修改。
》在命令行中找到你裝的vivado的當前目錄:比如-> cd D:XilinxVivado2014.2
》接著輸入64位的 OS用戶,輸入.settings64.bat
》接著到你的tcl的目錄下,在命令行輸入:vivado - mode tcl -source do_build.tcl(若發(fā)現(xiàn)錯誤,那就再運行一次)
》如果成功,你就可以看到:
我這里看到有以下的warning:
好像說的是有新版本。
》在vivado后面輸入start_gui。
》看看Project Setting那里選的板子有沒有錯誤。然后在Tcl Console那里輸入stop_gui。在命令行那里輸入exit。
對于create_proj.tcl的修改:以下tcl是用來選板子型號和源文件的語言。我的板子是zynq-7000,所以就把下面的device那里修改了一下!這個tcl完成的是項目的創(chuàng)建工作!
# This script sets the project variables for the Kintex7 device
# assign part to device variable
set device xc7k70tfbg484-2
# Create the project
puts "Creating new project: wave_gen"
# Insert the command to create the project here
create_project wave_gen -part $device
# Insert the command to set the target language for the project here
set_property target_language Verilog [current_project]
修改完保存退出,然后在命令行執(zhí)行do_build.tcl,接著打開vivado的gui看到板子的型號已經(jīng)改了。
對于load_files.tcl,這個是用來添加源文件的tcl。
import_files [glob $src_dir/*]
這個把RTL加了進去。
import_files -fileset [get_filesets constrs_1] $xdc_dir/wave_gen_timing.xdc
這個把約束加了進去。
import_ip -files $core_dir/char_fifo.xci -name char_fifo
加入了IP核,這里會有warning的話就根據(jù)給的提示,去vivado那里看看版本問題。
create_ip -name clk_wiz -version 5.1 -vendor xilinx.com -library ip -module_name clk_core
這個是增加了時鐘。
具體代碼如下:
# This script loads all the files required by the project
puts "Adding RTL files to the project"
# Insert the command to import the RTL files form $src_dir here
import_files [glob $src_dir/*]
puts "Importing XDC file to the project"
# Insert the command to import the XDC file form $xdc_dir here
import_files -fileset [get_filesets constrs_1] $xdc_dir/wave_gen_timing.xdc
puts "Importing Char_fifo IP to the project"
import_ip -files $core_dir/char_fifo.xci -name char_fifo
puts "Adding clk_core IP to the project"
create_ip -name clk_wiz -version 5.1 -vendor xilinx.com -library ip -module_name clk_core
set_property -dict [list CONFIG.Component_Name {clk_core} CONFIG.PRIM_SOURCE {Differential_clock_capable_pin} CONFIG.PRIM_IN_FREQ {200.000} CONFIG.CLKOUT2_USED {true} CONFIG.CLKOUT1_REQUESTED_OUT_FREQ {200.000} CONFIG.CLKOUT2_REQUESTED_OUT_FREQ {193.750}] [get_ips clk_core]
對于配置文件,set_props修改如下:
# This script overrides some process properties. Only those that need to be set
# differently from the defaults will be set here
puts "Setting Synthesis and Implementation properties"
puts "Setting Flatten Hierarchy property for synth_1 run"
# Insert a command to change flatten_hierarchy property to full
set_property steps.synth_design.args.flatten_hierarchy full [get_runs synth_1]
puts "Enable power optimization for impl_1 run"
set_property steps.power_opt_design.is_enabled true [get_runs impl_1]
最后是實現(xiàn)設(shè)計項目:
implement.tcl:
# Synthesize and Implement the design
puts "synthesizing the design"
# Insert the command to launch synthesis run here
launch_runs synth_1
puts "wait until synthesis done"
# Insert the command to wait on synth_1 run here
wait_on_run synth_1
puts "Implementing the design"
launch_runs impl_1
puts "wait until Implementation done"
wait_on_run impl_1
評論