You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2848 lines
104 KiB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
  1. ####################################################################################
  2. #
  3. # write_project_tcl.tcl (write a Vivado project tcl script for re-creating project)
  4. #
  5. # Script created on 02/08/2013 by Raj Klair (Xilinx, Inc.)
  6. #
  7. # 2014.2 - v2.0 (rev 4)
  8. # * do not return value from main proc
  9. # * fixed bug with relative file path calculation (break from loop while comparing
  10. # directory elements of file paths for file to make relative to o/p script dir)
  11. # 2014.1 - v2.0 (rev 3)
  12. # * make source file paths relative to script output directory
  13. #
  14. # 2013.4 -
  15. # 2013.3 -
  16. # 2013.2 - v1.0 (rev 2)
  17. # * no change
  18. #
  19. # 2013.1 - v1.0 (rev 1)
  20. # * initial version
  21. #
  22. ####################################################################################
  23. #
  24. # Modified version to better support revision control.
  25. # Can be called as write_project_tcl_git from the tcl console in Vivado.
  26. #
  27. # Differences:
  28. #
  29. # 1. The project directory is now relative to the scripts location.
  30. # Project directory was relative to the tcl console current directory.
  31. #
  32. # 2. When recreating a project, the generated files will be put in a "vivado_project" directory
  33. # under the top directory. If "vivado_project" exists already, it will be rewritten.
  34. #
  35. # 3. After recreating a project, the tcl console will change directory to the project directory.
  36. #
  37. # 4. No mention to the creation time of the project script, so that it is not different
  38. # every time it is generated.
  39. #
  40. ####################################################################################
  41. package require Vivado 1.2014.1
  42. namespace eval ::custom {
  43. namespace export write_project_tcl_git
  44. }
  45. namespace eval ::custom {
  46. proc write_project_tcl_git {args} {
  47. # Summary:
  48. # Export Tcl script for re-creating the current project
  49. # Argument Usage:
  50. # [-paths_relative_to <arg> = Script output directory path]: Override the reference directory variable for source file relative paths
  51. # [-origin_dir_override <arg>]: Set 'origin_dir' directory variable to the specified value (Default is value specified with the -paths_relative_to switch)
  52. # [-target_proj_dir <arg> = Current project directory path]: Directory where the project needs to be restored
  53. # [-force]: Overwrite existing tcl script file
  54. # [-all_properties]: Write all properties (default & non-default) for the project object(s)
  55. # [-no_copy_sources]: Do not import sources even if they were local in the original project
  56. # [-absolute_path]: Make all file paths absolute wrt the original project directory
  57. # [-dump_project_info]: Write object values
  58. # [-use_bd_files ]: Use BD sources directly instead of writing out procs to create them
  59. # [-internal]: Print basic header information in the generated tcl script
  60. # file: Name of the tcl script file to generate
  61. # Return Value:
  62. # true (0) if success, false (1) otherwise
  63. # Categories: xilinxtclstore, projutils
  64. # reset global variables
  65. variable a_global_vars
  66. reset_global_vars
  67. # process options
  68. for {set i 0} {$i < [llength $args]} {incr i} {
  69. set option [string trim [lindex $args $i]]
  70. switch -regexp -- $option {
  71. "-paths_relative_to" {
  72. incr i;
  73. if { [regexp {^-} [lindex $args $i]] } {
  74. send_msg_id Vivado-projutils-021 ERROR "Missing value for the $option option.\
  75. Please provide a valid path/directory name immediately following '$option'"
  76. return
  77. }
  78. set a_global_vars(s_relative_to) [file normalize [lindex $args $i]]
  79. }
  80. "-target_proj_dir" {
  81. incr i;
  82. if { [regexp {^-} [lindex $args $i]] } {
  83. send_msg_id Vivado-projutils-021 ERROR "Missing value for the $option option.\
  84. Please provide a valid path/directory name immediately following '$option'"
  85. return
  86. }
  87. set a_global_vars(s_target_proj_dir) [lindex $args $i]
  88. }
  89. "-origin_dir_override" { incr i;set a_global_vars(s_origin_dir_override) [lindex $args $i] }
  90. "-force" { set a_global_vars(b_arg_force) 1 }
  91. "-all_properties" { set a_global_vars(b_arg_all_props) 1 }
  92. "-no_copy_sources" { set a_global_vars(b_arg_no_copy_srcs) 1 }
  93. "-absolute_path" { set a_global_vars(b_absolute_path) 1 }
  94. "-dump_project_info" { set a_global_vars(b_arg_dump_proj_info) 1 }
  95. "-use_bd_files" { set a_global_vars(b_arg_use_bd_files) 1 }
  96. "-internal" { set a_global_vars(b_internal) 1 }
  97. default {
  98. # is incorrect switch specified?
  99. if { [regexp {^-} $option] } {
  100. send_msg_id Vivado-projutils-001 ERROR "Unknown option '$option', please type 'write_project_tcl -help' for usage info.\n"
  101. return
  102. }
  103. set a_global_vars(script_file) $option
  104. }
  105. }
  106. }
  107. # script file is a must
  108. if { [string equal $a_global_vars(script_file) ""] } {
  109. send_msg_id Vivado-projutils-002 ERROR "Missing value for option 'file', please type 'write_project_tcl -help' for usage info.\n"
  110. return
  111. }
  112. # should not be a directory
  113. if { [file isdirectory $a_global_vars(script_file)] } {
  114. send_msg_id Vivado-projutils-003 ERROR "The specified filename is a directory ($a_global_vars(script_file)), please type 'write_project_tcl -help' for usage info.\n"
  115. return
  116. }
  117. # check extension
  118. if { [file extension $a_global_vars(script_file)] != ".tcl" } {
  119. set a_global_vars(script_file) $a_global_vars(script_file).tcl
  120. }
  121. set a_global_vars(script_file) [file normalize $a_global_vars(script_file)]
  122. # error if file directory path does not exist
  123. set file_path [file dirname $a_global_vars(script_file)]
  124. if { ! [file exists $file_path] } {
  125. set script_filename [file tail $a_global_vars(script_file)]
  126. send_msg_id Vivado-projutils-013 ERROR "Directory in which file ${script_filename} is to be written does not exist \[$a_global_vars(script_file)\]\n"
  127. return
  128. }
  129. # recommend -force if file exists
  130. if { [file exists $a_global_vars(script_file)] && !$a_global_vars(b_arg_force) } {
  131. send_msg_id Vivado-projutils-004 ERROR "Tcl Script '$a_global_vars(script_file)' already exist. Use -force option to overwrite.\n"
  132. return
  133. }
  134. if { [get_files -quiet *.bd] eq "" } { set a_global_vars(b_arg_use_bd_files) 1 }
  135. # -no_copy_sources cannot be used without -use_bd_files
  136. if { $a_global_vars(b_arg_no_copy_srcs) && !$a_global_vars(b_arg_use_bd_files) } {
  137. send_msg_id Vivado-projutils-019 ERROR "This design contains BD sources. The option -no_copy_sources cannot be used without -use_bd_files.\
  138. 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\
  139. include the *.bd files to the new project \n"
  140. return
  141. }
  142. # set script file directory path
  143. set a_global_vars(s_path_to_script_dir) [file normalize $file_path]
  144. # now write
  145. if {[write_project_tcl_script]} {
  146. return
  147. }
  148. }
  149. }
  150. namespace eval ::custom {
  151. #
  152. # write_project_tcl tcl script argument & file handle vars
  153. #
  154. variable a_global_vars
  155. variable l_script_data [list]
  156. variable l_local_files [list]
  157. variable l_remote_files [list]
  158. variable b_project_board_set 0
  159. # set file types to filter
  160. variable l_filetype_filter [list]
  161. # Setup filter for non-user-settable filetypes
  162. set l_filetype_filter [list "ip" "ipx" "embedded design sources" "elf" "coefficient files" "configuration files" \
  163. "block diagrams" "block designs" "dsp design sources" "text" \
  164. "design checkpoint" "waveform configuration file"]
  165. # ip file extension types
  166. variable l_valid_ip_extns [list]
  167. set l_valid_ip_extns [list ".xci" ".bd" ".slx"]
  168. # set fileset types
  169. variable a_fileset_types
  170. set a_fileset_types {
  171. {{DesignSrcs} {srcset}}
  172. {{BlockSrcs} {blockset}}
  173. {{Constrs} {constrset}}
  174. {{SimulationSrcs} {simset}}
  175. }
  176. proc reset_global_vars {} {
  177. # Summary: initializes global namespace vars
  178. # This helper command is used to reset the variables used in the script.
  179. # Argument Usage:
  180. # none
  181. # Return Value:
  182. # None
  183. variable a_global_vars
  184. set a_global_vars(s_relative_to) {.}
  185. set a_global_vars(s_path_to_script_dir) ""
  186. set a_global_vars(s_origin_dir_override) ""
  187. set a_global_vars(s_target_proj_dir) ""
  188. set a_global_vars(b_arg_force) 0
  189. set a_global_vars(b_arg_no_copy_srcs) 0
  190. set a_global_vars(b_absolute_path) 0
  191. set a_global_vars(b_internal) 0
  192. set a_global_vars(b_arg_all_props) 0
  193. set a_global_vars(b_arg_dump_proj_info) 0
  194. set a_global_vars(b_local_sources) 0
  195. set a_global_vars(curr_time) [clock format [clock seconds]]
  196. set a_global_vars(fh) 0
  197. set a_global_vars(dp_fh) 0
  198. set a_global_vars(def_val_fh) 0
  199. set a_global_vars(script_file) ""
  200. if { [get_param project.enableMergedProjTcl] } {
  201. set a_global_vars(b_arg_use_bd_files) 0
  202. } else {
  203. set a_global_vars(b_arg_use_bd_files) 1
  204. }
  205. set l_script_data [list]
  206. set l_local_files [list]
  207. set l_remote_files [list]
  208. }
  209. proc write_project_tcl_script {} {
  210. # Summary: write project script
  211. # This helper command is used to script help.
  212. # Argument Usage:
  213. # none
  214. # Return Value:
  215. # true (0) if success, false (1) otherwise
  216. variable a_global_vars
  217. variable l_script_data
  218. variable l_remote_files
  219. variable l_local_files
  220. variable temp_dir
  221. variable temp_offset 1
  222. variable clean_temp
  223. variable l_open_bds [list]
  224. variable l_added_bds
  225. set l_script_data [list]
  226. set l_local_files [list]
  227. set l_remote_files [list]
  228. set l_open_bds [list]
  229. set l_added_bds [list]
  230. # Create temp directory (if required) for BD procs
  231. set temp_dir [ file join [file dirname $a_global_vars(script_file)] .Xiltemp ]
  232. set clean_temp 1
  233. if { [file isdirectory $temp_dir] || $a_global_vars(b_arg_use_bd_files) } {
  234. set clean_temp 0
  235. } else {
  236. file mkdir $temp_dir
  237. }
  238. # get the project name
  239. set tcl_obj [current_project]
  240. set proj_name [file tail [get_property name $tcl_obj]]
  241. set proj_dir [get_property directory $tcl_obj]
  242. set part_name [get_property part $tcl_obj]
  243. # output file script handle
  244. set file $a_global_vars(script_file)
  245. if {[catch {open $file w} a_global_vars(fh)]} {
  246. send_msg_id Vivado-projutils-005 ERROR "failed to open file for write ($file)\n"
  247. return 1
  248. }
  249. # dump project in canonical form
  250. if { $a_global_vars(b_arg_dump_proj_info) } {
  251. set dump_file [file normalize [file join $a_global_vars(s_path_to_script_dir) ${proj_name}_dump.txt]]
  252. if {[catch {open $dump_file w} a_global_vars(dp_fh)]} {
  253. send_msg_id Vivado-projutils-006 ERROR "failed to open file for write ($dump_file)\n"
  254. return 1
  255. }
  256. # default value output file script handle
  257. set def_val_file [file normalize [file join $a_global_vars(s_path_to_script_dir) ${proj_name}_def_val.txt]]
  258. if {[catch {open $def_val_file w} a_global_vars(def_val_fh)]} {
  259. send_msg_id Vivado-projutils-007 ERROR "failed to open file for write ($file)\n"
  260. return 1
  261. }
  262. }
  263. # explicitly update the compile order for current source/simset, if following conditions are met
  264. if { {All} == [get_property source_mgmt_mode [current_project]] &&
  265. {0} == [get_property is_readonly [current_project]] &&
  266. {RTL} == [get_property design_mode [current_fileset]] } {
  267. # re-parse source fileset compile order for the current top
  268. if {[llength [get_files -quiet -compile_order sources -used_in synthesis]] > 1} {
  269. update_compile_order -fileset [current_fileset] -quiet
  270. }
  271. # re-parse simlulation fileset compile order for the current top
  272. if {[llength [get_files -quiet -compile_order sources -used_in simulation]] > 1} {
  273. update_compile_order -fileset [current_fileset -simset] -quiet
  274. }
  275. }
  276. # writer helpers
  277. wr_create_project $proj_dir $proj_name $part_name
  278. wr_project_properties $proj_dir $proj_name
  279. wr_filesets $proj_dir $proj_name
  280. wr_prflow $proj_dir $proj_name
  281. if { !$a_global_vars(b_arg_use_bd_files) } {
  282. wr_bd
  283. }
  284. wr_runs $proj_dir $proj_name
  285. wr_proj_info $proj_name
  286. # write header
  287. write_header $proj_dir $proj_name $file
  288. # write script data
  289. foreach line $l_script_data {
  290. puts $a_global_vars(fh) $line
  291. }
  292. close $a_global_vars(fh)
  293. if { $a_global_vars(b_arg_dump_proj_info) } {
  294. close $a_global_vars(def_val_fh)
  295. close $a_global_vars(dp_fh)
  296. }
  297. set script_filename [file tail $file]
  298. set out_dir [file dirname [file normalize $file]]
  299. send_msg_id Vivado-projutils-008 INFO "Tcl script '$script_filename' generated in output directory '$out_dir'\n\n"
  300. if { $a_global_vars(b_absolute_path) } {
  301. send_msg_id Vivado-projutils-016 INFO "Please note that the -absolute_path switch was specified, hence the project source files will be referenced using\n\
  302. absolute path only, in the generated script. As such, the generated script will only work in the same filesystem where those absolute paths are accessible."
  303. } else {
  304. if { "." != $a_global_vars(s_relative_to) } {
  305. if { {} == $a_global_vars(s_origin_dir_override) } {
  306. send_msg_id Vivado-projutils-017 INFO "Please note that the -paths_relative_to switch was specified, hence the project source files will be referenced\n\
  307. wrt the path that was specified with this switch. The 'origin_dir' variable is set to this path in the generated script."
  308. } else {
  309. send_msg_id Vivado-projutils-017 INFO "Please note that the -paths_relative_to switch was specified, hence the project source files will be referenced wrt the\n\
  310. path that was specified with this switch. The 'origin_dir' variable is set to '$a_global_vars(s_origin_dir_override)' in the generated script."
  311. }
  312. } else {
  313. send_msg_id Vivado-projutils-015 INFO "Please note that by default, the file path for the project source files were set wrt the 'origin_dir' variable in the\n\
  314. generated script. When this script is executed from the output directory, these source files will be referenced wrt this 'origin_dir' path value.\n\
  315. In case this script was later physically moved to a different directory, the 'origin_dir' value MUST be set manually in the script with the path\n\
  316. relative to the new output directory to make sure that the source files are referenced correctly from the original project. You can also set the\n\
  317. 'origin_dir' automatically by setting the 'origin_dir_loc' variable in the tcl shell before sourcing this generated script. The 'origin_dir_loc'\n\
  318. variable should be set to the path relative to the new output directory. Alternatively, if you are sourcing the script from the Vivado command line,\n\
  319. then set the origin dir using '-tclargs --origin_dir <path>'. For example, 'vivado -mode tcl -source $script_filename -tclargs --origin_dir \"..\"\n"
  320. }
  321. }
  322. if { $a_global_vars(b_local_sources) } {
  323. print_local_file_msg "warning"
  324. } else {
  325. print_local_file_msg "info"
  326. }
  327. reset_global_vars
  328. return 0
  329. }
  330. proc wr_create_project { proj_dir name part_name } {
  331. # Summary: write create project command
  332. # This helper command is used to script help.
  333. # Argument Usage:
  334. # proj_dir: project directory path
  335. # name: project name
  336. # Return Value:
  337. # none
  338. variable a_global_vars
  339. variable l_script_data
  340. lappend l_script_data "# Set the reference directory for source file relative paths (by default the value is script directory path)"
  341. lappend l_script_data "set origin_dir \[file dirname \[info script\]\]"
  342. lappend l_script_data ""
  343. set var_name "origin_dir_loc"
  344. lappend l_script_data "# Use origin directory path location variable, if specified in the tcl shell"
  345. lappend l_script_data "if \{ \[info exists ::$var_name\] \} \{"
  346. lappend l_script_data " set origin_dir \$::$var_name"
  347. lappend l_script_data "\}"
  348. lappend l_script_data ""
  349. set var_name "user_project_name"
  350. lappend l_script_data "# Set the project name\nset project_name \"$name\"\n"
  351. lappend l_script_data "# Use project name variable, if specified in the tcl shell"
  352. lappend l_script_data "if \{ \[info exists ::$var_name\] \} \{"
  353. lappend l_script_data " set project_name \$::$var_name"
  354. lappend l_script_data "\}\n"
  355. lappend l_script_data "variable script_file"
  356. lappend l_script_data "set script_file \"[file tail $a_global_vars(script_file)]\"\n"
  357. lappend l_script_data "# Help information for this script"
  358. lappend l_script_data "proc help \{\} \{"
  359. lappend l_script_data " variable script_file"
  360. lappend l_script_data " puts \"\\nDescription:\""
  361. lappend l_script_data " puts \"Recreate a Vivado project from this script. The created project will be\""
  362. lappend l_script_data " puts \"functionally equivalent to the original project for which this script was\""
  363. lappend l_script_data " puts \"generated. The script contains commands for creating a project, filesets,\""
  364. lappend l_script_data " puts \"runs, adding/importing sources and setting properties on various objects.\\n\""
  365. lappend l_script_data " puts \"Syntax:\""
  366. lappend l_script_data " puts \"\$script_file\""
  367. lappend l_script_data " puts \"\$script_file -tclargs \\\[--origin_dir <path>\\\]\""
  368. lappend l_script_data " puts \"\$script_file -tclargs \\\[--project_name <name>\\\]\""
  369. lappend l_script_data " puts \"\$script_file -tclargs \\\[--help\\\]\\n\""
  370. lappend l_script_data " puts \"Usage:\""
  371. lappend l_script_data " puts \"Name Description\""
  372. lappend l_script_data " puts \"-------------------------------------------------------------------------\""
  373. if { {} == $a_global_vars(s_origin_dir_override) } {
  374. lappend l_script_data " puts \"\\\[--origin_dir <path>\\\] Determine source file paths wrt this path. Default\""
  375. lappend l_script_data " puts \" origin_dir path value is \\\".\\\", otherwise, the value\""
  376. lappend l_script_data " puts \" that was set with the \\\"-paths_relative_to\\\" switch\""
  377. lappend l_script_data " puts \" when this script was generated.\\n\""
  378. } else {
  379. lappend l_script_data " puts \"\\\[--origin_dir <path>\\\] Determine source file paths wrt this path. Default\""
  380. lappend l_script_data " puts \" origin_dir path value is \\\".\\\", otherwise, the value\""
  381. lappend l_script_data " puts \" that was set with the \\\"-origin_dir_override\\\" switch\""
  382. lappend l_script_data " puts \" when this script was generated.\\n\""
  383. }
  384. lappend l_script_data " puts \"\\\[--project_name <name>\\\] Create project with the specified name. Default\""
  385. lappend l_script_data " puts \" name is the name of the project from where this\""
  386. lappend l_script_data " puts \" script was generated.\\n\""
  387. lappend l_script_data " puts \"\\\[--help\\\] Print help information for this script\""
  388. lappend l_script_data " puts \"-------------------------------------------------------------------------\\n\""
  389. lappend l_script_data " exit 0"
  390. lappend l_script_data "\}\n"
  391. lappend l_script_data "if \{ \$::argc > 0 \} \{"
  392. lappend l_script_data " for \{set i 0\} \{\$i < \[llength \$::argc\]\} \{incr i\} \{"
  393. lappend l_script_data " set option \[string trim \[lindex \$::argv \$i\]\]"
  394. lappend l_script_data " switch -regexp -- \$option \{"
  395. lappend l_script_data " \"--origin_dir\" \{ incr i; set origin_dir \[lindex \$::argv \$i\] \}"
  396. lappend l_script_data " \"--project_name\" \{ incr i; set project_name \[lindex \$::argv \$i\] \}"
  397. lappend l_script_data " \"--help\" \{ help \}"
  398. lappend l_script_data " default \{"
  399. lappend l_script_data " if \{ \[regexp \{^-\} \$option\] \} \{"
  400. lappend l_script_data " puts \"ERROR: Unknown option '\$option' specified, please type '\$script_file -tclargs --help' for usage info.\\n\""
  401. lappend l_script_data " return 1"
  402. lappend l_script_data " \}"
  403. lappend l_script_data " \}"
  404. lappend l_script_data " \}"
  405. lappend l_script_data " \}"
  406. lappend l_script_data "\}\n"
  407. lappend l_script_data "# Set the directory path for the original project from where this script was exported"
  408. if { $a_global_vars(b_absolute_path) } {
  409. lappend l_script_data "set orig_proj_dir \"$proj_dir\""
  410. } else {
  411. set rel_file_path "[get_relative_file_path_for_source $proj_dir [get_script_execution_dir]]"
  412. set path "\[file normalize \"\$origin_dir/$rel_file_path\"\]"
  413. lappend l_script_data "set orig_proj_dir \"$path\""
  414. }
  415. lappend l_script_data ""
  416. # create project
  417. lappend l_script_data "# Create project"
  418. set tcl_cmd ""
  419. # set target project directory path if specified. If not, create project dir in current dir.
  420. set target_dir $a_global_vars(s_target_proj_dir)
  421. if { {} == $target_dir } {
  422. set tcl_cmd "create_project \$\{project_name\} \$origin_dir/vivado_project -part $part_name -quiet -force"
  423. } else {
  424. # is specified target proj dir == current dir?
  425. set cwd [file normalize [string map {\\ /} [pwd]]]
  426. set dir [file normalize [string map {\\ /} $target_dir]]
  427. if { [string equal $cwd $dir] } {
  428. set tcl_cmd "create_project \$project_name -part $part_name"
  429. } else {
  430. set tcl_cmd "create_project \$project_name \"$target_dir\" -part $part_name"
  431. }
  432. }
  433. if { [get_property managed_ip [current_project]] } {
  434. set tcl_cmd "$tcl_cmd -ip"
  435. }
  436. lappend l_script_data $tcl_cmd
  437. if { $a_global_vars(b_arg_dump_proj_info) } {
  438. puts $a_global_vars(dp_fh) "project_name=\$\{project_name\}"
  439. }
  440. lappend l_script_data ""
  441. lappend l_script_data "# Set the directory path for the new project"
  442. lappend l_script_data "set proj_dir \[get_property directory \[current_project\]\]"
  443. lappend l_script_data ""
  444. lappend l_script_data "# Reconstruct message rules"
  445. set msg_control_rules [ debug::get_msg_control_rules -as_tcl ]
  446. if { [string length $msg_control_rules] > 0 } {
  447. lappend l_script_data "${msg_control_rules}"
  448. } else {
  449. lappend l_script_data "# None"
  450. }
  451. lappend l_script_data ""
  452. }
  453. proc wr_project_properties { proj_dir proj_name } {
  454. # Summary: write project properties
  455. # This helper command is used to script help.
  456. # Argument Usage:
  457. # proj_name: project name
  458. # Return Value:
  459. # None
  460. variable l_script_data
  461. variable b_project_board_set
  462. # write project properties
  463. set tcl_obj [current_project]
  464. set get_what "get_projects"
  465. lappend l_script_data "# Set project properties"
  466. lappend l_script_data "set obj \[current_project\]"
  467. # is project "board_part" set already?
  468. if { [string length [get_property "board_part" $tcl_obj]] > 0 } {
  469. set b_project_board_set 1
  470. }
  471. write_props $proj_dir $proj_name $get_what $tcl_obj "project"
  472. }
  473. proc write_bd_as_proc { bd_file } {
  474. # Summary: writes out BD creation steps as a proc
  475. # Argument: BD file
  476. # Return Value: None
  477. variable l_added_bds
  478. variable l_bd_proc_calls
  479. variable l_script_data
  480. variable temp_offset
  481. variable l_open_bds
  482. variable temp_dir
  483. variable bd_prop_steps
  484. if { [lsearch $l_added_bds $bd_file] != -1 } { return }
  485. set to_close 1
  486. # Add sources referenced in the BD
  487. add_references $bd_file
  488. # Open BD in stealth mode, if not already open
  489. set bd_filename [file tail $bd_file]
  490. if { [lsearch $l_open_bds $bd_filename] != -1 } {
  491. set to_close 0
  492. } else {
  493. open_bd_design -stealth [ get_files $bd_file ]
  494. }
  495. current_bd_design [get_bd_designs [file rootname $bd_filename]]
  496. # write the BD as a proc to a temp file
  497. while { [file exists [file join $temp_dir "temp_$temp_offset.tcl"]] } {
  498. incr temp_offset
  499. }
  500. set temp_bd_file [file join $temp_dir "temp_$temp_offset.tcl"]
  501. write_bd_tcl -no_project_wrapper -make_local $temp_bd_file
  502. # Set non default properties for the BD
  503. wr_bd_properties $bd_file
  504. # Close BD if opened in stealth mode
  505. if {$to_close == 1 } {
  506. #close_bd_design -stealth [ get_files $bd_file ]
  507. #close_bd_design [get_bd_designs [file rootname $bd_filename]]
  508. close_bd_design [get_bd_designs [file rootname $bd_filename]]
  509. }
  510. # Get proc call
  511. if {[catch {open $temp_bd_file r} fp]} {
  512. send_msg_id Vivado-projutils-020 ERROR "failed to write out proc for $bd_file \n"
  513. return 1
  514. }
  515. # TODO no need to read whole file, just second line will do
  516. set file_data [read $fp ]
  517. set split_proc [split $file_data]
  518. set proc_index 7
  519. set str [lindex $split_proc $proc_index]
  520. close $fp
  521. # Add the BD proc, call to the proc and BD property steps
  522. if { [string equal [lindex $split_proc [expr {$proc_index-1}] ] "proc"]
  523. && [regexp {^cr_bd_.*} $str]
  524. } then {
  525. append str " \"\""
  526. lappend l_script_data "\n"
  527. lappend l_script_data $file_data
  528. lappend l_added_bds $bd_file
  529. lappend l_script_data $str
  530. lappend l_script_data $bd_prop_steps
  531. }
  532. # delete temp file
  533. file delete $temp_bd_file
  534. incr temp_offset
  535. }
  536. proc wr_bd_properties { file } {
  537. # Summary: writes non default BD properties
  538. # Argument: the .BD file
  539. # Return Value: none
  540. variable bd_prop_steps
  541. variable a_global_vars
  542. set bd_prop_steps ""
  543. set bd_name [get_property FILE_NAME [current_bd_design]]
  544. set bd_props [list_property [ get_files $file ] ]
  545. set read_only_props [rdi::get_attr_specs -object [get_files $file] -filter {is_readonly}]
  546. foreach prop $bd_props {
  547. if { [lsearch $read_only_props $prop] != -1
  548. || [string equal -nocase $prop "file_type" ]
  549. } then { continue }
  550. set def_val [list_property_value -default $prop [ get_files $file ] ]
  551. set cur_val [get_property $prop [get_files $file ] ]
  552. set def_val \"$def_val\"
  553. set cur_val \"$cur_val\"
  554. if { $a_global_vars(b_arg_all_props) } {
  555. append bd_prop_steps "set_property $prop $cur_val \[get_files $bd_name \] \n"
  556. } else {
  557. if { $def_val ne $cur_val } {
  558. append bd_prop_steps "set_property $prop $cur_val \[get_files $bd_name \] \n"
  559. }
  560. }
  561. }
  562. }
  563. proc add_references { sub_design } {
  564. # Summary: Looks for sources referenced in the block design and adds them
  565. # Argument: sub_design file
  566. # Return Value: None
  567. variable l_script_data
  568. variable l_added_bds
  569. # Getting references, if any
  570. set refs [ get_files -quiet -references -of_objects [ get_files $sub_design ] ]
  571. foreach file $refs {
  572. if { [file extension $file ] ==".bd" } {
  573. if { [lsearch $l_added_bds $file] != -1 } { continue }
  574. # Write out referred bd as a proc
  575. write_bd_as_proc $file
  576. } else {
  577. # Skip adding file if it's already part of the project
  578. lappend l_script_data "if { \[get_files [file tail $file]\] == \"\" } {"
  579. lappend l_script_data " import_files -quiet -fileset [current_fileset -srcset] $file\n}"
  580. }
  581. }
  582. }
  583. proc wr_bd {} {
  584. # Summary: write procs to create BD's
  585. # Return Value: None
  586. variable a_global_vars
  587. variable l_script_data
  588. variable l_added_bds
  589. variable l_bd_proc_calls
  590. variable l_open_bds [list]
  591. variable temp_dir
  592. variable clean_temp
  593. # String that will hold commands to set BD properties
  594. variable bd_prop_steps "\n# Setting BD properties \n"
  595. # Get already opened BD designs
  596. set open_bd_names [get_bd_designs]
  597. foreach bd_name $open_bd_names {
  598. lappend l_open_bds [get_property FILE_NAME [get_bd_designs $bd_name]]
  599. }
  600. # Get all BD files in the design
  601. set bd_files [get_files -norecurse *.bd]
  602. lappend l_script_data "\n# Adding sources referenced in BDs, if not already added"
  603. foreach bd_file $bd_files {
  604. # Making sure BD is not locked
  605. set is_locked [get_property IS_LOCKED [get_files $bd_file ] ]
  606. if { $is_locked == 1 } {
  607. file delete $a_global_vars(script_file)
  608. send_msg_id Vivado-projutils-018 ERROR "Project tcl cannot be written as the design contains one or more \
  609. locked/out-of-date design(s). Please run report_ip_status and update the design.\n"
  610. return 1
  611. }
  612. # Write out bd as a proc
  613. write_bd_as_proc $bd_file
  614. }
  615. # Delete temp directory
  616. if { $clean_temp == 1} {
  617. file delete -force $temp_dir
  618. }
  619. }
  620. proc wr_filesets { proj_dir proj_name } {
  621. # Summary: write fileset object properties
  622. # This helper command is used to script help.
  623. # Argument Usage:
  624. # proj_name: project name
  625. # Return Value:
  626. # None
  627. variable a_fileset_types
  628. # write fileset data
  629. foreach {fs_data} $a_fileset_types {
  630. set filesets [get_filesets -filter FILESET_TYPE==[lindex $fs_data 0]]
  631. write_specified_fileset $proj_dir $proj_name $filesets
  632. }
  633. }
  634. proc write_specified_fileset { proj_dir proj_name filesets } {
  635. # Summary: write fileset properties and sources
  636. # This helper command is used to script help.
  637. # Argument Usage:
  638. # proj_name: project name
  639. # filesets: list of filesets
  640. # Return Value:
  641. # None
  642. variable a_global_vars
  643. variable l_script_data
  644. variable a_fileset_types
  645. # write filesets
  646. set type "file"
  647. foreach tcl_obj $filesets {
  648. # Is this a IP block fileset for a proxy IP that is owned by another composite file?
  649. # If so, we don't want to write it out as an independent file. The parent will take care of it.
  650. if { [is_proxy_ip_fileset $tcl_obj] } {
  651. continue
  652. }
  653. set fs_type [get_property fileset_type [get_filesets $tcl_obj]]
  654. # is this a IP block fileset? if yes, do not create block fileset, but create for a pure HDL based fileset (no IP's)
  655. if { [is_ip_fileset $tcl_obj] } {
  656. # do not create block fileset
  657. } else {
  658. lappend l_script_data "# Create '$tcl_obj' fileset (if not found)"
  659. lappend l_script_data "if \{\[string equal \[get_filesets -quiet $tcl_obj\] \"\"\]\} \{"
  660. set fs_sw_type [get_fileset_type_switch $fs_type]
  661. lappend l_script_data " create_fileset $fs_sw_type $tcl_obj"
  662. lappend l_script_data "\}\n"
  663. }
  664. set get_what_fs "get_filesets"
  665. # set IP REPO PATHS (if any) for filesets of type "DesignSrcs" or "BlockSrcs"
  666. if { (({DesignSrcs} == $fs_type) || ({BlockSrcs} == $fs_type)) } {
  667. # If BlockSet contains only one IP, then this indicates the case of OOC1
  668. # This means that we should not write these properties, they are read-only
  669. set blockset_is_ooc1 false
  670. if { {BlockSrcs} == $fs_type } {
  671. set current_fs_files [get_files -quiet -of_objects [get_filesets $tcl_obj] -norecurse]
  672. if { [llength $current_fs_files] == 1 } {
  673. set only_file_in_fs [lindex $current_fs_files 0]
  674. set file_type [get_property FILE_TYPE $only_file_in_fs]
  675. set blockset_is_ooc1 [expr {$file_type == {IP}} ? true : false]
  676. }
  677. }
  678. if { $blockset_is_ooc1} {
  679. # We do not write properties for OOC1
  680. } elseif { ({RTL} == [get_property design_mode [get_filesets $tcl_obj]]) } {
  681. set repo_paths [get_ip_repo_paths $tcl_obj]
  682. if { [llength $repo_paths] > 0 } {
  683. lappend l_script_data "# Set IP repository paths"
  684. lappend l_script_data "set obj \[get_filesets $tcl_obj\]"
  685. set path_list [list]
  686. foreach path $repo_paths {
  687. if { $a_global_vars(b_absolute_path) } {
  688. lappend path_list $path
  689. } else {
  690. set rel_file_path "[get_relative_file_path_for_source $path [get_script_execution_dir]]"
  691. set path "\[file normalize \"\$origin_dir/$rel_file_path\"\]"
  692. lappend path_list $path
  693. }
  694. }
  695. set repo_path_str [join $path_list " "]
  696. lappend l_script_data "set_property \"ip_repo_paths\" \"${repo_path_str}\" \$obj"
  697. lappend l_script_data ""
  698. lappend l_script_data "# Rebuild user ip_repo's index before adding any source files"
  699. lappend l_script_data "update_ip_catalog -rebuild"
  700. lappend l_script_data ""
  701. }
  702. }
  703. }
  704. # is this a IP block fileset? if yes, then set the current srcset object (IP's will be added to current source fileset)
  705. if { [is_ip_fileset $tcl_obj] } {
  706. set srcset [current_fileset -srcset]
  707. lappend l_script_data "# Set '$srcset' fileset object"
  708. lappend l_script_data "set obj \[$get_what_fs $srcset\]"
  709. } else {
  710. lappend l_script_data "# Set '$tcl_obj' fileset object"
  711. lappend l_script_data "set obj \[$get_what_fs $tcl_obj\]"
  712. }
  713. if { {Constrs} == $fs_type } {
  714. lappend l_script_data ""
  715. write_constrs $proj_dir $proj_name $tcl_obj $type
  716. } else {
  717. write_files $proj_dir $proj_name $tcl_obj $type
  718. }
  719. # is this a IP block fileset? if yes, do not write block fileset properties (block fileset doesnot exist in new project)
  720. if { [is_ip_fileset $tcl_obj] } {
  721. # do not write ip fileset properties
  722. } else {
  723. lappend l_script_data "# Set '$tcl_obj' fileset properties"
  724. lappend l_script_data "set obj \[$get_what_fs $tcl_obj\]"
  725. write_props $proj_dir $proj_name $get_what_fs $tcl_obj "fileset"
  726. }
  727. }
  728. }
  729. proc wr_runs { proj_dir proj_name } {
  730. # Summary: write runs and properties
  731. # This helper command is used to script help.
  732. # Argument Usage:
  733. # proj_name: project name
  734. # Return Value:
  735. # None
  736. variable l_script_data
  737. # write runs (synthesis, Implementation)
  738. set runs [get_runs -filter {IS_SYNTHESIS == 1}]
  739. write_specified_run $proj_dir $proj_name $runs
  740. if { {RTL} == [get_property design_mode [current_fileset]] } {
  741. lappend l_script_data "# set the current synth run"
  742. lappend l_script_data "current_run -synthesis \[get_runs [current_run -synthesis]\]\n"
  743. }
  744. set runs [get_runs -filter {IS_IMPLEMENTATION == 1}]
  745. write_specified_run $proj_dir $proj_name $runs
  746. lappend l_script_data "# set the current impl run"
  747. lappend l_script_data "current_run -implementation \[get_runs [current_run -implementation]\]"
  748. lappend l_script_data ""
  749. lappend l_script_data "# Change current directory to project folder"
  750. lappend l_script_data "cd \[file dirname \[info script\]\]"
  751. }
  752. proc wr_proj_info { proj_name } {
  753. # Summary: write generated project status message
  754. # This helper command is used to script help.
  755. # Argument Usage:
  756. # proj_name: project name
  757. # Return Value:
  758. # None
  759. variable l_script_data
  760. lappend l_script_data "\nputs \"INFO: Project created:\$project_name\""
  761. }
  762. proc write_header { proj_dir proj_name file } {
  763. # Summary: write script header
  764. # This helper command is used to script help.
  765. # Argument Usage:
  766. # Return Value:
  767. # None
  768. variable a_global_vars
  769. variable l_local_files
  770. variable l_remote_files
  771. set version_txt [split [version] "\n"]
  772. set version [lindex $version_txt 0]
  773. set copyright [lindex $version_txt 2]
  774. set product [lindex [split $version " "] 0]
  775. set version_id [join [lrange $version 1 end] " "]
  776. set tcl_file [file tail $file]
  777. puts $a_global_vars(fh) "#*****************************************************************************************"
  778. puts $a_global_vars(fh) "# $product (TM) $version_id"
  779. puts $a_global_vars(fh) "#\n# $tcl_file: Tcl script for re-creating project '$proj_name'\n#"
  780. puts $a_global_vars(fh) "# $copyright"
  781. puts $a_global_vars(fh) "#\n# This file contains the $product Tcl commands for re-creating the project to the state*"
  782. puts $a_global_vars(fh) "# when this script was generated. In order to re-create the project, please source this"
  783. puts $a_global_vars(fh) "# file in the $product Tcl Shell."
  784. puts $a_global_vars(fh) "#"
  785. puts $a_global_vars(fh) "# * Note that the runs in the created project will be configured the same way as the"
  786. puts $a_global_vars(fh) "# original project, however they will not be launched automatically. To regenerate the"
  787. puts $a_global_vars(fh) "# run results please launch the synthesis/implementation runs as needed.\n#"
  788. puts $a_global_vars(fh) "#*****************************************************************************************"
  789. }
  790. proc print_local_file_msg { msg_type } {
  791. # Summary: print warning on finding local sources
  792. # This helper command is used to script help.
  793. # Argument Usage:
  794. # Return Value:
  795. # None
  796. puts ""
  797. if { [string equal $msg_type "warning"] } {
  798. send_msg_id Vivado-projutils-010 WARNING "Found source(s) that were local or imported into the project. If this project is being source controlled, then\n\
  799. please ensure that the project source(s) are also part of this source controlled data. The list of these local source(s) can be found in the generated script\n\
  800. under the header section."
  801. } else {
  802. send_msg_id Vivado-projutils-011 INFO "If this project is being source controlled, then please ensure that the project source(s) are also part of this source\n\
  803. controlled data. The list of these local source(s) can be found in the generated script under the header section."
  804. }
  805. puts ""
  806. }
  807. proc get_ip_repo_paths { tcl_obj } {
  808. # Summary:
  809. # Iterate over the fileset properties and get the ip_repo_paths (if set)
  810. # Argument Usage:
  811. # tcl_obj : fileset
  812. # Return Value:
  813. # List of repo paths
  814. set repo_path_list [list]
  815. foreach path [get_property ip_repo_paths [get_filesets $tcl_obj]] {
  816. lappend repo_path_list $path
  817. }
  818. return $repo_path_list
  819. }
  820. proc filter { prop val { file {} } } {
  821. # Summary: filter special properties
  822. # This helper command is used to script help.
  823. # Argument Usage:
  824. # Return Value:
  825. # true (1) if found, false (1) otherwise
  826. variable l_filetype_filter
  827. variable l_valid_ip_extns
  828. set prop [string toupper $prop]
  829. if { [expr { $prop == "BOARD" } || \
  830. { $prop == "IS_HD" } || \
  831. { $prop == "IS_PARTIAL_RECONFIG" } || \
  832. { $prop == "ADD_STEP" }]} {
  833. return 1
  834. }
  835. if { [string equal type "project"] } {
  836. if { [expr { $prop == "DIRECTORY" }] } {
  837. return 1
  838. }
  839. }
  840. # error reported if file_type is set
  841. # e.g ERROR: [Vivado 12-563] The file type 'IP' is not user settable.
  842. set val [string tolower $val]
  843. if { [string equal $prop "FILE_TYPE"] } {
  844. if { [lsearch $l_filetype_filter $val] != -1 } {
  845. return 1
  846. }
  847. }
  848. # filter readonly is_managed property for ip
  849. if { [string equal $prop "IS_MANAGED"] } {
  850. if { [lsearch -exact $l_valid_ip_extns [string tolower [file extension $file]]] >= 0 } {
  851. return 1
  852. }
  853. }
  854. # filter ip_repo_paths (ip_repo_paths is set before adding sources)
  855. if { [string equal -nocase $prop {ip_repo_paths}] } {
  856. return 1
  857. }
  858. return 0
  859. }
  860. proc is_local_to_project { file } {
  861. # Summary: check if file is local to the project directory structure
  862. # This helper command is used to script help.
  863. # Argument Usage:
  864. # Return Value:
  865. # true (1), if file is local to the project (inside project directory structure)
  866. # false (0), if file is outside the project directory structure
  867. # Remove quotes for proper normalize output
  868. set file [string trim $file "\""]
  869. set dir [get_property directory [current_project]]
  870. set proj_comps [split [string trim [file normalize [string map {\\ /} $dir]]] "/"]
  871. set file_comps [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
  872. set is_local 1
  873. for {set i 1} {$i < [llength $proj_comps]} {incr i} {
  874. if { [lindex $proj_comps $i] != [lindex $file_comps $i] } {
  875. set is_local 0;break
  876. }
  877. }
  878. return $is_local
  879. }
  880. proc is_ip_readonly_prop { name } {
  881. # Summary: Return true if dealing with following IP properties that are not settable for an IP in read-only state
  882. # Argument Usage:
  883. # name: property name
  884. # Return Value:
  885. # true if success, false otherwise
  886. if { [regexp -nocase {synth_checkpoint_mode} $name] ||
  887. [regexp -nocase {is_locked} $name] ||
  888. [regexp -nocase {generate_synth_checkpoint} $name] } {
  889. return true
  890. }
  891. return false
  892. }
  893. proc write_properties { prop_info_list get_what tcl_obj } {
  894. # Summary: write object properties
  895. # This helper command is used to script help.
  896. # Argument Usage:
  897. # Return Value:
  898. # None
  899. variable a_global_vars
  900. variable l_script_data
  901. if {[llength $prop_info_list] > 0} {
  902. set b_add_closing_brace 0
  903. foreach x $prop_info_list {
  904. set elem [split $x "#"]
  905. set name [lindex $elem 0]
  906. set value [lindex $elem 1]
  907. if { ([is_ip_readonly_prop $name]) && ([string equal $get_what "get_files"]) } {
  908. set cmd_str "if \{ !\[get_property \"is_locked\" \$file_obj\] \} \{"
  909. lappend l_script_data "$cmd_str"
  910. set cmd_str " set_property -name \"$name\" -value \"$value\" -objects"
  911. set b_add_closing_brace 1
  912. } else {
  913. set cmd_str "set_property -name \"$name\" -value \"$value\" -objects"
  914. }
  915. if { [string equal $get_what "get_files"] } {
  916. lappend l_script_data "$cmd_str \$file_obj"
  917. if { $b_add_closing_brace } {
  918. lappend l_script_data "\}"
  919. set b_add_closing_brace 0
  920. }
  921. } else {
  922. # comment "is_readonly" project property
  923. if { [string equal $get_what "get_projects"] && [string equal "$name" "is_readonly"] } {
  924. if { ! $a_global_vars(b_arg_all_props) } {
  925. send_msg_id Vivado-projutils-012 INFO "The current project is in 'read_only' state. The generated script will create a writable project."
  926. }
  927. continue
  928. }
  929. lappend l_script_data "$cmd_str \$obj"
  930. }
  931. }
  932. }
  933. lappend l_script_data ""
  934. }
  935. proc align_project_properties { prop proj_name proj_file_path } {
  936. # Summary:
  937. # Argument Usage:
  938. # Return Value:
  939. variable a_global_vars
  940. set dir_suffix {}
  941. if { {} == $prop } {
  942. return $proj_file_path
  943. }
  944. # align project properties to have project name variable
  945. if {[string equal -nocase $prop "ip_output_repo"] ||
  946. [string equal -nocase $prop "sim.ipstatic.compiled_library_dir"] } {
  947. set dir_suffix "cache"
  948. } else {
  949. if {[string equal -nocase $prop "sim.central_dir"] ||
  950. [string equal -nocase $prop "ip.user_files_dir"] ||
  951. [string equal -nocase $prop "sim.ipstatic.source_dir"] } {
  952. set dir_suffix "ip_user_files"
  953. }}
  954. # skip other properties
  955. if { {} == $dir_suffix } {
  956. return $proj_file_path
  957. }
  958. set match_str "${proj_name}/${proj_name}.${dir_suffix}"
  959. set proj_file_path [string map {\\ /} $proj_file_path]
  960. if { [regexp $match_str $proj_file_path] } {
  961. set proj_file_path [regsub -all "${proj_name}" $proj_file_path "\$\{project_name\}"]
  962. } else {
  963. set match_str "${proj_name}.${dir_suffix}"
  964. set proj_file_path [regsub "${proj_name}\.${dir_suffix}" $proj_file_path "\$\{project_name\}\.${dir_suffix}"]
  965. }
  966. return $proj_file_path
  967. }
  968. proc write_props { proj_dir proj_name get_what tcl_obj type } {
  969. # Summary: write first class object properties
  970. # This helper command is used to script help.
  971. # Argument Usage:
  972. # Return Value:
  973. # none
  974. variable a_global_vars
  975. variable l_script_data
  976. variable b_project_board_set
  977. set obj_name [get_property name [$get_what $tcl_obj]]
  978. set read_only_props [rdi::get_attr_specs -class [get_property class $tcl_obj] -filter {is_readonly}]
  979. set prop_info_list [list]
  980. set properties [list_property [$get_what $tcl_obj]]
  981. foreach prop $properties {
  982. if { [is_deprecated_property $prop] } { continue }
  983. # skip read-only properties
  984. if { [lsearch $read_only_props $prop] != -1 } { continue }
  985. # skip writing PR-Configuration, attached right after creation of impl run
  986. if { ([get_property pr_flow [current_project]] == 1) && [string equal $type "run"] } {
  987. set isImplRun [get_property is_implementation [$get_what $tcl_obj]]
  988. if { ($isImplRun == 1) && [string equal -nocase $prop "pr_configuration"] } {
  989. continue
  990. }
  991. }
  992. set prop_type "unknown"
  993. if { [string equal $type "run"] } {
  994. # skip steps.<step_name>.reports dynamic read only property (to be populated by creation of reports)
  995. if { [regexp -nocase "STEPS\..*\.REPORTS" $prop] } {
  996. continue;
  997. }
  998. if { [regexp "STEPS" $prop] } {
  999. # skip step properties
  1000. } else {
  1001. set attr_names [rdi::get_attr_specs -class [get_property class [get_runs $tcl_obj] ]]
  1002. if { [lsearch $attr_names $prop] != -1 } {
  1003. set prop_type [get_property type [lindex $attr_names [lsearch $attr_names $prop]]]
  1004. }
  1005. }
  1006. } else {
  1007. set attr_spec [rdi::get_attr_specs -quiet $prop -object [$get_what $tcl_obj]]
  1008. if { {} == $attr_spec } {
  1009. set prop_lower [string tolower $prop]
  1010. set attr_spec [rdi::get_attr_specs -quiet $prop_lower -object [$get_what $tcl_obj]]
  1011. }
  1012. set prop_type [get_property type $attr_spec]
  1013. }
  1014. set def_val [list_property_value -default $prop $tcl_obj]
  1015. set dump_prop_name [string tolower ${obj_name}_${type}_$prop]
  1016. set cur_val [get_property $prop $tcl_obj]
  1017. # filter special properties
  1018. if { [filter $prop $cur_val] } { continue }
  1019. # do not set "runs" or "project" part, if "board_part" is set
  1020. if { ([string equal $type "project"] || [string equal $type "run"]) &&
  1021. [string equal -nocase $prop "part"] &&
  1022. $b_project_board_set } {
  1023. continue
  1024. }
  1025. # do not set "fileset" target_part, if "board_part" is set
  1026. if { [string equal $type "fileset"] &&
  1027. [string equal -nocase $prop "target_part"] &&
  1028. $b_project_board_set } {
  1029. continue
  1030. }
  1031. # do not set default_rm for partitionDef initially as RM is not created at time of creation of pdef
  1032. if { [string equal $type "partitionDef"] &&
  1033. [string equal -nocase $prop "default_rm"] } {
  1034. continue
  1035. }
  1036. # re-align values
  1037. set cur_val [get_target_bool_val $def_val $cur_val]
  1038. set abs_proj_file_path [get_property $prop [$get_what $tcl_obj]]
  1039. set path_match [string match $proj_dir* $abs_proj_file_path]
  1040. if { ($path_match == 1) && ($a_global_vars(b_absolute_path) != 1) } {
  1041. # changing the absolute path to relative
  1042. set abs_path_length [string length $proj_dir]
  1043. set proj_file_path [string replace $abs_proj_file_path 0 $abs_path_length "\$proj_dir/"]
  1044. set proj_file_path [align_project_properties $prop $proj_name $proj_file_path]
  1045. set prop_entry "[string tolower $prop]#$proj_file_path"
  1046. } else {
  1047. set abs_proj_file_path [align_project_properties $prop $proj_name $abs_proj_file_path]
  1048. set prop_entry "[string tolower $prop]#$abs_proj_file_path"
  1049. }
  1050. # re-align include dir path wrt origin dir
  1051. if { [string equal -nocase $prop "include_dirs"] } {
  1052. if { [llength $abs_proj_file_path] > 0 } {
  1053. if { !$a_global_vars(b_absolute_path) } {
  1054. set incl_paths $abs_proj_file_path
  1055. set rel_paths [list]
  1056. foreach path $incl_paths {
  1057. lappend rel_paths "\[file normalize \"\$origin_dir/[get_relative_file_path_for_source $path [get_script_execution_dir]]\"\]"
  1058. }
  1059. set prop_entry "[string tolower $prop]#[join $rel_paths " "]"
  1060. }
  1061. }
  1062. }
  1063. # fix paths wrt the original project dir
  1064. if {([string equal -nocase $prop "top_file"]) && ($cur_val != "") } {
  1065. set file $cur_val
  1066. set srcs_dir "${proj_name}.srcs"
  1067. set file_dirs [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
  1068. set src_file [join [lrange $file_dirs [lsearch -exact $file_dirs "$srcs_dir"] end] "/"]
  1069. if { [is_local_to_project $file] } {
  1070. set proj_file_path "\$proj_dir/$src_file"
  1071. } else {
  1072. set proj_file_path "[get_relative_file_path_for_source $src_file [get_script_execution_dir]]"
  1073. }
  1074. set prop_entry "[string tolower $prop]#$proj_file_path"
  1075. } elseif {([string equal -nocase $prop "target_constrs_file"] ||
  1076. [string equal -nocase $prop "target_ucf"]) &&
  1077. ($cur_val != "") } {
  1078. set file $cur_val
  1079. set fs_name $tcl_obj
  1080. set path_dirs [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
  1081. set src_file [join [lrange $path_dirs [lsearch -exact $path_dirs "$fs_name"] end] "/"]
  1082. set file_object [lindex [get_files -quiet -of_objects [get_filesets $fs_name] [list $file]] 0]
  1083. set file_props [list_property $file_object]
  1084. if { [lsearch $file_props "IMPORTED_FROM"] != -1 } {
  1085. if { $a_global_vars(b_arg_no_copy_srcs) } {
  1086. set proj_file_path "\$orig_proj_dir/${proj_name}.srcs/$src_file"
  1087. } else {
  1088. set proj_file_path "\$proj_dir/\$project_name.srcs/$src_file"
  1089. }
  1090. } else {
  1091. # is file new inside project?
  1092. if { [is_local_to_project $file] } {
  1093. set path_dirs [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
  1094. set local_constrs_file [join [lrange $path_dirs end-1 end] "/"]
  1095. set local_constrs_file [string trimleft $local_constrs_file "/"]
  1096. set local_constrs_file [string trimleft $local_constrs_file "\\"]
  1097. set file $local_constrs_file
  1098. set proj_file_path "\[get_files *$local_constrs_file\]"
  1099. } else {
  1100. if { $a_global_vars(b_absolute_path) } {
  1101. set proj_file_path "$file"
  1102. } else {
  1103. set file_no_quotes [string trim $file "\""]
  1104. set rel_file_path [get_relative_file_path_for_source $file_no_quotes [get_script_execution_dir]]
  1105. set proj_file_path "\[file normalize \"\$origin_dir/$rel_file_path\"\]"
  1106. }
  1107. }
  1108. }
  1109. set prop_entry "[string tolower $prop]#$proj_file_path"
  1110. }
  1111. # re-align compiled_library_dir
  1112. if { [string equal -nocase $prop "compxlib.compiled_library_dir"] ||
  1113. [string equal -nocase $prop "compxlib.modelsim_compiled_library_dir"] ||
  1114. [string equal -nocase $prop "compxlib.questa_compiled_library_dir"] ||
  1115. [string equal -nocase $prop "compxlib.ies_compiled_library_dir"] ||
  1116. [string equal -nocase $prop "compxlib.vcs_compiled_library_dir"] ||
  1117. [string equal -nocase $prop "compxlib.riviera_compiled_library_dir"] ||
  1118. [string equal -nocase $prop "compxlib.activehdl_compiled_library_dir"] } {
  1119. set compile_lib_dir_path $cur_val
  1120. set cache_dir "${proj_name}.cache"
  1121. set path_dirs [split [string trim [file normalize [string map {\\ /} $cur_val]]] "/"]
  1122. if {[lsearch -exact $path_dirs "$cache_dir"] > 0} {
  1123. set dir_path [join [lrange $path_dirs [lsearch -exact $path_dirs "$cache_dir"] end] "/"]
  1124. set compile_lib_dir_path "\$proj_dir/$dir_path"
  1125. set compile_lib_dir_path [regsub $cache_dir $compile_lib_dir_path "\$\{project_name\}\.cache"]
  1126. }
  1127. set prop_entry "[string tolower $prop]#$compile_lib_dir_path"
  1128. }
  1129. # process run step tcl pre/post properties
  1130. if { [string equal $type "run"] } {
  1131. if { [regexp "STEPS" $prop] } {
  1132. if { [regexp "TCL.PRE" $prop] || [regexp "TCL.POST" $prop] } {
  1133. if { ($cur_val != "") } {
  1134. set file $cur_val
  1135. set srcs_dir "${proj_name}.srcs"
  1136. set file_dirs [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
  1137. set src_file [join [lrange $file_dirs [lsearch -exact $file_dirs "$srcs_dir"] end] "/"]
  1138. set tcl_file_path {}
  1139. if { [is_local_to_project $file] } {
  1140. set tcl_file_path "\$proj_dir/$src_file"
  1141. } else {
  1142. if { $a_global_vars(b_absolute_path) } {
  1143. set tcl_file_path "$file"
  1144. } else {
  1145. set rel_file_path "[get_relative_file_path_for_source $src_file [get_script_execution_dir]]"
  1146. set tcl_file_path "\[file normalize \"\$origin_dir/$rel_file_path\"\]"
  1147. }
  1148. }
  1149. set prop_entry "[string tolower $prop]#$tcl_file_path"
  1150. }
  1151. }
  1152. }
  1153. }
  1154. if { $a_global_vars(b_arg_all_props) } {
  1155. lappend prop_info_list $prop_entry
  1156. } else {
  1157. if { $def_val != $cur_val } {
  1158. lappend prop_info_list $prop_entry
  1159. }
  1160. }
  1161. if { $a_global_vars(b_arg_dump_proj_info) } {
  1162. if { ([string equal -nocase $prop "top_file"] ||
  1163. [string equal -nocase $prop "target_constrs_file"] ||
  1164. [string equal -nocase $prop "target_ucf"] ) && [string equal $type "fileset"] } {
  1165. # fix path
  1166. set file $cur_val
  1167. set srcs_dir "${proj_name}.srcs"
  1168. set file_dirs [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
  1169. set src_file [join [lrange $file_dirs [lsearch -exact $file_dirs "$srcs_dir"] end] "/"]
  1170. set cur_val "\$PSRCDIR/$src_file"
  1171. }
  1172. puts $a_global_vars(def_val_fh) "$prop:($prop_type) DEFAULT_VALUE ($def_val)==CURRENT_VALUE ($cur_val)"
  1173. puts $a_global_vars(dp_fh) "${dump_prop_name}=$cur_val"
  1174. }
  1175. }
  1176. if { {fileset} == $type } {
  1177. set fs_type [get_property fileset_type [get_filesets $tcl_obj]]
  1178. if { {SimulationSrcs} == $fs_type } {
  1179. if { ![get_property is_readonly [current_project]] } {
  1180. add_simulator_props $get_what $tcl_obj prop_info_list
  1181. }
  1182. }
  1183. }
  1184. # write properties now
  1185. write_properties $prop_info_list $get_what $tcl_obj
  1186. }
  1187. proc add_simulator_props { get_what tcl_obj prop_info_list_arg } {
  1188. # Summary: write file and file properties
  1189. # This helper command is used to script help.
  1190. # Argument Usage:
  1191. # Return Value:
  1192. # none
  1193. upvar $prop_info_list_arg prop_info_list
  1194. set target_simulator [get_property target_simulator [current_project]]
  1195. set simulators [get_simulators]
  1196. foreach simulator [get_simulators] {
  1197. if { $target_simulator == $simulator } { continue }
  1198. set_property target_simulator $simulator [current_project]
  1199. set prefix [string tolower [lindex [split $simulator {.}] 0]]
  1200. write_simulator_props $prefix $get_what $tcl_obj prop_info_list
  1201. }
  1202. set_property target_simulator $target_simulator [current_project]
  1203. }
  1204. proc write_simulator_props { prefix get_what tcl_obj prop_info_list_arg } {
  1205. # Summary: write non-default simulator properties
  1206. # Argument Usage:
  1207. # Return Value:
  1208. # none
  1209. upvar $prop_info_list_arg prop_info_list
  1210. variable a_global_vars
  1211. variable l_script_data
  1212. set read_only_props [rdi::get_attr_specs -class [get_property class $tcl_obj] -filter {is_readonly}]
  1213. foreach prop [list_property [$get_what $tcl_obj]] {
  1214. if { [lsearch $read_only_props $prop] != -1 } { continue }
  1215. if { [is_deprecated_property $prop] } { continue }
  1216. set sim_prefix [string tolower [lindex [split $prop {.}] 0]]
  1217. if { $prefix != $sim_prefix } { continue }
  1218. set attr_spec [rdi::get_attr_specs -quiet $prop -object [$get_what $tcl_obj]]
  1219. if { {} == $attr_spec } {
  1220. set prop_lower [string tolower $prop]
  1221. set attr_spec [rdi::get_attr_specs -quiet $prop_lower -object [$get_what $tcl_obj]]
  1222. }
  1223. set prop_type [get_property type $attr_spec]
  1224. set def_val [list_property_value -default $prop $tcl_obj]
  1225. set cur_val [get_property $prop $tcl_obj]
  1226. set cur_val [get_target_bool_val $def_val $cur_val]
  1227. set prop_entry "[string tolower $prop]#[get_property $prop [$get_what $tcl_obj]]"
  1228. if { $def_val != $cur_val } {
  1229. lappend prop_info_list $prop_entry
  1230. }
  1231. }
  1232. }
  1233. proc is_deprecated_property { property } {
  1234. # Summary: filter old properties
  1235. # Argument Usage:
  1236. # Return Value:
  1237. set property [string tolower $property]
  1238. if { [string equal $property "board"] ||
  1239. [string equal $property "verilog_dir"] ||
  1240. [string equal $property "compxlib.compiled_library_dir"] ||
  1241. [string equal $property "dsa.build_flow"] ||
  1242. [string equal $property "runtime"] ||
  1243. [string equal $property "unit_under_test"] ||
  1244. [string equal $property "xelab.snapshot"] ||
  1245. [string equal $property "xelab.debug_level"] ||
  1246. [string equal $property "xelab.relax"] ||
  1247. [string equal $property "xelab.mt_level"] ||
  1248. [string equal $property "xelab.load_glbl"] ||
  1249. [string equal $property "xelab.rangecheck"] ||
  1250. [string equal $property "xelab.sdf_delay"] ||
  1251. [string equal $property "xelab.unifast"] ||
  1252. [string equal $property "xelab.nosort"] ||
  1253. [string equal $property "xelab.more_options"] ||
  1254. [string equal $property "xsim.view"] ||
  1255. [string equal $property "xsim.wdb"] ||
  1256. [string equal $property "xsim.saif"] ||
  1257. [string equal $property "xsim.tclbatch"] ||
  1258. [string equal $property "xsim.more_options"] ||
  1259. [string equal $property "modelsim.custom_do"] ||
  1260. [string equal $property "modelsim.custom_udo"] ||
  1261. [string equal $property "modelsim.vhdl_syntax"] ||
  1262. [string equal $property "modelsim.use_explicit_decl"] ||
  1263. [string equal $property "modelsim.log_all_signals"] ||
  1264. [string equal $property "modelsim.sdf_delay"] ||
  1265. [string equal $property "modelsim.saif"] ||
  1266. [string equal $property "modelsim.incremental"] ||
  1267. [string equal $property "modelsim.unifast"] ||
  1268. [string equal $property "modelsim.64bit"] ||
  1269. [string equal $property "modelsim.vsim_more_options"] ||
  1270. [string equal $property "modelsim.vlog_more_options"] ||
  1271. [string equal $property "modelsim.vcom_more_options"] ||
  1272. [string equal $property "xsim.simulate.uut"] ||
  1273. [string equal $property "modelsim.simulate.uut"] ||
  1274. [string equal $property "questa.simulate.uut"] ||
  1275. [string equal $property "ies.simulate.uut"] ||
  1276. [string equal $property "vcs.simulate.uut"] } {
  1277. return true
  1278. }
  1279. return false
  1280. }
  1281. proc write_files { proj_dir proj_name tcl_obj type } {
  1282. # Summary: write file and file properties
  1283. # This helper command is used to script help.
  1284. # Argument Usage:
  1285. # Return Value:
  1286. # none
  1287. variable a_global_vars
  1288. variable l_script_data
  1289. set l_local_file_list [list]
  1290. set l_remote_file_list [list]
  1291. # return if empty fileset
  1292. if {[llength [get_files -quiet -of_objects [get_filesets $tcl_obj]]] == 0 } {
  1293. lappend l_script_data "# Empty (no sources present)\n"
  1294. return
  1295. }
  1296. set fs_name [get_filesets $tcl_obj]
  1297. set import_coln [list]
  1298. set add_file_coln [list]
  1299. foreach file [get_files -quiet -norecurse -of_objects [get_filesets $tcl_obj]] {
  1300. if { [file extension $file] == ".xcix" } { continue }
  1301. # Skip direct import/add of BD files if -use_bd_files is not provided
  1302. if { [file extension $file] == ".bd" && !$a_global_vars(b_arg_use_bd_files) } { continue }
  1303. set path_dirs [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
  1304. set begin [lsearch -exact $path_dirs "$proj_name.srcs"]
  1305. set src_file [join [lrange $path_dirs $begin+1 end] "/"]
  1306. # fetch first object
  1307. set file_object [lindex [get_files -quiet -of_objects [get_filesets $fs_name] [list $file]] 0]
  1308. set file_props [list_property $file_object]
  1309. if { [lsearch $file_props "IMPORTED_FROM"] != -1 } {
  1310. # import files
  1311. set imported_path [get_property "imported_from" $file]
  1312. set rel_file_path [get_relative_file_path_for_source $file [get_script_execution_dir]]
  1313. set proj_file_path "\$origin_dir/$rel_file_path"
  1314. set file "\"[file normalize $proj_dir/${proj_name}.srcs/$src_file]\""
  1315. if { $a_global_vars(b_arg_no_copy_srcs) } {
  1316. # add to the local collection
  1317. lappend l_remote_file_list $file
  1318. if { $a_global_vars(b_absolute_path) } {
  1319. lappend add_file_coln "$file"
  1320. } else {
  1321. lappend add_file_coln "\"\[file normalize \"$proj_file_path\"\]\""
  1322. }
  1323. } else {
  1324. # add to the import collection
  1325. lappend l_local_file_list $file
  1326. if { $a_global_vars(b_absolute_path) } {
  1327. lappend import_coln "$file"
  1328. } else {
  1329. lappend import_coln "\"\[file normalize \"$proj_file_path\"\]\""
  1330. }
  1331. }
  1332. } else {
  1333. set file "\"$file\""
  1334. # is local? add to local project, add to collection and then import this collection by default unless -no_copy_sources is specified
  1335. if { [is_local_to_project $file] } {
  1336. if { $a_global_vars(b_arg_dump_proj_info) } {
  1337. set src_file "\$PSRCDIR/$src_file"
  1338. }
  1339. # add to the import collection
  1340. if { $a_global_vars(b_absolute_path) } {
  1341. lappend import_coln [file normalize [string trim $file "\""]]
  1342. } else {
  1343. set file_no_quotes [string trim $file "\""]
  1344. set org_file_path "\$origin_dir/[get_relative_file_path_for_source $file_no_quotes [get_script_execution_dir]]"
  1345. lappend import_coln "\"\[file normalize \"$org_file_path\"\]\""
  1346. }
  1347. lappend l_local_file_list $file
  1348. } else {
  1349. if {$a_global_vars(b_absolute_path) } {
  1350. lappend add_file_coln [string trim $file "\""]
  1351. } else {
  1352. set file_no_quotes [string trim $file "\""]
  1353. set org_file_path "\$origin_dir/[get_relative_file_path_for_source $file_no_quotes [get_script_execution_dir]]"
  1354. lappend add_file_coln "\"\[file normalize \"$org_file_path\"\]\""
  1355. }
  1356. lappend l_remote_file_list $file
  1357. }
  1358. }
  1359. }
  1360. # set flag that local sources were found and print warning at the end
  1361. if { (!$a_global_vars(b_local_sources)) && ([llength l_local_file_list] > 0) } {
  1362. set a_global_vars(b_local_sources) 1
  1363. }
  1364. if {[llength $add_file_coln]>0} {
  1365. lappend l_script_data "set files \[list \\"
  1366. foreach file $add_file_coln {
  1367. lappend l_script_data " $file\\"
  1368. }
  1369. lappend l_script_data "\]"
  1370. lappend l_script_data "add_files -norecurse -fileset \$obj \$files"
  1371. lappend l_script_data ""
  1372. }
  1373. # now import local files if -no_copy_sources is not specified
  1374. if { [llength $import_coln] > 0 } {
  1375. if { ! $a_global_vars(b_arg_no_copy_srcs)} {
  1376. lappend l_script_data "# Import local files from the original project"
  1377. lappend l_script_data "set files \[list \\"
  1378. foreach ifile $import_coln {
  1379. lappend l_script_data " $ifile\\"
  1380. }
  1381. lappend l_script_data "\]"
  1382. # is this a IP block fileset? if yes, import files into current source fileset
  1383. if { [is_ip_fileset $tcl_obj] } {
  1384. lappend l_script_data "set imported_files \[import_files -fileset [current_fileset -srcset] \$files\]"
  1385. } else {
  1386. lappend l_script_data "set imported_files \[import_files -fileset $tcl_obj \$files\]"
  1387. }
  1388. } else {
  1389. lappend l_script_data "# Add local files from the original project (-no_copy_sources specified)"
  1390. lappend l_script_data "set files \[list \\"
  1391. foreach ifile $import_coln {
  1392. lappend l_script_data " $ifile\\"
  1393. }
  1394. lappend l_script_data "\]"
  1395. # is this a IP block fileset? if yes, add files into current source fileset
  1396. if { [is_ip_fileset $tcl_obj] } {
  1397. lappend l_script_data "set added_files \[add_files -fileset [current_fileset -srcset] \$files\]"
  1398. } else {
  1399. lappend l_script_data "set added_files \[add_files -fileset $tcl_obj \$files\]"
  1400. }
  1401. }
  1402. lappend l_script_data ""
  1403. }
  1404. # write fileset file properties for remote files (added sources)
  1405. write_fileset_file_properties $tcl_obj $fs_name $proj_dir $l_remote_file_list "remote"
  1406. # write fileset file properties for local files (imported sources)
  1407. write_fileset_file_properties $tcl_obj $fs_name $proj_dir $l_local_file_list "local"
  1408. }
  1409. proc write_constrs { proj_dir proj_name tcl_obj type } {
  1410. # Summary: write constrs fileset files and properties
  1411. # Argument Usage:
  1412. # Return Value:
  1413. # none
  1414. variable a_global_vars
  1415. variable l_script_data
  1416. set fs_name [get_filesets $tcl_obj]
  1417. # return if empty fileset
  1418. if {[llength [get_files -quiet -of_objects [get_filesets $tcl_obj]]] == 0 } {
  1419. lappend l_script_data "# Empty (no sources present)\n"
  1420. return
  1421. }
  1422. foreach file [get_files -quiet -norecurse -of_objects [get_filesets $tcl_obj]] {
  1423. lappend l_script_data "# Add/Import constrs file and set constrs file properties"
  1424. set constrs_file {}
  1425. set file_category {}
  1426. set path_dirs [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
  1427. set begin [lsearch -exact $path_dirs "$proj_name.srcs"]
  1428. set src_file [join [lrange $path_dirs $begin+1 end] "/"]
  1429. set file_object [lindex [get_files -quiet -of_objects [get_filesets $fs_name] [list $file]] 0]
  1430. set file_props [list_property $file_object]
  1431. # constrs sources imported?
  1432. if { [lsearch $file_props "IMPORTED_FROM"] != -1 } {
  1433. set imported_path [get_property "imported_from" $file]
  1434. set rel_file_path [get_relative_file_path_for_source $file [get_script_execution_dir]]
  1435. set proj_file_path "\$origin_dir/$rel_file_path"
  1436. set file "\"[file normalize $proj_dir/${proj_name}.srcs/$src_file]\""
  1437. # donot copy imported constrs in new project? set it as remote file in new project.
  1438. if { $a_global_vars(b_arg_no_copy_srcs) } {
  1439. set constrs_file $file
  1440. set file_category "remote"
  1441. if { $a_global_vars(b_absolute_path) } {
  1442. add_constrs_file "$file"
  1443. } else {
  1444. set str "\"\[file normalize \"$proj_file_path\"\]\""
  1445. add_constrs_file $str
  1446. }
  1447. } else {
  1448. # copy imported constrs in new project. Set it as local file in new project.
  1449. set constrs_file $file
  1450. set file_category "local"
  1451. if { $a_global_vars(b_absolute_path) } {
  1452. import_constrs_file $tcl_obj "$file"
  1453. } else {
  1454. set str "\"\[file normalize \"$proj_file_path\"\]\""
  1455. import_constrs_file $tcl_obj $str
  1456. }
  1457. }
  1458. } else {
  1459. # constrs sources were added, so check if these are local or added from remote location
  1460. set file "\"$file\""
  1461. set constrs_file $file
  1462. # is added constrs local to the project? import it in the new project and set it as local in the new project
  1463. if { [is_local_to_project $file] } {
  1464. # file is added from within project, so set it as local in the new project
  1465. set file_category "local"
  1466. if { $a_global_vars(b_arg_dump_proj_info) } {
  1467. set src_file "\$PSRCDIR/$src_file"
  1468. }
  1469. set file_no_quotes [string trim $file "\""]
  1470. set org_file_path "\$origin_dir/[get_relative_file_path_for_source $file_no_quotes [get_script_execution_dir]]"
  1471. set str "\"\[file normalize \"$org_file_path\"\]\""
  1472. if { $a_global_vars(b_arg_no_copy_srcs)} {
  1473. add_constrs_file "$str"
  1474. } else {
  1475. import_constrs_file $tcl_obj $str
  1476. }
  1477. } else {
  1478. # file is added from remote location, so set it as remote in the new project
  1479. set file_category "remote"
  1480. # find relative file path of the added constrs if no_copy in the new project
  1481. if { $a_global_vars(b_arg_no_copy_srcs) && (!$a_global_vars(b_absolute_path))} {
  1482. set file_no_quotes [string trim $file "\""]
  1483. set rel_file_path [get_relative_file_path_for_source $file_no_quotes [get_script_execution_dir]]
  1484. set file_1 "\"\[file normalize \"\$origin_dir/$rel_file_path\"\]\""
  1485. add_constrs_file "$file_1"
  1486. } else {
  1487. add_constrs_file "$file"
  1488. }
  1489. }
  1490. # set flag that local sources were found and print warning at the end
  1491. if { !$a_global_vars(b_local_sources) } {
  1492. set a_global_vars(b_local_sources) 1
  1493. }
  1494. }
  1495. write_constrs_fileset_file_properties $tcl_obj $fs_name $proj_dir $constrs_file $file_category
  1496. }
  1497. }
  1498. proc add_constrs_file { file_str } {
  1499. # Summary: add constrs file
  1500. # This helper command is used to script help.
  1501. # Argument Usage:
  1502. # Return Value:
  1503. # none
  1504. variable a_global_vars
  1505. variable l_script_data
  1506. if { $a_global_vars(b_absolute_path) } {
  1507. lappend l_script_data "set file $file_str"
  1508. } else {
  1509. if { $a_global_vars(b_arg_no_copy_srcs) } {
  1510. lappend l_script_data "set file $file_str"
  1511. } else {
  1512. set file_no_quotes [string trim $file_str "\""]
  1513. set rel_file_path [get_relative_file_path_for_source $file_no_quotes [get_script_execution_dir]]
  1514. lappend l_script_data "set file \"\[file normalize \"\$origin_dir/$rel_file_path\"\]\""
  1515. }
  1516. }
  1517. lappend l_script_data "set file_added \[add_files -norecurse -fileset \$obj \$file\]"
  1518. }
  1519. proc import_constrs_file { tcl_obj file_str } {
  1520. # Summary: import constrs file
  1521. # This helper command is used to script help.
  1522. # Argument Usage:
  1523. # Return Value:
  1524. # none
  1525. variable a_global_vars
  1526. variable l_script_data
  1527. # now import local files if -no_copy_sources is not specified
  1528. if { ! $a_global_vars(b_arg_no_copy_srcs)} {
  1529. lappend l_script_data "set file $file_str"
  1530. lappend l_script_data "set file_imported \[import_files -fileset $tcl_obj \$file\]"
  1531. }
  1532. }
  1533. proc write_constrs_fileset_file_properties { tcl_obj fs_name proj_dir file file_category } {
  1534. # Summary: write constrs fileset file properties
  1535. # This helper command is used to script help.
  1536. # Argument Usage:
  1537. # Return Value:
  1538. # none
  1539. variable a_global_vars
  1540. variable l_script_data
  1541. variable l_local_files
  1542. variable l_remote_files
  1543. set file_prop_count 0
  1544. # collect local/remote files for the header section
  1545. if { [string equal $file_category "local"] } {
  1546. lappend l_local_files $file
  1547. } elseif { [string equal $file_category "remote"] } {
  1548. lappend l_remote_files $file
  1549. }
  1550. set file [string trim $file "\""]
  1551. # fix file path for local files
  1552. if { [string equal $file_category "local"] } {
  1553. set path_dirs [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
  1554. set src_file [join [lrange $path_dirs end-1 end] "/"]
  1555. set src_file [string trimleft $src_file "/"]
  1556. set src_file [string trimleft $src_file "\\"]
  1557. set file $src_file
  1558. }
  1559. set file_object ""
  1560. if { [string equal $file_category "local"] } {
  1561. set file_object [lindex [get_files -quiet -of_objects [get_filesets $fs_name] [list "*$file"]] 0]
  1562. } elseif { [string equal $file_category "remote"] } {
  1563. set file_object [lindex [get_files -quiet -of_objects [get_filesets $fs_name] [list $file]] 0]
  1564. }
  1565. # get the constrs file properties
  1566. set file_props [list_property $file_object]
  1567. set prop_info_list [list]
  1568. set prop_count 0
  1569. foreach file_prop $file_props {
  1570. set is_readonly [get_property is_readonly [rdi::get_attr_specs $file_prop -object $file_object]]
  1571. if { [string equal $is_readonly "1"] } {
  1572. continue
  1573. }
  1574. set prop_type [get_property type [rdi::get_attr_specs $file_prop -object $file_object]]
  1575. set def_val [list_property_value -default $file_prop $file_object]
  1576. set cur_val [get_property $file_prop $file_object]
  1577. # filter special properties
  1578. if { [filter $file_prop $cur_val $file] } { continue }
  1579. # re-align values
  1580. set cur_val [get_target_bool_val $def_val $cur_val]
  1581. set dump_prop_name [string tolower ${fs_name}_file_${file_prop}]
  1582. set prop_entry ""
  1583. if { [string equal $file_category "local"] } {
  1584. set prop_entry "[string tolower $file_prop]#[get_property $file_prop $file_object]"
  1585. } elseif { [string equal $file_category "remote"] } {
  1586. set prop_value_entry [get_property $file_prop $file_object]
  1587. set prop_entry "[string tolower $file_prop]#$prop_value_entry"
  1588. }
  1589. # include all properties?
  1590. if { $a_global_vars(b_arg_all_props) } {
  1591. lappend prop_info_list $prop_entry
  1592. incr prop_count
  1593. } else {
  1594. # include only non-default (default behavior)
  1595. if { $def_val != $cur_val } {
  1596. lappend prop_info_list $prop_entry
  1597. incr prop_count
  1598. }
  1599. }
  1600. if { $a_global_vars(b_arg_dump_proj_info) } {
  1601. puts $a_global_vars(def_val_fh) "[file tail $file]=$file_prop ($prop_type) :DEFAULT_VALUE ($def_val)==CURRENT_VALUE ($cur_val)"
  1602. puts $a_global_vars(dp_fh) "$dump_prop_name=$cur_val"
  1603. }
  1604. }
  1605. # write properties now
  1606. if { $prop_count>0 } {
  1607. if { {remote} == $file_category } {
  1608. if { $a_global_vars(b_absolute_path) } {
  1609. lappend l_script_data "set file \"$file\""
  1610. } else {
  1611. lappend l_script_data "set file \"\$origin_dir/[get_relative_file_path_for_source $file [get_script_execution_dir]]\""
  1612. lappend l_script_data "set file \[file normalize \$file\]"
  1613. }
  1614. } else {
  1615. lappend l_script_data "set file \"$file\""
  1616. }
  1617. lappend l_script_data "set file_obj \[get_files -of_objects \[get_filesets $tcl_obj\] \[list \"*\$file\"\]\]"
  1618. set get_what "get_files"
  1619. write_properties $prop_info_list $get_what $tcl_obj
  1620. incr file_prop_count
  1621. }
  1622. if { $file_prop_count == 0 } {
  1623. lappend l_script_data "# None"
  1624. }
  1625. }
  1626. proc write_specified_run { proj_dir proj_name runs } {
  1627. # Summary: write the specified run information
  1628. # This helper command is used to script help.
  1629. # Argument Usage:
  1630. # Return Value:
  1631. # none
  1632. variable a_global_vars
  1633. variable l_script_data
  1634. set get_what "get_runs"
  1635. foreach tcl_obj $runs {
  1636. # is block fileset based run that contains IP? donot create OOC run
  1637. if { [is_ip_run $tcl_obj] } {
  1638. continue
  1639. }
  1640. # fetch run attributes
  1641. set part [get_property part [$get_what $tcl_obj]]
  1642. set parent_run [get_property parent [$get_what $tcl_obj]]
  1643. set src_set [get_property srcset [$get_what $tcl_obj]]
  1644. set constrs_set [get_property constrset [$get_what $tcl_obj]]
  1645. set strategy [get_property strategy [$get_what $tcl_obj]]
  1646. set parent_run_str ""
  1647. if { $parent_run != "" } {
  1648. set parent_run_str " -parent_run $parent_run"
  1649. }
  1650. set fileset_type [get_property fileset_type [get_property srcset [$get_what $tcl_obj]]]
  1651. set isImplRun [get_property is_implementation [$get_what $tcl_obj]]
  1652. set isPRProject [get_property pr_flow [current_project]]
  1653. set def_flow_type_val [list_property_value -default flow [$get_what $tcl_obj]]
  1654. set cur_flow_type_val [get_property flow [$get_what $tcl_obj]]
  1655. set def_strat_type_val [list_property_value -default strategy [$get_what $tcl_obj]]
  1656. set cur_strat_type_val [get_property strategy [$get_what $tcl_obj]]
  1657. set isChildImplRun 0
  1658. if { $isPRProject == 1 && $isImplRun == 1 && $parent_run != "" } {
  1659. set isChildImplRun [get_property is_implementation [$get_what $parent_run]]
  1660. if { $isChildImplRun == 1 } {
  1661. set prConfig [get_property pr_configuration [get_runs $tcl_obj]]
  1662. if { [get_pr_configurations $prConfig] == "" } {
  1663. # review this change. Either skip this run creation or flag error while sourcing script...???
  1664. continue
  1665. }
  1666. }
  1667. }
  1668. set cmd_str " create_run -name $tcl_obj -part $part -flow {$cur_flow_type_val} -strategy \"$cur_strat_type_val\""
  1669. if { $isChildImplRun == 1 } {
  1670. set cmd_str " $cmd_str -pr_config $prConfig"
  1671. }
  1672. lappend l_script_data "# Create '$tcl_obj' run (if not found)"
  1673. lappend l_script_data "if \{\[string equal \[get_runs -quiet $tcl_obj\] \"\"\]\} \{"
  1674. lappend l_script_data "$cmd_str -constrset $constrs_set$parent_run_str"
  1675. lappend l_script_data "\} else \{"
  1676. lappend l_script_data " set_property strategy \"$cur_strat_type_val\" \[get_runs $tcl_obj\]"
  1677. lappend l_script_data " set_property flow \"$cur_flow_type_val\" \[get_runs $tcl_obj\]"
  1678. lappend l_script_data "\}"
  1679. if { ($isImplRun == 1) && ($isPRProject == 1 && $isChildImplRun == 0) && ({DesignSrcs} == $fileset_type) } {
  1680. set prConfig [get_property pr_configuration [get_runs $tcl_obj]]
  1681. if { [get_pr_configurations $prConfig] != "" } {
  1682. lappend l_script_data "set_property pr_configuration $prConfig \[get_runs $tcl_obj\]"
  1683. }
  1684. }
  1685. lappend l_script_data "set obj \[$get_what $tcl_obj\]"
  1686. write_props $proj_dir $proj_name $get_what $tcl_obj "run"
  1687. write_report_strategy $tcl_obj
  1688. }
  1689. }
  1690. proc get_fileset_type_switch { fileset_type } {
  1691. # Summary: Return the fileset type switch for a given fileset
  1692. # Argument Usage:
  1693. # Return Value:
  1694. # Fileset type switch name
  1695. variable a_fileset_types
  1696. set fs_switch ""
  1697. foreach {fs_data} $a_fileset_types {
  1698. set fs_type [lindex $fs_data 0]
  1699. if { [string equal -nocase $fileset_type $fs_type] } {
  1700. set fs_switch [lindex $fs_data 1]
  1701. set fs_switch "-$fs_switch"
  1702. break
  1703. }
  1704. }
  1705. return $fs_switch
  1706. }
  1707. proc get_target_bool_val { def_val cur_val } {
  1708. # Summary: Resolve current boolean property value wrt its default value
  1709. # Argument Usage:
  1710. # Return Value:
  1711. # Resolved boolean value
  1712. set target_val $cur_val
  1713. if { [string equal $def_val "false"] && [string equal $cur_val "0"] } { set target_val "false" } \
  1714. elseif { [string equal $def_val "true"] && [string equal $cur_val "1"] } { set target_val "true" } \
  1715. elseif { [string equal $def_val "false"] && [string equal $cur_val "1"] } { set target_val "true" } \
  1716. elseif { [string equal $def_val "true"] && [string equal $cur_val "0"] } { set target_val "false" } \
  1717. elseif { [string equal $def_val "{}"] && [string equal $cur_val ""] } { set target_val "{}" }
  1718. return $target_val
  1719. }
  1720. proc write_fileset_file_properties { tcl_obj fs_name proj_dir l_file_list file_category } {
  1721. # Summary:
  1722. # Write fileset file properties for local and remote files
  1723. # Argument Usage:
  1724. # tcl_obj: object to inspect
  1725. # fs_name: fileset name
  1726. # l_file_list: list of files (local or remote)
  1727. # file_category: file catwgory (local or remote)
  1728. # Return Value:
  1729. # none
  1730. variable a_global_vars
  1731. variable l_script_data
  1732. variable l_local_files
  1733. variable l_remote_files
  1734. # is this a IP block fileset? if yes, set current source fileset
  1735. if { [is_ip_fileset $tcl_obj] } {
  1736. lappend l_script_data "# Set '[current_fileset -srcset]' fileset file properties for $file_category files"
  1737. } else {
  1738. lappend l_script_data "# Set '$tcl_obj' fileset file properties for $file_category files"
  1739. }
  1740. set file_prop_count 0
  1741. # collect local/remote files
  1742. foreach file $l_file_list {
  1743. if { [string equal $file_category "local"] } {
  1744. lappend l_local_files $file
  1745. } elseif { [string equal $file_category "remote"] } {
  1746. lappend l_remote_files $file
  1747. } else {}
  1748. }
  1749. foreach file $l_file_list {
  1750. set file [string trim $file "\""]
  1751. # fix file path for local files
  1752. if { [string equal $file_category "local"] } {
  1753. set path_dirs [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
  1754. set src_file [join [lrange $path_dirs end-1 end] "/"]
  1755. set src_file [string trimleft $src_file "/"]
  1756. set src_file [string trimleft $src_file "\\"]
  1757. set file $src_file
  1758. }
  1759. set file_object ""
  1760. if { [string equal $file_category "local"] } {
  1761. set file_object [lindex [get_files -quiet -of_objects [get_filesets $fs_name] [list "*$file"]] 0]
  1762. } elseif { [string equal $file_category "remote"] } {
  1763. set file_object [lindex [get_files -quiet -of_objects [get_filesets $fs_name] [list $file]] 0]
  1764. }
  1765. set file_props [list_property $file_object]
  1766. set prop_info_list [list]
  1767. set prop_count 0
  1768. foreach file_prop $file_props {
  1769. set is_readonly [get_property is_readonly [rdi::get_attr_specs $file_prop -object $file_object]]
  1770. if { [string equal $is_readonly "1"] } {
  1771. continue
  1772. }
  1773. # Fix for CR-939211
  1774. if { ([file extension $file] == ".bd") && ([string equal -nocase $file_prop "generate_synth_checkpoint"] || [string equal -nocase $file_prop "synth_checkpoint_mode"]) } {
  1775. continue
  1776. }
  1777. set prop_type [get_property type [rdi::get_attr_specs $file_prop -object $file_object]]
  1778. set def_val [list_property_value -default $file_prop $file_object]
  1779. set cur_val [get_property $file_prop $file_object]
  1780. # filter special properties
  1781. if { [filter $file_prop $cur_val $file] } { continue }
  1782. # re-align values
  1783. set cur_val [get_target_bool_val $def_val $cur_val]
  1784. set dump_prop_name [string tolower ${fs_name}_file_${file_prop}]
  1785. set prop_entry ""
  1786. if { [string equal $file_category "local"] } {
  1787. set prop_entry "[string tolower $file_prop]#[get_property $file_prop $file_object]"
  1788. } elseif { [string equal $file_category "remote"] } {
  1789. set prop_value_entry [get_property $file_prop $file_object]
  1790. set prop_entry "[string tolower $file_prop]#$prop_value_entry"
  1791. } else {}
  1792. if { $a_global_vars(b_arg_all_props) } {
  1793. lappend prop_info_list $prop_entry
  1794. incr prop_count
  1795. } else {
  1796. if { $def_val != $cur_val } {
  1797. lappend prop_info_list $prop_entry
  1798. incr prop_count
  1799. }
  1800. }
  1801. if { $a_global_vars(b_arg_dump_proj_info) } {
  1802. puts $a_global_vars(def_val_fh) "[file tail $file]=$file_prop ($prop_type) :DEFAULT_VALUE ($def_val)==CURRENT_VALUE ($cur_val)"
  1803. puts $a_global_vars(dp_fh) "$dump_prop_name=$cur_val"
  1804. }
  1805. }
  1806. # write properties now
  1807. if { $prop_count>0 } {
  1808. if { {remote} == $file_category } {
  1809. if { $a_global_vars(b_absolute_path) } {
  1810. lappend l_script_data "set file \"$file\""
  1811. } else {
  1812. lappend l_script_data "set file \"\$origin_dir/[get_relative_file_path_for_source $file [get_script_execution_dir]]\""
  1813. lappend l_script_data "set file \[file normalize \$file\]"
  1814. }
  1815. } else {
  1816. lappend l_script_data "set file \"$file\""
  1817. }
  1818. # is this a IP block fileset? if yes, get files from current source fileset
  1819. if { [is_ip_fileset $tcl_obj] } {
  1820. lappend l_script_data "set file_obj \[get_files -of_objects \[get_filesets [current_fileset -srcset]\] \[list \"*\$file\"\]\]"
  1821. } else {
  1822. lappend l_script_data "set file_obj \[get_files -of_objects \[get_filesets $tcl_obj\] \[list \"*\$file\"\]\]"
  1823. }
  1824. set get_what "get_files"
  1825. write_properties $prop_info_list $get_what $tcl_obj
  1826. incr file_prop_count
  1827. }
  1828. }
  1829. if { $file_prop_count == 0 } {
  1830. lappend l_script_data "# None"
  1831. }
  1832. lappend l_script_data ""
  1833. }
  1834. proc get_script_execution_dir { } {
  1835. # Summary: Return script directory path from where the script will be executed
  1836. # Argument Usage:
  1837. # none
  1838. # Return Value:
  1839. # Path to the script direc
  1840. variable a_global_vars
  1841. # default: return script directory path
  1842. set scr_exe_dir $a_global_vars(s_path_to_script_dir)
  1843. # is -path_to_relative specified and the path exists? return this dir
  1844. set rel_to_dir $a_global_vars(s_relative_to)
  1845. if { ("." != $rel_to_dir) } {
  1846. set rel_to_dir [file normalize $rel_to_dir]
  1847. if { [file exists $rel_to_dir] } {
  1848. set scr_exe_dir $rel_to_dir
  1849. }
  1850. }
  1851. return $scr_exe_dir
  1852. }
  1853. # TODO: This is the same as xcs_get_relative_file_path for simulators, see common/utils.tcl
  1854. # Remember to add the 'source .../common/utils.tcl' in the write_project_tcl proc to load the common file
  1855. proc get_relative_file_path_for_source { file_path_to_convert relative_to } {
  1856. # Summary: Get the relative path wrt to path specified
  1857. # Argument Usage:
  1858. # file_path_to_convert: input file to make relative to specfied path
  1859. # Return Value:
  1860. # Relative path wrt the path specified
  1861. variable a_xport_sim_vars
  1862. # make sure we are dealing with a valid relative_to directory. If regular file or is not a directory, get directory
  1863. if { [file isfile $relative_to] || ![file isdirectory $relative_to] } {
  1864. set relative_to [file dirname $relative_to]
  1865. }
  1866. set cwd [file normalize [pwd]]
  1867. if { [file pathtype $file_path_to_convert] eq "relative" } {
  1868. # is relative_to path same as cwd?, just return this path, no further processing required
  1869. if { [string equal $relative_to $cwd] } {
  1870. return $file_path_to_convert
  1871. }
  1872. # the specified path is "relative" but something else, so make it absolute wrt current working dir
  1873. set file_path_to_convert [file join $cwd $file_path_to_convert]
  1874. }
  1875. # is relative_to "relative"? convert to absolute as well wrt cwd
  1876. if { [file pathtype $relative_to] eq "relative" } {
  1877. set relative_to [file join $cwd $relative_to]
  1878. }
  1879. # normalize
  1880. set file_path_to_convert [file normalize $file_path_to_convert]
  1881. set relative_to [file normalize $relative_to]
  1882. set file_path $file_path_to_convert
  1883. set file_comps [file split $file_path]
  1884. set relative_to_comps [file split $relative_to]
  1885. set found_match false
  1886. set index 0
  1887. set fc_comps_len [llength $file_comps]
  1888. set rt_comps_len [llength $relative_to_comps]
  1889. # compare each dir element of file_to_convert and relative_to, set the flag and
  1890. # get the final index till these sub-dirs matched. Break if limit reaches.
  1891. while { [lindex $file_comps $index] == [lindex $relative_to_comps $index] } {
  1892. if { !$found_match } { set found_match true }
  1893. incr index
  1894. if { ($index == $fc_comps_len) || ($index == $rt_comps_len) } {
  1895. break;
  1896. }
  1897. }
  1898. # any common dirs found? convert path to relative
  1899. if { $found_match } {
  1900. set parent_dir_path ""
  1901. set rel_index $index
  1902. # keep traversing the relative_to dirs and build "../" levels
  1903. while { [lindex $relative_to_comps $rel_index] != "" } {
  1904. set parent_dir_path "../$parent_dir_path"
  1905. incr rel_index
  1906. }
  1907. #
  1908. # at this point we have parent_dir_path setup with exact number of sub-dirs to go up
  1909. #
  1910. # now build up part of path which is relative to matched part
  1911. set rel_path ""
  1912. set rel_index $index
  1913. while { [lindex $file_comps $rel_index] != "" } {
  1914. set comps [lindex $file_comps $rel_index]
  1915. if { $rel_path == "" } {
  1916. # first dir
  1917. set rel_path $comps
  1918. } else {
  1919. # append remaining dirs
  1920. set rel_path "${rel_path}/$comps"
  1921. }
  1922. incr rel_index
  1923. }
  1924. # prepend parent dirs, this is the complete resolved path now
  1925. set resolved_path "${parent_dir_path}${rel_path}"
  1926. return $resolved_path
  1927. }
  1928. # no common dirs found, just return the normalized path
  1929. return $file_path
  1930. }
  1931. proc is_ip_fileset { fileset } {
  1932. # Summary: Find IP's if any from the specified fileset and return true if 'generate_synth_checkpoint' is set to 1
  1933. # Argument Usage:
  1934. # fileset: fileset name
  1935. # Return Value:
  1936. # true (1) if success, false (0) otherwise
  1937. # make sure fileset is block fileset type
  1938. set isPRFlow [get_property pr_flow [current_project]]
  1939. set isRMFileset 0
  1940. if { $isPRFlow == 1 } {
  1941. set allReconfigModules [get_reconfig_modules]
  1942. foreach reconfigmodule $allReconfigModules {
  1943. set rmFileset [get_filesets -of_objects [get_reconfig_modules $reconfigmodule]]
  1944. if { [string equal $rmFileset $fileset] } {
  1945. set isRMFileset 1
  1946. break
  1947. }
  1948. }
  1949. }
  1950. if { $isRMFileset == 1 } {
  1951. return false
  1952. }
  1953. if { {BlockSrcs} != [get_property fileset_type [get_filesets $fileset]] } {
  1954. return false
  1955. }
  1956. set ip_filter "FILE_TYPE == \"IP\" || FILE_TYPE==\"Block Designs\""
  1957. set ips [get_files -all -quiet -of_objects [get_filesets $fileset] -filter $ip_filter]
  1958. set b_found false
  1959. foreach ip $ips {
  1960. if { [get_property generate_synth_checkpoint [lindex [get_files -quiet -all $ip] 0]] } {
  1961. set b_found true
  1962. break
  1963. }
  1964. }
  1965. if { $b_found } {
  1966. return true
  1967. }
  1968. return false
  1969. }
  1970. proc is_proxy_ip_fileset { fileset } {
  1971. # Summary: Determine if the fileset is an OOC run for a proxy IP that has a parent composite
  1972. # Argument Usage:
  1973. # fileset: fileset name
  1974. # Return Value:
  1975. # true (1) if the fileset contains an IP at its root with a parent composite, false (0) otherwise
  1976. # make sure fileset is block fileset type
  1977. if { {BlockSrcs} != [get_property fileset_type [get_filesets $fileset]] } {
  1978. return false
  1979. }
  1980. set ip_with_parent_filter "FILE_TYPE == IP && PARENT_COMPOSITE_FILE != \"\""
  1981. if {[llength [get_files -norecurse -quiet -of_objects [get_filesets $fileset] -filter $ip_with_parent_filter]] == 1} {
  1982. return true
  1983. }
  1984. return false
  1985. }
  1986. proc is_ip_run { run } {
  1987. # Summary: Find IP's if any from the fileset linked with the block fileset run
  1988. # Argument Usage:
  1989. # run: run name
  1990. # Return Value:
  1991. # true (1) if success, false (0) otherwise
  1992. set fileset [get_property srcset [get_runs $run]]
  1993. return [is_ip_fileset $fileset]
  1994. }
  1995. proc wr_prflow { proj_dir proj_name } {
  1996. # Summary: write partial reconfiguration and properties
  1997. # This helper command is used to script help.
  1998. # Argument Usage:
  1999. # proj_name: project name
  2000. # Return Value:
  2001. # None
  2002. if { [get_property pr_flow [current_project]] == 0 } {
  2003. return
  2004. }
  2005. # write below properties only if it's a pr project
  2006. wr_pdefs $proj_dir $proj_name
  2007. wr_reconfigModules $proj_dir $proj_name
  2008. wr_prConf $proj_dir $proj_name
  2009. }
  2010. proc wr_pdefs { proj_dir proj_name } {
  2011. # Summary: write partial reconfiguration and properties
  2012. # This helper command is used to script help.
  2013. # Argument Usage:
  2014. # proj_name: project name
  2015. # Return Value:
  2016. # None
  2017. # write pDef i.e. create partition def
  2018. set partitionDefs [get_partition_def]
  2019. foreach partitionDef $partitionDefs {
  2020. write_specified_partition_definition $proj_dir $proj_name $partitionDef
  2021. }
  2022. }
  2023. proc write_specified_partition_definition { proj_dir proj_name pDef } {
  2024. # Summary: write the specified partition definition
  2025. # This helper command is used to script help.
  2026. # Argument Usage:
  2027. # Return Value:
  2028. # none
  2029. variable l_script_data
  2030. set get_what "get_partition_defs"
  2031. set pdefName [get_property name [$get_what $pDef]]
  2032. set moduleName [get_property module_name [$get_what $pDef]]
  2033. set pdef_library [get_property library [$get_what $pDef]]
  2034. set default_library [get_property default_lib [current_project]]
  2035. set cmd_str "create_partition_def -name $pdefName -module $moduleName"
  2036. if { ($pdef_library != "") && (![string equal $pdef_library $default_library]) } {
  2037. set cmd_str "$cmd_str -library $pdef_library"
  2038. }
  2039. lappend l_script_data "# Create '$pdefName' partition definition"
  2040. lappend l_script_data "$cmd_str"
  2041. lappend l_script_data "set obj \[$get_what $pDef\]"
  2042. write_props $proj_dir $proj_name $get_what $pDef "partitionDef"
  2043. }
  2044. proc wr_reconfigModules { proj_dir proj_name } {
  2045. # Summary: write reconfiguration modules for RPs
  2046. # This helper command is used to script help.
  2047. # Argument Usage:
  2048. # proj_name: project name
  2049. # Return Value:
  2050. # None
  2051. # write reconfigurations modules
  2052. set reconfigModules [get_reconfig_modules]
  2053. foreach rm $reconfigModules {
  2054. set rm_bds [get_files -quiet -of_objects [get_reconfig_modules $rm] *.bd]
  2055. foreach rm_bd $rm_bds {
  2056. write_bd_as_proc $rm_bd
  2057. }
  2058. write_specified_reconfig_module $proj_dir $proj_name $rm
  2059. }
  2060. }
  2061. proc write_specified_reconfig_module { proj_dir proj_name reconfModule } {
  2062. # Summary: write the specified partial reconfiguration module information
  2063. # This helper command is used to script help.
  2064. # Argument Usage:
  2065. # Return Value:
  2066. # none
  2067. variable l_script_data
  2068. set get_what "get_reconfig_modules"
  2069. # fetch all the run attritubes and properties of passed reconfig modules
  2070. set name [get_property name [$get_what $reconfModule]]
  2071. set partitionDefName [get_property partition_def [$get_what $reconfModule]]
  2072. set isGateLevelSet [get_property is_gate_level [$get_what $reconfModule]]
  2073. lappend l_script_data "# Create '$reconfModule' reconfigurable module"
  2074. lappend l_script_data "set partitionDef \[get_partition_defs $partitionDefName\]"
  2075. if { $isGateLevelSet } {
  2076. set moduleName [get_property module_name [$get_what $reconfModule]]
  2077. if { $moduleName == "" } {
  2078. return
  2079. }
  2080. lappend l_script_data "create_reconfig_module -name $name -top $moduleName -partition_def \$partitionDef -gate_level"
  2081. } else {
  2082. lappend l_script_data "create_reconfig_module -name $name -partition_def \$partitionDef"
  2083. }
  2084. # write default_rm property for pDef if RM and its corresponding property for pDef->defaultRM is same
  2085. set defaultRM_for_pDef [get_property default_rm [get_partition_def $partitionDefName]]
  2086. if { [string equal $reconfModule $defaultRM_for_pDef] } {
  2087. lappend l_script_data "set_property default_rm $reconfModule \$partitionDef"
  2088. }
  2089. lappend l_script_data "set obj \[$get_what $reconfModule\]"
  2090. write_props $proj_dir $proj_name $get_what $reconfModule "reconfigModule"
  2091. write_reconfigmodule_files $proj_dir $proj_name $reconfModule
  2092. }
  2093. proc wr_prConf {proj_dir proj_name} {
  2094. # Summary: write reconfiguration modules for RPs
  2095. # This helper command is used to script help.
  2096. # Argument Usage:
  2097. # proj_name: project name
  2098. # Return Value:
  2099. # None
  2100. # write pr configurations
  2101. set prConfigurations [get_pr_configurations]
  2102. foreach prConfig $prConfigurations {
  2103. write_specified_prConfiguration $proj_dir $proj_name $prConfig
  2104. }
  2105. }
  2106. proc write_specified_prConfiguration { proj_dir proj_name prConfig } {
  2107. # Summary: write the specified pr reconfiguration
  2108. # This helper command is used to script help.
  2109. # Argument Usage:
  2110. # Return Value:
  2111. # none
  2112. variable l_script_data
  2113. set get_what "get_pr_configurations"
  2114. # fetch pr config properties
  2115. set name [get_property name [$get_what $prConfig]]
  2116. lappend l_script_data "# Create '$prConfig' pr configurations"
  2117. lappend l_script_data "create_pr_configuration -name $name"
  2118. lappend l_script_data "set obj \[$get_what $prConfig\]"
  2119. write_props $proj_dir $proj_name $get_what $prConfig "prConfiguration"
  2120. }
  2121. proc write_reconfigmodule_files { proj_dir proj_name reconfigModule } {
  2122. # Summary: write file and file properties
  2123. # This helper command is used to script help.
  2124. # Argument Usage:
  2125. # Return Value:
  2126. # none
  2127. variable a_global_vars
  2128. variable l_script_data
  2129. set l_local_file_list [list]
  2130. set l_remote_file_list [list]
  2131. # return if empty fileset
  2132. if {[llength [get_files -quiet -norecurse -of_objects [get_filesets -of_objects $reconfigModule]]] == 0 } {
  2133. lappend l_script_data "# Empty (no sources present)\n"
  2134. return
  2135. }
  2136. set fileset [get_filesets -of_objects $reconfigModule]
  2137. set fs_name [get_property name $fileset]
  2138. set import_coln [list]
  2139. set add_file_coln [list]
  2140. set bd_list [list]
  2141. foreach file [get_files -quiet -norecurse -of_objects [get_filesets -of_objects $reconfigModule]] {
  2142. if { [file extension $file ] ==".bd" && !$a_global_vars(b_arg_use_bd_files)} {
  2143. lappend bd_list $file
  2144. continue
  2145. }
  2146. set path_dirs [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
  2147. set begin [lsearch -exact $path_dirs "$proj_name.srcs"]
  2148. set src_file [join [lrange $path_dirs $begin+1 end] "/"]
  2149. # fetch first object
  2150. set file_object [lindex [get_files -quiet -norecurse -of_objects [get_filesets -of_objects $reconfigModule] [list $file]] 0]
  2151. set file_props [list_property $file_object]
  2152. if { [lsearch $file_props "IMPORTED_FROM"] != -1 } {
  2153. # import files
  2154. set imported_path [get_property "imported_from" $file]
  2155. set rel_file_path [get_relative_file_path_for_source $file [get_script_execution_dir]]
  2156. set proj_file_path "\$origin_dir/$rel_file_path"
  2157. set file "\"[file normalize $proj_dir/${proj_name}.srcs/$src_file]\""
  2158. if { $a_global_vars(b_arg_no_copy_srcs) } {
  2159. # add to the local collection
  2160. lappend l_remote_file_list $file
  2161. if { $a_global_vars(b_absolute_path) } {
  2162. lappend add_file_coln "$file"
  2163. } else {
  2164. lappend add_file_coln "\"\[file normalize \"$proj_file_path\"\]\""
  2165. }
  2166. } else {
  2167. # add to the import collection
  2168. lappend l_local_file_list $file
  2169. if { $a_global_vars(b_absolute_path) } {
  2170. lappend import_coln "$file"
  2171. } else {
  2172. lappend import_coln "\"\[file normalize \"$proj_file_path\"\]\""
  2173. }
  2174. }
  2175. } else {
  2176. set file "\"$file\""
  2177. # is local? add to local project, add to collection and then import this collection by default unless -no_copy_sources is specified
  2178. if { [is_local_to_project $file] } {
  2179. if { $a_global_vars(b_arg_dump_proj_info) } {
  2180. set src_file "\$PSRCDIR/$src_file"
  2181. }
  2182. # add to the import collection
  2183. set file_no_quotes [string trim $file "\""]
  2184. set org_file_path "\$origin_dir/[get_relative_file_path_for_source $file_no_quotes [get_script_execution_dir]]"
  2185. lappend import_coln "\"\[file normalize \"$org_file_path\"\]\""
  2186. lappend l_local_file_list $file
  2187. } else {
  2188. lappend l_remote_file_list $file
  2189. }
  2190. # add file to collection
  2191. if { $a_global_vars(b_arg_no_copy_srcs) && (!$a_global_vars(b_absolute_path))} {
  2192. set file_no_quotes [string trim $file "\""]
  2193. set rel_file_path [get_relative_file_path_for_source $file_no_quotes [get_script_execution_dir]]
  2194. set file1 "\"\[file normalize \"\$origin_dir/$rel_file_path\"\]\""
  2195. lappend add_file_coln "$file1"
  2196. } else {
  2197. lappend add_file_coln "$file"
  2198. }
  2199. }
  2200. }
  2201. if {[llength $bd_list] > 0 } {
  2202. foreach bd_file $bd_list {
  2203. set filename [file tail $bd_file]
  2204. lappend l_script_data " move_files \[ get_files $filename \] -of_objects \[get_reconfig_modules $reconfigModule\]"
  2205. }
  2206. }
  2207. if {[llength $add_file_coln]>0} {
  2208. lappend l_script_data "set files \[list \\"
  2209. foreach file $add_file_coln {
  2210. if { $a_global_vars(b_absolute_path) } {
  2211. lappend l_script_data " $file\\"
  2212. } else {
  2213. if { $a_global_vars(b_arg_no_copy_srcs) } {
  2214. lappend l_script_data " $file\\"
  2215. } else {
  2216. set file_no_quotes [string trim $file "\""]
  2217. set rel_file_path [get_relative_file_path_for_source $file_no_quotes [get_script_execution_dir]]
  2218. lappend l_script_data " \"\[file normalize \"\$origin_dir/$rel_file_path\"\]\"\\"
  2219. }
  2220. }
  2221. }
  2222. lappend l_script_data "\]"
  2223. lappend l_script_data "add_files -norecurse -of_objects \[get_reconfig_modules $reconfigModule\] \$files"
  2224. lappend l_script_data ""
  2225. }
  2226. # now import local files if -no_copy_sources is not specified
  2227. if { ! $a_global_vars(b_arg_no_copy_srcs)} {
  2228. if { [llength $import_coln] > 0 } {
  2229. lappend l_script_data "# Import local files from the original project"
  2230. lappend l_script_data "set files \[list \\"
  2231. foreach ifile $import_coln {
  2232. lappend l_script_data " $ifile\\"
  2233. }
  2234. lappend l_script_data "\]"
  2235. lappend l_script_data "import_files -of_objects \[get_reconfig_modules $reconfigModule\] \$files"
  2236. lappend l_script_data ""
  2237. }
  2238. }
  2239. # write fileset file properties for remote files (added sources)
  2240. write_reconfigmodule_file_properties $reconfigModule $fs_name $proj_dir $l_remote_file_list "remote"
  2241. # write fileset file properties for local files (imported sources)
  2242. write_reconfigmodule_file_properties $reconfigModule $fs_name $proj_dir $l_local_file_list "local"
  2243. # move sub-design files (XCI/BD) of reconfig modules from sources fileset to reconfig-module (RM) fileset
  2244. add_reconfigmodule_subdesign_files $reconfigModule
  2245. }
  2246. proc add_reconfigmodule_subdesign_files { reconfigModule } {
  2247. # Summary:
  2248. # Argument Usage:
  2249. # Return Value:
  2250. variable l_script_data
  2251. foreach rmSubdesignFileset [get_property subdesign_filesets $reconfigModule] {
  2252. foreach fileObj [get_files -quiet -norecurse -of_objects [get_filesets $rmSubdesignFileset]] {
  2253. set path_dirs [split [string trim [file normalize [string map {\\ /} $fileObj ]]] "/"]
  2254. set path [join [lrange $path_dirs end-1 end] "/"]
  2255. set path [string trimleft $path "/"]
  2256. lappend l_script_data "move_files -of_objects \$obj \[get_files *$path\]"
  2257. lappend l_script_data ""
  2258. }
  2259. }
  2260. }
  2261. proc write_reconfigmodule_file_properties { reconfigModule fs_name proj_dir l_file_list file_category } {
  2262. # Summary:
  2263. # Write fileset file properties for local and remote files
  2264. # Argument Usage:
  2265. # reconfigModule : object to inspect
  2266. # fs_name: fileset name
  2267. # l_file_list: list of files (local or remote)
  2268. # file_category: file catwgory (local or remote)
  2269. # Return Value:
  2270. # none
  2271. variable a_global_vars
  2272. variable l_script_data
  2273. variable l_local_files
  2274. variable l_remote_files
  2275. set l_local_files [list]
  2276. set l_remote_files [list]
  2277. set tcl_obj [get_filesets -of_objects $reconfigModule]
  2278. lappend l_script_data "# Set '$reconfigModule' fileset file properties for $file_category files"
  2279. set file_prop_count 0
  2280. # collect local/remote files
  2281. foreach file $l_file_list {
  2282. if { [string equal $file_category "local"] } {
  2283. lappend l_local_files $file
  2284. } elseif { [string equal $file_category "remote"] } {
  2285. lappend l_remote_files $file
  2286. } else {}
  2287. }
  2288. foreach file $l_file_list {
  2289. set file [string trim $file "\""]
  2290. # fix file path for local files
  2291. if { [string equal $file_category "local"] } {
  2292. set path_dirs [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
  2293. set src_file [join [lrange $path_dirs end-1 end] "/"]
  2294. set src_file [string trimleft $src_file "/"]
  2295. set src_file [string trimleft $src_file "\\"]
  2296. set file $src_file
  2297. }
  2298. set file_object ""
  2299. if { [string equal $file_category "local"] } {
  2300. set file_object [lindex [get_files -quiet -norecurse -of_objects [get_filesets -of_objects $reconfigModule] [list "*$file"]] 0]
  2301. } elseif { [string equal $file_category "remote"] } {
  2302. set file_object [lindex [get_files -quiet -norecurse -of_objects [get_filesets -of_objects $reconfigModule] [list $file]] 0]
  2303. }
  2304. set file_props [list_property $file_object]
  2305. set prop_info_list [list]
  2306. set prop_count 0
  2307. foreach file_prop $file_props {
  2308. set is_readonly [get_property is_readonly [rdi::get_attr_specs $file_prop -object $file_object]]
  2309. if { [string equal $is_readonly "1"] } {
  2310. continue
  2311. }
  2312. set prop_type [get_property type [rdi::get_attr_specs $file_prop -object $file_object]]
  2313. set def_val [list_property_value -default $file_prop $file_object]
  2314. set cur_val [get_property $file_prop $file_object]
  2315. # filter special properties
  2316. if { [filter $file_prop $cur_val $file] } { continue }
  2317. # re-align values
  2318. set cur_val [get_target_bool_val $def_val $cur_val]
  2319. set dump_prop_name [string tolower ${fs_name}_file_${file_prop}]
  2320. set prop_entry ""
  2321. if { [string equal $file_category "local"] } {
  2322. set prop_entry "[string tolower $file_prop]#[get_property $file_prop $file_object]"
  2323. } elseif { [string equal $file_category "remote"] } {
  2324. set prop_value_entry [get_property $file_prop $file_object]
  2325. set prop_entry "[string tolower $file_prop]#$prop_value_entry"
  2326. } else {}
  2327. if { $a_global_vars(b_arg_all_props) } {
  2328. lappend prop_info_list $prop_entry
  2329. incr prop_count
  2330. } else {
  2331. if { $def_val != $cur_val } {
  2332. lappend prop_info_list $prop_entry
  2333. incr prop_count
  2334. }
  2335. }
  2336. if { $a_global_vars(b_arg_dump_proj_info) } {
  2337. puts $a_global_vars(def_val_fh) "[file tail $file]=$file_prop ($prop_type) :DEFAULT_VALUE ($def_val)==CURRENT_VALUE ($cur_val)"
  2338. puts $a_global_vars(dp_fh) "$dump_prop_name=$cur_val"
  2339. }
  2340. }
  2341. # write properties now
  2342. if { $prop_count>0 } {
  2343. if { {remote} == $file_category } {
  2344. if { $a_global_vars(b_absolute_path) } {
  2345. lappend l_script_data "set file \"$file\""
  2346. } else {
  2347. lappend l_script_data "set file \"\$origin_dir/[get_relative_file_path_for_source $file [get_script_execution_dir]]\""
  2348. lappend l_script_data "set file \[file normalize \$file\]"
  2349. }
  2350. } else {
  2351. lappend l_script_data "set file \"$file\""
  2352. }
  2353. lappend l_script_data "set obj \[get_files -of_objects \[get_reconfig_modules $reconfigModule\] \[list \"*\$file\"\]\]"
  2354. set get_what "get_files -of_objects "
  2355. write_properties $prop_info_list $get_what $tcl_obj
  2356. incr file_prop_count
  2357. }
  2358. }
  2359. if { $file_prop_count == 0 } {
  2360. lappend l_script_data "# None"
  2361. }
  2362. lappend l_script_data ""
  2363. }
  2364. proc write_report_strategy { run } {
  2365. # Summary:
  2366. # delete all reports associated with run, then recreate each one by one as per its configuration.
  2367. # Argument Usage:
  2368. # run FCO:
  2369. # Return Value: none
  2370. set retVal [get_param project.enableReportConfiguration]
  2371. if { $retVal == 0 } {
  2372. return
  2373. }
  2374. set reports [get_report_configs -of_objects [get_runs $run]]
  2375. if { [llength $reports] == 0 } {
  2376. return
  2377. }
  2378. variable l_script_data
  2379. lappend l_script_data "set reports \[get_report_configs -of_objects \$obj\]"
  2380. lappend l_script_data "if { \[llength \$reports \] > 0 } {"
  2381. lappend l_script_data " delete_report_config \[get_report_configs -of_objects \$obj\]"
  2382. lappend l_script_data "}"
  2383. foreach report $reports {
  2384. set report_name [get_property name $report]
  2385. set report_spec [get_property report_type $report]
  2386. set step [get_property run_step $report]
  2387. lappend l_script_data "# Create '$report' report (if not found)"
  2388. lappend l_script_data "if \{ \[ string equal \[get_report_configs -of_objects \[get_runs $run\] $report\] \"\" \] \} \{"
  2389. lappend l_script_data " create_report_config -report_name $report_name -report_type $report_spec -steps $step -runs $run"
  2390. lappend l_script_data "\}"
  2391. lappend l_script_data "set obj \[get_report_configs -of_objects \[get_runs $run\] $report\]"
  2392. lappend l_script_data "if { \$obj != \"\" } {"
  2393. write_report_props $report
  2394. lappend l_script_data "}"
  2395. }
  2396. }
  2397. proc write_report_props { report } {
  2398. # Summary:
  2399. # iterate over all report options and send all non default values to -->set_property <property> <curr_value> [report FCO]
  2400. # Argument Usage:
  2401. # report FCO:
  2402. # Return Value: none
  2403. variable l_script_data
  2404. variable a_global_vars
  2405. set obj_name [get_property name $report]
  2406. set read_only_props [rdi::get_attr_specs -class [get_property class $report] -filter {is_readonly}]
  2407. set prop_info_list [list]
  2408. set properties [list_property $report]
  2409. foreach prop $properties {
  2410. if { [string equal -nocase $prop "OPTIONS.pb"] || [string equal -nocase $prop "OPTIONS.rpx"] } {
  2411. #skipping read_only property
  2412. continue
  2413. }
  2414. if { [lsearch $read_only_props $prop] != -1 } { continue }
  2415. set def_val [list_property_value -default $prop $report]
  2416. set cur_val [get_property $prop $report]
  2417. # filter special properties
  2418. if { [filter $prop $cur_val] } { continue }
  2419. set cur_val [get_target_bool_val $def_val $cur_val]
  2420. set prop_entry "[string tolower $prop]#[get_property $prop $report]"
  2421. if { $a_global_vars(b_arg_all_props) } {
  2422. lappend prop_info_list $prop_entry
  2423. } elseif { $def_val != $cur_val } {
  2424. lappend prop_info_list $prop_entry
  2425. }
  2426. }
  2427. write_properties $prop_info_list "get_report_configs" $report
  2428. }
  2429. }