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.

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