原贴地址:https://electronics.stackexchange.com/questions/59477/using-svn-with-xilinx-vivado
(回答2尚未翻译完)

问题

我刚开始使用Vivado开发一个新项目,我想把文件放在SVN里管理。

Vivado似乎按如下目录结构,在项目名称(比如proj1)目录下,创建项目文件

/<path to the project>/proj1/
                            proj1.xpr
                            proj1.srcs/
                                       constrs_1/
                                                new/
                                                    const1.xdc
                            proj1.runs/
                            proj1.data/
                            proj1.cache/

我的疸是,除了XDC和XPR文件之外,我还需要放哪些文件到SVN里?

回答1 by Mark Lakata

Xilinx 在YouTube发布了一个视频(唉)来讨论这事,链接如下

http://www.xilinx.com/training/vivado/vivado-version-control-overview.htm

以下是我对这个视频(8分钟)的概述。

开始之前

如果你真心喜欢完全的控制,Xilinx建议你彻底忘掉GUI,转面在命令行下做所有事情,这样你能区分清楚哪些文件是源代码、哪些不是。
否则,Xilinx认为Vivado项目并非为版本控制设计的,不要签入整个项目。请阅读以下提示……

基线

显而易见,所有你在Vivado工具以外编写的文件都需要签入。
(Vivado项目管理的文件里需要)签入下列文件

*.v, *.vh, *.vhdl, *.edif  - HDL and Netlist
*.xdc - Constraints
*.xci - IP Core
*.bd  - IP Integrator Block Diagram
*.xmp - Embedded Subsystem
*.sgp - System Generator Subsystem
*.bmm
*.cdc - Chipscope
*.elf
*.mem

IP核

如果你使用IP核,那么把IP生成在一个独立的目录里,然后签入所有东西。

Checkpoints

如果你希望能重新运行一部分生成流程,而不是重新生成所有东西,那么需要签入checkpoint文件。

*.dcp - Design Checkpoints

我的补遗条目

要是Xilinx工具足够高效,我才不会签入dcp文件呢。但实际上这些工具需要运行好几个小时,所以把dcp签入进来可能是值得的,代价是版本控制得很丑。
这个视频没说Vivado项目文件(*.xpr)偷偷生成的部分,以下是我的建议:

*.xpr
*.data/*/fileset.xml
*.data/*/runs.xml

Xilinx的建议的变通方式(这是个hack技巧,不适合版本控制)是每次你要提交代码之前,先运行File -> Write Project Tcl命令,然后提交生成的TCL文件到版本控制系统。之后更新了本地目录时,你可以运行这个TCL文件来生成所有项目文件。恶。

回答2 by stanri

Vivado 2014.1允许使用.tcl脚本来重建项目。
要使用这个功能,在项目打开的时候,使用File -> Write Project tcl

基本项目

我通常把我的源代码和.tcl腰带保存在项目以外的目录里。项目生成的Xilinx的IP核可以复制到任何地方,操作方式是右键单击IP核,选择Copy IP,然后删除原件。生成了TCL脚本之后,it creates relative links to these files(译注:手头没有Vivado,这句意思不明)。这是我通常使用的目录结构。

base_project/
 srcs/
  project.v
 ip/
  ip1/
   ip1.xml
   ip1.xci
 genproject.tcl

只有IP的.xml和.xci文件需要提交(并且其实技术上也不是完全必须,参见最后的注释)。

This is what gets committed to git, note the lack of project.xpr or project directories.

When I run genproject.tcl, it creates another directory for the project.

base_project/
 srcs/
 ip/
 genproject.tcl
 projectdir/
  project.runs/
  project.cache/
  project.xpr

This new folder is completely disposable. In order to create this structure, I modify the tcl script in the following way.

I change the first 3 lines as follows:

# Set the reference directory for source file relative paths
# (by default the value is script directory path)
set origin_dir [file dirname [info script]]

# Set the directory path for the original project from where this script was exported
set orig_proj_dir "[file normalize "$origin_dir/projectdir"]"

# Create project
create_project project $projectdir/project

This creates a new project directory and the new project in that dir.

Then I modify the paths to point to the correct places. You may need to change these paths in other places in the script.

# Set 'sources_1' fileset object
set obj [get_filesets sources_1]
set files [list \
 "[file normalize "$origin_dir/srcs/project.v"]"\
 "[file normalize "$origin_dir/ip/ip1/ip1.xci"]"\
]
add_files -norecurse -fileset $obj $files

I also modify the design runs for IP cores as seen in this answer.

The .wcfg files can be included in a similar way to the ip and srcs.

This is where the processing ends for more simple projects (containing only sources and IP, no block diagrams). The following needs to also be done in order to store the block diagram data.

Block Diagram Projects

In order to save the block diagram, with the block diagram open, go File -> Export -> Block Diagram to Tcl, and save it in the same dir as the other tcl file.

Then I made a Generate_Wrapper.tcl script which creates the block diagram wrapper files so you don't need to do that manually. The project/project.srcs folder is used to store the bd data, but it's still completely disposable, since the bd is stored in the tcl script. Save this with the other two.

set origin_dir [file dirname [info script]]

make_wrapper -files [get_files $origin_dir/project/project.srcs/sources_1/bd/design_1/design_1.bd] -top
add_files -norecurse -force $origin_dir/project/project.srcs/sources_1/bd/design_1/hdl/design_1_wrapper.v
update_compile_order -fileset sources_1
update_compile_order -fileset sim_1

At the end of my genproject.tcl I add the following lines to generate the block diagram and wrappers:

source $origin_dir/Create_bd.tcl
source $origin_dir/Generate_Wrapper.tcl
regenerate_bd_layout

For projects with no source (just block diagram), my git commit is just the following:

base_project/
 Generate_Wrapper.tcl
 Create_Bd.tcl
 genproject.tcl

In order to generate everything, run genproject.tcl.

You can even combine all of these into one if you are particularly efficient, I haven't got round to that yet.

Custom Components: The component project

Another quick note on creating a custom component. If you have a component.xml, add that to your tcl sources list:

  "[file normalize "$origin_dir/component.xml"]"\

And then also add the following section:

set file "$origin_dir/component.xml"
set file [file normalize $file]
set file_obj [get_files -of_objects [get_filesets sources_1] [list "*$file"]]
set_property "file_type" "IP-XACT" $file_obj

This includes the component design into the project for easy customisation.

Custom Components: Referencing your component

You can spacify your custom component repo path like this:

# Set IP repository paths
set obj [get_filesets sources_1]
set_property "ip_repo_paths" "[file normalize "$origin_dir/path/to/repository"]" $obj

In my repo folder, there are individual folders containing .xml files. So you're not referencing the folder containing the .xml, but the parent of that one. Eg:

repository/
 component1/component1.xml
 component2/component2.xml

How do we run these tcl scripts?

Open Vivado, and without opening any projects, select Tools -> Run TCL script, and navigate to your script.

Extra TCL notes

Every command you run in Vivado is shown in the tcl console as a tcl command. For example, when I generated a new Xilinx IP using the GUI, this came up in the tcl console:

create_ip -name floating_point -vendor xilinx.com -library ip -module_name floating_point_0
set_property -dict [list CONFIG.Operation_Type {Fixed_to_float} \
CONFIG.A_Precision_Type {Custom} CONFIG.C_A_Exponent_Width {38} \
CONFIG.C_A_Fraction_Width {0} CONFIG.Result_Precision_Type {Custom} \
CONFIG.C_Result_Exponent_Width {8} CONFIG.C_Result_Fraction_Width {16} \
CONFIG.Flow_Control {NonBlocking} CONFIG.Has_ARESETn {true}] \
[get_ips floating_point_0]

This means a couple of things:

You don't really even need to save xilinx ip cores - once they're the way you want them, copy the commands to the tcl script and you don't need to commit ip/ anymore.

specify the IP directory with the -dir argument after -module_name to put it wherever you'd like (in default it's in project.srcs).

Mostly anything you do in the GUI can be done in tcl, the easiest way to see how xilinx does stuff is to do it in the GUI and then look at what's in the TCL console afterwards.

This humongous pdf details all the vivado tcl commands.