Browse Source

Generate scripts for block designs instead of using BD files

pull/7/head
Ricardo Barbedo 4 years ago
parent
commit
b87abb1f42
3 changed files with 38 additions and 18 deletions
  1. +23
    -5
      README.md
  2. +2
    -2
      scripts/git_wrapper.tcl
  3. +13
    -11
      scripts/write_project_tcl_git.tcl

+ 23
- 5
README.md View File

@ -54,17 +54,19 @@ Vivado is a pain in the ass to source control decently, so these scripts provide
│ ├── testbench │ ├── testbench
│ │ ├── *.v │ │ ├── *.v
│ │ └── *.vhd │ │ └── *.vhd
│ ├── blockdesign
│ │ ├── ui
│ │ ├── ip
│ │ ├── *.bd
│ │ └── ...
│ └── ... │ └── ...
└── vivado_project/ # Untracked generated files └── vivado_project/ # Untracked generated files
├── project_name.xpr ├── project_name.xpr
├── project_name.cache/ ├── project_name.cache/
├── project_name.hw/ ├── project_name.hw/
├── project_name.sim/ ├── 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 ### 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 #### Board part repository paths
Only board part repositories inside the project are stored in the project Only board part repositories inside the project are stored in the project


+ 2
- 2
scripts/git_wrapper.tcl View File

@ -53,7 +53,7 @@ namespace eval ::git_wrapper {
set proj_file [current_project].tcl set proj_file [current_project].tcl
# Generate project and add it # 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 puts $proj_file
exec git add $proj_file exec git add $proj_file
@ -76,6 +76,6 @@ namespace eval ::git_wrapper {
# Generate project # Generate project
set proj_file [current_project].tcl set proj_file [current_project].tcl
puts $proj_file 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
} }
} }

+ 13
- 11
scripts/write_project_tcl_git.tcl View File

@ -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 } 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 script file directory path
set a_global_vars(s_path_to_script_dir) [file normalize $file_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 out bd as a proc
write_bd_as_proc $bd_file 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 import_coln [list]
set add_file_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]] { foreach file [get_files -quiet -norecurse -of_objects [get_filesets $tcl_obj]] {
if { [file extension $file] == ".xcix" } { continue } if { [file extension $file] == ".xcix" } { continue }
# Skip direct import/add of BD files if -use_bd_files is not provided # 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 } 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 path_dirs [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
set begin [lsearch -exact $path_dirs "$proj_name.srcs"] set begin [lsearch -exact $path_dirs "$proj_name.srcs"]
set src_file [join [lrange $path_dirs $begin+1 end] "/"] set src_file [join [lrange $path_dirs $begin+1 end] "/"]


Loading…
Cancel
Save