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.

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