From b87abb1f42330026ab7e5306ad91361396dbf16a Mon Sep 17 00:00:00 2001 From: Ricardo Barbedo Date: Sun, 12 Apr 2020 13:02:40 +0200 Subject: [PATCH] Generate scripts for block designs instead of using BD files --- README.md | 28 +++++++++++++++++++++++----- scripts/git_wrapper.tcl | 4 ++-- scripts/write_project_tcl_git.tcl | 24 +++++++++++++----------- 3 files changed, 38 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 45694d4..2c44f21 100644 --- a/README.md +++ b/README.md @@ -54,17 +54,19 @@ Vivado is a pain in the ass to source control decently, so these scripts provide │ ├── testbench │ │ ├── *.v │ │ └── *.vhd - │ ├── blockdesign - │ │ ├── ui - │ │ ├── ip - │ │ ├── *.bd - │ │ └── ... │ └── ... └── vivado_project/ # Untracked generated files ├── project_name.xpr ├── project_name.cache/ ├── project_name.hw/ ├── project_name.sim/ + ├── project_name.srcs/ + │ ├── sources_1/ + │ │ ├── bd/ # BDs are regenerated from script + │ │ │ ├── my_bd/hdl/my_bd_wrapper.{v,vhd} # BD wrappers are also regenerated + │ │ │ └── ... + │ │ └── ... + │ └── ... └── ... ``` @@ -83,6 +85,22 @@ Vivado is a pain in the ass to source control decently, so these scripts provide ### Notes +### Block design support + +If a block design is present, Tcl processes will be integrated in the project +generator file to regenerate it. + +The script will also automatically create and add the BD wrapper to the project. + +The wrapper of the `.bd` file **must** be called `${bd_name}_wrapper` +(e.g. `my_awesome_bd_wrapper` if your BD is called `my_awesome_bd`), +which is the default when creating in the GUI with `Create HDL Wrapper...`. + +The BD wrapper that is automatically generated by Vivado **must not** be +tracked by Git. If you need to manually modify the BD wrapper generated by Vivado, +you can write a handwritten wrapper to the generated wrapper and put only the +handwritten one under source control. + #### Board part repository paths Only board part repositories inside the project are stored in the project diff --git a/scripts/git_wrapper.tcl b/scripts/git_wrapper.tcl index b698251..f74fa3d 100644 --- a/scripts/git_wrapper.tcl +++ b/scripts/git_wrapper.tcl @@ -53,7 +53,7 @@ namespace eval ::git_wrapper { set proj_file [current_project].tcl # Generate project and add it - write_project_tcl_git -no_copy_sources -use_bd_files -force $proj_file + write_project_tcl_git -no_copy_sources -force $proj_file puts $proj_file exec git add $proj_file @@ -76,6 +76,6 @@ namespace eval ::git_wrapper { # Generate project set proj_file [current_project].tcl puts $proj_file - write_project_tcl_git -no_copy_sources -use_bd_files -force $proj_file + write_project_tcl_git -no_copy_sources -force $proj_file } } diff --git a/scripts/write_project_tcl_git.tcl b/scripts/write_project_tcl_git.tcl index 1f2d30f..83fe82b 100644 --- a/scripts/write_project_tcl_git.tcl +++ b/scripts/write_project_tcl_git.tcl @@ -168,17 +168,6 @@ proc write_project_tcl_git {args} { } if { [get_files -quiet *.bd] eq "" } { set a_global_vars(b_arg_use_bd_files) 1 } - - # -no_copy_sources cannot be used without -use_bd_files - if { $a_global_vars(b_arg_no_copy_srcs) && !$a_global_vars(b_arg_use_bd_files) } { - if { $a_global_vars(b_arg_quiet) } { - reset_msg_setting - } - send_msg_id Vivado-projutils-019 ERROR "This design contains BD sources. The option -no_copy_sources cannot be used without -use_bd_files.\ - Please remove -no_copy_sources if you wish to write out BD's as procs in the project tcl, otherwise add the option -use_bd_files to directly\ - include the *.bd files to the new project \n" - return - } # set script file directory path set a_global_vars(s_path_to_script_dir) [file normalize $file_path] @@ -754,6 +743,11 @@ proc wr_bd {} { # Write out bd as a proc write_bd_as_proc $bd_file + + # Add wrapper creation + set bd_filename [file tail $bd_file] + lappend l_script_data "\n# Create wrapper file for $bd_filename" + lappend l_script_data "make_wrapper -files \[get_files $bd_filename\] -import -top\n" } @@ -1616,10 +1610,18 @@ proc write_files { proj_dir proj_name tcl_obj type } { set import_coln [list] set add_file_coln [list] + # Create BD wrapper file names (without extensions) to be skipped later + set bd_wrapper_names {} + foreach bd_file [get_files *.bd] { lappend bd_wrapper_names [file rootname [file tail $bd_file]]_wrapper } + foreach file [get_files -quiet -norecurse -of_objects [get_filesets $tcl_obj]] { if { [file extension $file] == ".xcix" } { continue } # Skip direct import/add of BD files if -use_bd_files is not provided if { [file extension $file] == ".bd" && !$a_global_vars(b_arg_use_bd_files) } { continue } + + # Skip generated BD file wrappers + if { [lsearch -exact $bd_wrapper_names [file rootname [file tail $file]]] != -1 } { continue } + set path_dirs [split [string trim [file normalize [string map {\\ /} $file]]] "/"] set begin [lsearch -exact $path_dirs "$proj_name.srcs"] set src_file [join [lrange $path_dirs $begin+1 end] "/"]