如何在Xilinx ISE中使用TCL提高工作效率

合集下载

如何在Xilinx ISE中使用TCL提高工作效率

如何在Xilinx ISE中使用TCL提高工作效率

使用TCL脚本可以极大地提高ISE的工作效率,省去了很多手动的鼠标点击,你只要编辑好相关的Verilog/VHDL源文件和UCF文件即可,然后运行一下.tcl文件就可以等着看结果了。

下面简要说明:第一步:新建工程文件夹,将编写好的Verilog/VHDL源文件和UCF文件及TCL文件(编写方法见下文)放入文件夹中第二步:打开ISE,单击ISE信息提示栏中的Tcl Console,在Command栏键入pwd,查看当前目录,然后键入cd命令进入到你新建的工程文件夹,例如:cd D:/new第三步:运行tcl脚本文件,键入source new.tcl(假设你的.tcl文件名为new.tcl),剩下的工作就是等待了,脚本运行完后会生成bit文件下面大致讲一下Xilinx下tcl脚本文件的编写,首先新建一个文本文件,保存为.tcl格式,将下面的内容复制进文本文件,照着修改就行了要深入学习TCL建议看Xilinx的相关文档,还有华为TCL培训教程等project new my_proj1.ise;# 新建工程project set family spartan3e;# 选择器件project set device xc3s500eproject set package fg320project set speed -4##################################################################### ########### 添加源文件##################################################################### ##########puts "Adding Source Files..."xfile add di.vhd;# 添加.vhd文件xfile add ce.vhd;# 添加.vhd文件xfile add top.ucf;# 添加.ucf文件##################################################################### ########### 设置实现选项,可根据需要自己修改##################################################################### ##########puts "Setting Project Properties..."project set "custom compile file list" "fpga_b.prj"project set "Optimization Effort" Highproject set "Cores Search Directories" ../srcproject set "Read Cores" true ;# default is true, don't need to set project set "Macro Search Path" ../srcproject set "Map Effort Level" Highproject set "Perform Timing-Driven Packing and Placement" 1project set "Place & Route Effort Level (Overall)" High# Do not generate the default post place static timing reportproject set "generate post-place & route static timing report" false##################################################################### ########### 运行设计##################################################################### ##########process run "Implement Design";# 运行Implement Designputs "Implement design done"process run "Generate Programming File";# 生成bit文件puts "Bit file ready!"#project close;# 如需关闭本工程,把本行前面的#去掉#puts "project closed!"。

Xilinx_TCL

Xilinx_TCL

Scripting Xilinx® ISE™ with TclA Tutorial based on a simple implementationDoulos - July 2008IntroductionXilinx ISE is one of the very many EDA tools that can be controlled using Tcl. Why would you want to do that? Well, on our courses I often see delegates make an edit to their source code then go and re-implement it, only to find that the synthesis/layout doesn't do the same as it did last time.This is a constant danger if repeatability depends on remembering to click on the correct boxes and menus in the user interface. If you create a command file you can run that same file many times, thus guaranteeing that you are issuing the same commands to the tool each time.There are two ways of running the script:1) Within the GUI there is a Tcl command window, in which you can source (i.e. call/run) a script.2) You can issue the command "xtclsh <scriptname>" in your DOS command window or *nix shell and avoid the overhead of a graphical interface completely.With all this in mind, we are now going to explore some of the ways in which we can drive ISE from a Tcl script. We will synthesize a small design using XST and implement it in a Spartan3e device (chosen to match the boards used with our course VHDL for FPGA Design).Input FilesThe first thing we need to do is to tell the tool which source file will be used. We want to do this in a maintainable way, and to this end all filenames are given at the top of the script.We set some Tcl variables to contain the filenames we want to use:# where all output will be createdset compile_directory spartan3e# the top-level of our HDL source:set top_name spartan3e_top# input source files:set hdl_files [ list../constants_spartan.vhd../components.vhdRest of files...]# constraints with pin placements.set constraints_file ../spartan3e_fsm.ucfA '#' signifies a comment, which last until a newline and is ignored. Well, mostly. There is some deep underlying behaviour which means it's best to follow these rules about comments:•Each comment on a separate line where # is the first character on that line•Don't include mismatched round or square brackets, and don't use curly brackets at all.The 'set' command is used to apply a value to a variable:set variable_name valueIn the setting of the variable hdl_files we used the list command to create a Tcl list from the following text strings. We could have done it simply using curly braces, like this:set hdl_files {../constants_spartan.vhd../components.vhdRest of files...}This approach has some drawbacks, especially when the list items have spaces or special characters.it's generally best to construct the list using the list command. That also allows you to uselappend and lindex commands to manipulate the list.Setting a compilation directoryNow we have the file set up, we need to have somewhere to process them. We can use the file command and its sub-command mkdir to create a directory:if {![file isdirectory $compile_directory]} {file mkdir $compile_directory}This code asks if the directory exists and if not it is created. Using $variable_name gets you the current value of that variable. You may also find file exists useful.Project creation and settingsSo, now we have a directory and we can do something there. Assuming no project exists in this directory we can go ahead and make one. Xilinx provide the project command, which includes sub-commands for the project settings and other related tasks. Let's try some:project new $proj.iseproject set family Spartan3Eproject set device xc3s500eproject set package fg320project set speed -4This is one of the strengths of Tcl: it is easy to add new commands just by writing your own procedures. Writing procedures is outside the scope of this discussion but is covered fully in the Doulos course Essential Tcl/Tk.Now we need to add some files to the project. Again, Xilinx provide a Tcl command for this: thexfile command is used to add, remove, and get information on any source files in the current ISE project. We need to add some files, but we don't really want to type out filenames again (maintainability, remember?) and we already have a list of source files. Solution is to loop through the list adding each file to the project:foreach filename $hdl_files {xfile add $filenameputs "Adding file $filename to the project."}The puts command is a simple way to write to STDOUT (usually the console/shell). Note: don't forget to add the constraints file; NGDBuild does not automatically detect .ucf files when run from Tcl. Use xfile add in the same way.Running processesBefore we run any processes, we can set process options using the project set command; see the provided script for examples and the Xilinx Development System Reference Guide for exhaustive detail.Now we can run something. Just as with the ISE graphical interface, running any given process will run any required prior processes. In our example, I can issue this commandprocess run "Generate Programming File"and the design will be synthesized and implemented first before the bitfile is created. Again, just as in the graphical interface, source and intermediate file dependencies are checked and processes are run only if required. For example, to force a implementation rerun:process run "Implement Design" -force rerun_allProgramming the deviceHere we have to change our approach, as Impact does not have a Tcl interface. However, this does allow us to explore another way of controlling applications. Impact has the ability to run a script file that consists of a series of commands. These are not Tcl commands, but we can use Tcl to construct this file. We can then run Impact from with the Tcl script. Let's see how.First we need to open a file that will become the Impact script. We do this with the open command:if {[catch {set f_id [open $impact_script_filename w]} msg]} {puts "Can't create $impact_script_filename"puts $msgexit}What's going on here? The open command returns a handle to the file which we put in the variablef_id. If open fails it would stop the script; this is probably the best thing to do here, but in general you may want to trap errors and continue with other things. That's what catch can do: it will return a non-zero error code if the command it runs (in this case the open) fails and place any error message from that command in the variable that here is called msg. Hence, if the open fails $msg will contain the reason why.At the end of this we either have a filehandle we can use or the script has stopped.How do we write text to the file? With the puts command. Earlier we used it to write text to the console, but here we see an extension:puts $f_id "addDevice -position 1 -file $bit_filename"Well, it's not really an extension. The default destination of a puts command is the standard output, so if we leave off that argument that is where it goes. The line above writes the text to the file given byf_id instead. After we have written the required command to the Impact script we should close the file.Now we have to start Impact. There are several ways of calling external programs from Tcl; the easiest is to use the exec command, which runs the external program, waits for it to finish and returns all its output. This is acceptable for quick programs but not for anything more complicated, as you cannot direct any input to the program or control it while it is running. More flexibility is provided by using the open command, but this time as a pipe from the program:set impact [open "|impact -batch $impact_script_filename" r]This line starts Impact with the script, and returns its output to the variable impact_p. The benefit of using the pipe is that we can now watch the stdout of the tool from within our Tcl script:while {![eof $impact_p]} { gets $impact_p line ; puts $line }This code writes each line of Impact's output to the Tcl script's own standard output. The command'eof' returns true when the external program finishes. If the external program requires some interaction this approach will not work, as the external program will only return true to eof when it finishes andnot when to supply some text. In our case it's OK because we want the Impact script to run until completion without interraction. We explore ways of interacting with programs in Essential Tcl/Tk. Assuming all this runs successfully you should have a working device. Congratulations!。

vivado调用tcl指令

vivado调用tcl指令

vivado调用tcl指令【实用版】目录1.引言2.Vivado 与 TCL 指令的简介3.如何在 Vivado 中调用 TCL 指令4.实际应用案例5.总结正文【引言】在 FPGA 设计和开发过程中,Vivado 是 Xilinx 公司提供的一款强大的集成开发环境(IDE),可以帮助工程师更高效地完成项目。

而在Vivado 中,可以使用 TCL(Tool Command Language)指令来进行脚本编程和自动化操作。

本文将介绍如何在 Vivado 中调用 TCL 指令,并举例说明其在实际项目中的应用。

【Vivado 与 TCL 指令的简介】Vivado 是 Xilinx 公司推出的一款针对 FPGA 和 SoC 器件的设计工具,它支持从设计输入到验证、实施和测试等全流程的开发。

Vivado 具有丰富的功能,可以满足各种复杂数字逻辑电路的设计需求。

TCL(Tool Command Language)是一种脚本语言,用于控制和自动化Xilinx 开发工具的行为。

通过编写 TCL 脚本,用户可以实现自定义操作,提高开发效率。

【如何在 Vivado 中调用 TCL 指令】要在 Vivado 中调用 TCL 指令,需要遵循以下步骤:1.打开 Vivado,并加载需要进行 TCL 指令操作的 FPGA 设计项目。

2.在 Vivado 的菜单栏中,选择“File”>“Automation”>“Create”来创建一个新的 TCL 脚本文件。

3.编写 TCL 脚本。

例如,以下脚本用于创建一个名为“my_design”的工程:```# Create a new project named "my_design"set project_name "my_design"set project_path"C:/Users/username/Documents/Vivado/Projects"create_project $project_name $project_path```4.保存 TCL 脚本,并将其与 Vivado 项目关联。

vivado tcl语句

vivado tcl语句

vivado tcl语句1. 什么是Vivado TCL语句?Vivado是一种由赛灵思公司开发的综合工具套件,用于设计和实现复杂的数字电路。

TCL(Tool Command Language)是一种脚本语言,由约翰·奥斯汀(John Ousterhout)于1988年开发,用于自动化软件任务。

在Vivado中,你可以使用TCL语句来定义和执行各种操作,例如创建设计工程,生成约束文件,运行综合和实现流程等。

2. 使用TCL语句的优势有哪些?使用TCL语句可以带来许多优势。

首先,TCL是一种脚本语言,它允许你编写一系列命令来执行复杂的任务,无需逐个手动输入命令。

这大大提高了工作效率,减少了错误的可能性。

其次,TCL语句是可编程的,这意味着你可以使用条件语句、循环和函数等控制结构来编写更加灵活和智能的代码。

你可以根据特定需求自定义脚本,以便自动执行一系列任务,而不是手动操作。

此外,TCL语句还可以与其他脚本语言和工具进行交互,例如Python和Shell脚本。

这意味着你可以在TCL脚本中调用其他脚本或工具的功能,以实现更高级的自动化和集成。

3. 如何使用Vivado TCL语句?使用Vivado TCL语句有一些基本步骤。

首先,你需要打开Vivado软件,并创建或打开一个设计工程。

在Vivado界面中,你可以打开"TCL Console"窗口,它允许你在其中输入和执行TCL命令。

接下来,你可以使用TCL语句来执行各种操作,例如创建设计工程、添加源文件、设置约束、运行综合和实现等。

可以使用"source"命令执行一个TCL脚本文件,或者逐个输入命令。

通过在命令前加上"puts"命令,你还可以打印输出结果,以便进行调试和验证。

此外,Vivado还提供了TCL命令的完整文档和参考手册,你可以在其中查找各种命令和用法的详细信息。

这些文档可以帮助你学习和理解TCL 语句的功能和用法。

后处理中常用的TCL语句

后处理中常用的TCL语句

程式尾的做法_加入加工时间和程式头的做法一样,这里就不详细说明了这里就说一下加入加工时间在自定义命令里输入如下指令global mom_machine_timeMOM_output_literal "(TIME: [ format "%.2f" $mom_machine_time] MIN)"加turbo,使后处理速度快5~6倍再在如图位置增加一个自定义命令输入以下内容uplevel #0 {set mom_kin_is_turbo_output "TRUE"MOM_reload_kinematics}加入刀具信息在弹出的对话框中输入如下指令global mom_tool_diameterglobal mom_tool_corner1_radiusglobal mom_tool_nameMOM_output_literal "( $mom_tool_name D=[format "%.2f" $mom_tool_diameter]R=[format "%.2f" $mom_tool_corner1_radius] )"注意,D和R都可以改成你方便识别的文字,也可以改成汉字,不过要你的机床能识别汉字,%.2f是输出刀具信息的精度,这个意思是小数点后面2位数,2可以改成其它数字,其它地方就不要改了主軸轉速﹕[format "%.0f" $mom_spindle_rpm]進給﹕[format %.1f $mom_feed_cut_value]加工時間﹕[ format "%.2f" $mom_machine_time]刀具名稱:$mom_tool_name刀具直徑:[ format "D=%.2f" $mom_tool_diameter]刀具R角半徑:[ format "R=%.2f" $mom_tool_corner1_radius]刀具伸出長L:[ format "L=%.2f" $mom_tool_length]刀具首下長FL:[ format "FL=%.2f" $mom_tool_flute_length]攻牙Q值的設定﹕$mom_cycle_retract_to自定程式名﹕$mom_output_file_basename內定程式名﹕$mom_group_nameglobal mom_tool_name 刀具详思信息global mom_tool_diameter mom_tool_corner1_radius mom_tool_flute_lengthmom_tool_lengthMOM_set_seq_offMOM_output_literal "(ToolName=$mom_tool_name\D=[format "%.2f" $mom_tool_diameter]\R=[format "%.2f" $mom_tool_corner1_radius]\F=[format "%.2f" $mom_tool_flute_length]\L=[format "%.2f" $mom_tool_length])"global mom_tool_nameMOM_output_literal "(TOOL: $mom_tool_name)" 程式中加刀具名global mom_group_nameMOM_output_literal "(NAME: $mom_group_name)" 程式中加程式名global mom_operation_name 程式中单节名MOM_output_literal "(Operation_Name= $mom_operation_name)"在程序尾加入的代码:#=============================================================proc MOM_end_of_program { } {#===================================================== ========global mom_stock_part mom_stock_floor (后处理加佘量 )MOM_output_literal "(Part stock=[format "%.3f" $mom_stock_part] MM \ Floor stock= [format "%.3f" $mom_stock_floor ] MM)"global mom_machine_time 加工时间MOM_output_literal "(Total Machine Time: [ format "%.2f" $mom_machine_time] minutes)"以上源代码适合各类机床。

TCL-TK实现modelsim仿真多用例顺序执行

TCL-TK实现modelsim仿真多用例顺序执行

TCL-TK实现modelsim仿真多用例顺序执行背景:随着逻辑的复杂程度的增加,逻辑的设计越来越复杂,逻辑得规模也越来越大。

在进行一个设计时候,需要多个仿真用例来对设计进行功能、异常的验证。

如果从传统的单个执行用例一个一个执行往往需要很费时间。

本文阐述的是,如何用TCL/TK实现可视化的,基于mentor公司的modelsim的仿真用例串行执行。

也就是,一次性将所有用例执行完毕,并生成测试报告。

TCL/TK编写的程序可以通过细微的改动移植到LINUX环境下。

本文的代码部分实现的是可以兼容两种系统的仿真用例串行执行程序。

本文所涉及的的工具为xilinx公司ise9.2.04,modelsim6.0d,tcl8.5。

1.设计工程准备对于一个设计工程,我们会建立相应的目录。

目录结构如下图:图1.1 工程结构图下面分别介绍各个目录的作用。

bfm文件夹存放仿真需要用的仿真接口模型,用于进行激励的输入。

lib文件夹存放仿真的库文件。

利用modlsim将xilinx库提供的器件库文件vlog。

编译后的文件放到lib/work文件夹下。

rtl文件夹存放设计的源代码,lib用于存放编译设计后的库文件。

sim文件夹用于存放设计文件代码所编译后的仿真文件。

tests文件夹下存放的是仿真用例。

在每个用例文件夹下存放着start.tcl文件,用于进行该用例的执行。

内容如下:exec vsimk –do “vmap work ../sim/work; vlog ../rtl/*.v;vlog ../bfm/*.v; vsim ../lib/work/ work.tb_design; do wave.do;p_run 5ms; quit -f”通过tcl解释器加载该文件,该用例可以自动运行,且自动退出modlsim。

如果该设计的用例数较多,务必导致,工作效率的降低。

通过tcl/tk编写的串行脚本用例,可以方便的将所有的用例串行执行完毕。

vivado tcl语法

vivado tcl语法

vivado tcl语法Vivado是一款用于FPGA设计的软件,而Tcl(Tool Command Language)是Vivado软件中用于编程和自动化的一种脚本语言。

以下是一些Vivado Tcl语法的基本概念和示例:1. 控制流程命令:`if`:例如,`if { $value == 1 } { do something }``foreach`:例如,`foreach item $list { do something }``while`:例如,`while { $condition } { do something }`2. 数组:数组可以直接赋值,例如:`set i(1) 123` 和 `set i(16) "hi"`。

支持任意维数的数组,例如:`set i(1,2,3) "hi"`,引用时直接使用`$i(1,2,3)`。

使用 `parray` 命令可以打印出数组的全部信息。

3. 目标选择与定位:Vivado中的目标可以分为五类:ports(顶层I/O)、pins(其他所有端口)、cells(各级模块、blackbox和门级元件)、nets(连线)和clocks(在XDC中定义的时钟)。

使用 `get_` 命令来选取这些目标,例如 `get_ports`、`get_cells`、`get_nets` 等。

4. 层次问题:Vivado中Tcl/XDC对网表中目标的搜索是层次化的。

搜索特定层次的目标时,可以使用 `current_instance` 命令来设置搜索的层次。

5. 其他常用命令:`create_clock`:创建一个时钟源。

`create_pin`:在IP或FPGA设备上创建一个物理引脚。

`create_task` 和 `create_process`:创建任务和进程来定义设计流程。

6. 文件操作:使用 `open` 和 `close` 命令来打开和关闭文件。

vivado调用tcl指令

vivado调用tcl指令

vivado调用tcl指令摘要:1.简介2.vivado 和tcl 指令的基本概念3.vivado 调用tcl 指令的方法4.实例演示5.总结正文:1.简介Vivado 是Xilinx 公司推出的一款FPGA 设计工具,它集成了大量的IP 核,可以方便地进行FPGA 设计。

在Vivado 中,我们可以通过调用TCL 指令来实现一些复杂的功能。

本文将详细介绍Vivado 调用TCL 指令的方法。

2.vivado 和tcl 指令的基本概念Vivado是一个基于TCL/TK的脚本语言,我们可以通过编写TCL脚本实现对Vivado的命令控制。

TCL(Tool Command Language)是一种脚本语言,用于控制不同类型的工具,它具有简单、易于学习的特点。

3.vivado 调用tcl 指令的方法在Vivado 中调用TCL 指令,主要分为以下几个步骤:步骤一:编写TCL 脚本首先,我们需要编写一个TCL 脚本文件,例如:example.tcl。

在脚本中,我们可以定义一些变量,以及实现所需功能的TCL 指令。

步骤二:设置TCL 环境打开Vivado,进入“File” -> “Setup” -> “TCL/TK Interpreter”。

在这里,我们需要设置TCL 脚本的路径,指向我们刚刚创建的example.tcl 文件。

步骤三:运行TCL 脚本在Vivado 中,我们可以通过“Run” -> “Script”来运行TCL 脚本。

在弹出的对话框中,选择我们设置好的TCL 脚本文件,点击“Run”按钮即可执行脚本。

4.实例演示下面,我们通过一个简单的实例来演示如何在Vivado 中调用TCL 指令:实例需求:创建一个简单的4 位加法器,并将结果保存到文件中。

步骤一:编写TCL 脚本创建一个名为“add4.tcl”的文件,编写以下代码:```set top_module add4_topset top_file [top_module]_wrap.vcreate_module $top_moduleset_property INTERFACE_TYPE vlnv [get_property INTERFACE_TYPE $top_module]create_module adder_4bitset_property INTERFACE_TYPE vlnv [get_property INTERFACE_TYPEadder_4bit]connect_portsset_property PACKAGE_PIN A [get_property PACKAGE_PIN A $top_module]set_property PACKAGE_PIN B [get_property PACKAGE_PIN B$top_module]set_property PACKAGE_PIN C [get_property PACKAGE_PIN C$top_module]set_property PACKAGE_PIN D [get_property PACKAGE_PIN D $top_module]set_property PACKAGE_PIN Y [get_property PACKAGE_PIN Y adder_4bit]set_property PACKAGE_PIN_NAME Y [get_propertyPACKAGE_PIN_NAME Y adder_4bit]set_property PACKAGE_PIN_DIRECTION Y inputcreate_property_array -name IO_PIN_DIRECTIONS -values "input output input input output"set_property IO_PIN_DIRECTIONS [get_propertyIO_PIN_DIRECTIONS $top_module]```步骤二:设置TCL 环境打开Vivado,进入“File” -> “Setup” -> “TCL/TK Interpreter”,设置TCL 脚本的路径为“add4.tcl”。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

使用TCL脚本可以极大地提高ISE的工作效率,省去了很多手动的鼠标点击,你只要编辑好相关的Verilog/VHDL源文件和UCF文件即可,然后运行一下.tcl文件就可以等着看结果了。

下面简要说明:
第一步:新建工程文件夹,将编写好的Verilog/VHDL源文件和UCF文件及TCL文件(编写方法见下文)放入文件夹中
第二步:打开ISE,单击ISE信息提示栏中的Tcl Console,在Command栏键入pwd,查看当前目录,然后键入cd命令进入到你新建的工程文件夹,例如:cd D:/new
第三步:运行tcl脚本文件,键入source new.tcl(假设你的.tcl文件名为new.tcl),剩下的工作就是等待了,脚本运行完后会生成bit文件
下面大致讲一下Xilinx下tcl脚本文件的编写,首先新建一个文本文件,保存为.tcl格式,将下面的内容复制进文本文件,照着修改就行了要深入学习TCL建议看Xilinx的相关文档,还有华为TCL培训教程等
project new my_proj1.ise;# 新建工程
project set family spartan3e;# 选择器件
project set device xc3s500e
project set package fg320
project set speed -4
##################################################################### ##########
# 添加源文件
##################################################################### ##########
puts "Adding Source Files..."
xfile add di.vhd;# 添加.vhd文件
xfile add ce.vhd;# 添加.vhd文件
xfile add top.ucf;# 添加.ucf文件
##################################################################### ##########
# 设置实现选项,可根据需要自己修改
##################################################################### ##########
puts "Setting Project Properties..."
project set "custom compile file list" "fpga_b.prj"
project set "Optimization Effort" High
project set "Cores Search Directories" ../src
project set "Read Cores" true ;# default is true, don't need to set project set "Macro Search Path" ../src
project set "Map Effort Level" High
project set "Perform Timing-Driven Packing and Placement" 1
project set "Place & Route Effort Level (Overall)" High
# Do not generate the default post place static timing report
project set "generate post-place & route static timing report" false
##################################################################### ##########
# 运行设计
##################################################################### ##########
process run "Implement Design";# 运行Implement Design
puts "Implement design done"
process run "Generate Programming File";# 生成bit文件
puts "Bit file ready!"
#project close;# 如需关闭本工程,把本行前面的#去掉
#puts "project closed!"。

相关文档
最新文档