step1:使用creat_project指令創(chuàng)建一個(gè)項(xiàng)目設(shè)計(jì),產(chǎn)生這個(gè)項(xiàng)目的目錄,以及有關(guān)的子目錄。
具體使用的指令是create_project tcl_first //這里的tcl_first是你的項(xiàng)目名稱。
在你建好的項(xiàng)目中,有.xpr,.data,.srcs和.runs的目錄。其中.xpr和.data保存著全部項(xiàng)目管理的信息和狀態(tài)。在.srcs目錄下的就是源文件:RTL(verilog,VHDL,system verilog);IP核(利用import_file指令將文件放到Source_1的目錄下,或者add File);約束文件集在constrs_1:包含設(shè)計(jì)所需的全部約束文件(時(shí)序約束和物理約束);仿真文件:testbench和測(cè)試案例。使用get_filesets指令可以找到文件集,利用get_files指令可以找到文件。
step2:項(xiàng)目運(yùn)行管理器:輸出文件的位置:DIRECTORY。
利用的工具:FLOW。
綜合運(yùn)行:XST可以作為綜合工具。
運(yùn)行之后可以在TCL看要求的特性:get_property。
以上是一些可能用到的指令。
利用creat_run指令產(chǎn)生運(yùn)行,synth_1和impl_1的運(yùn)行是自動(dòng)產(chǎn)生的。
利用set_property設(shè)置運(yùn)行對(duì)象的特性來(lái)配置運(yùn)行。利用launch_runs指令啟動(dòng)運(yùn)行,利用-next_step或-to_step選項(xiàng)可以控制哪個(gè)步驟運(yùn)行。
利用-pre_launch_script指令和-post_launch_script選項(xiàng)可以在進(jìn)程進(jìn)行之前或之后運(yùn)行Tcl腳本。
利用reset_runs指令可以進(jìn)行復(fù)位運(yùn)行。
利用wait_on_run指令主要的vivado設(shè)計(jì)套件的進(jìn)程可以等待一個(gè)運(yùn)行完成。
使用open_design可以看你的設(shè)計(jì)!
step3:約束管理: 當(dāng)使用launch_runs的時(shí)候啟動(dòng)一個(gè)進(jìn)程,后臺(tái)在開(kāi)始之前讀入約束。在交互模式下,約束存放在存儲(chǔ)器中,可以利用report_time和report_summmary產(chǎn)生時(shí)序報(bào)告。
step4:進(jìn)入實(shí)戰(zhàn),了解了這么多概念,接下來(lái)試試?yán)没陧?xiàng)目的設(shè)計(jì)流程通過(guò)產(chǎn)生設(shè)計(jì)項(xiàng)目,添加源文件,設(shè)置項(xiàng)目變量進(jìn)行進(jìn)程特性和實(shí)現(xiàn)設(shè)計(jì)項(xiàng)目四個(gè)步驟實(shí)現(xiàn)wavegen項(xiàng)目。
利用Tcl
修改Tcl文件
在指定位置添加Tcl命令
產(chǎn)生設(shè)計(jì)項(xiàng)目
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è)置項(xiàng)目變量
Do_build.tcl
"#source $ script_dir/set_props.tcl"
進(jìn)行進(jìn)程特征
Set_props.tcl
set_property steps.synth_design. args. flatten_hierarchy full [get_runs synth_1]
實(shí)現(xiàn)設(shè)計(jì)項(xiàng)目
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的要求對(duì)這個(gè)進(jìn)行修改。
》在命令行中找到你裝的vivado的當(dāng)前目錄:比如-> cd D:XilinxVivado2014.2
》接著輸入64位的 OS用戶,輸入.settings64.bat
》接著到你的tcl的目錄下,在命令行輸入:vivado - mode tcl -source do_build.tcl(若發(fā)現(xiàn)錯(cuò)誤,那就再運(yùn)行一次)
》如果成功,你就可以看到:
我這里看到有以下的warning:
好像說(shuō)的是有新版本。
》在vivado后面輸入start_gui。
》看看Project Setting那里選的板子有沒(méi)有錯(cuò)誤。然后在Tcl Console那里輸入stop_gui。在命令行那里輸入exit。
對(duì)于create_proj.tcl的修改:以下tcl是用來(lái)選板子型號(hào)和源文件的語(yǔ)言。我的板子是zynq-7000,所以就把下面的device那里修改了一下!這個(gè)tcl完成的是項(xiàng)目的創(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,接著打開(kāi)vivado的gui看到板子的型號(hào)已經(jīng)改了。
對(duì)于load_files.tcl,這個(gè)是用來(lái)添加源文件的tcl。
import_files [glob $src_dir/*]
這個(gè)把RTL加了進(jìn)去。
import_files -fileset [get_filesets constrs_1] $xdc_dir/wave_gen_timing.xdc
這個(gè)把約束加了進(jìn)去。
import_ip -files $core_dir/char_fifo.xci -name char_fifo
加入了IP核,這里會(huì)有warning的話就根據(jù)給的提示,去vivado那里看看版本問(wèn)題。
create_ip -name clk_wiz -version 5.1 -vendor xilinx.com -library ip -module_name clk_core
這個(gè)是增加了時(shí)鐘。
具體代碼如下:
# 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]
對(duì)于配置文件,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]
最后是實(shí)現(xiàn)設(shè)計(jì)項(xiàng)目:
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
評(píng)論
查看更多