write_project_tcl_git.tcl 115 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158
  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. file delete $a_global_vars(script_file)
  640. if { $a_global_vars(b_arg_quiet) } {
  641. reset_msg_setting
  642. }
  643. send_msg_id Vivado-projutils-018 ERROR "Project tcl cannot be written as the design contains one or more \
  644. locked/out-of-date design(s). Please run report_ip_status and update the design.\n"
  645. return 1
  646. }
  647. # Write out bd as a proc
  648. write_bd_as_proc $bd_file
  649. # Add wrapper creation
  650. set bd_filename [file tail $bd_file]
  651. lappend l_script_data "\n# Create wrapper file for $bd_filename"
  652. lappend l_script_data "make_wrapper -files \[get_files $bd_filename\] -import -top\n"
  653. }
  654. # Delete temp directory
  655. if { $clean_temp == 1} {
  656. file delete -force $temp_dir
  657. }
  658. }
  659. proc wr_filesets { proj_dir proj_name } {
  660. # Summary: write fileset object properties
  661. # This helper command is used to script help.
  662. # Argument Usage:
  663. # proj_name: project name
  664. # Return Value:
  665. # None
  666. variable a_fileset_types
  667. # write fileset data
  668. foreach {fs_data} $a_fileset_types {
  669. set filesets [get_filesets -filter FILESET_TYPE==[lindex $fs_data 0]]
  670. write_specified_fileset $proj_dir $proj_name $filesets
  671. }
  672. }
  673. proc write_specified_fileset { proj_dir proj_name filesets } {
  674. # Summary: write fileset properties and sources
  675. # This helper command is used to script help.
  676. # Argument Usage:
  677. # proj_name: project name
  678. # filesets: list of filesets
  679. # Return Value:
  680. # None
  681. variable a_global_vars
  682. variable l_script_data
  683. variable a_fileset_types
  684. # write filesets
  685. set type "file"
  686. foreach tcl_obj $filesets {
  687. # Is this a IP block fileset for a proxy IP that is owned by another composite file?
  688. # If so, we don't want to write it out as an independent file. The parent will take care of it.
  689. if { [is_proxy_ip_fileset $tcl_obj] } {
  690. continue
  691. }
  692. set fs_type [get_property fileset_type [get_filesets $tcl_obj]]
  693. # is this a IP block fileset? if yes, do not create block fileset, but create for a pure HDL based fileset (no IP's)
  694. if { [is_ip_fileset $tcl_obj] } {
  695. # do not create block fileset
  696. } elseif { [string equal $tcl_obj "utils_1"] } {
  697. # do not create utils fileset
  698. } else {
  699. lappend l_script_data "# Create '$tcl_obj' fileset (if not found)"
  700. lappend l_script_data "if \{\[string equal \[get_filesets -quiet $tcl_obj\] \"\"\]\} \{"
  701. set fs_sw_type [get_fileset_type_switch $fs_type]
  702. lappend l_script_data " create_fileset $fs_sw_type $tcl_obj"
  703. lappend l_script_data "\}\n"
  704. }
  705. set get_what_fs "get_filesets"
  706. # set IP REPO PATHS (if any) for filesets of type "DesignSrcs" or "BlockSrcs"
  707. if { (({DesignSrcs} == $fs_type) || ({BlockSrcs} == $fs_type)) } {
  708. # If BlockSet contains only one IP, then this indicates the case of OOC1
  709. # This means that we should not write these properties, they are read-only
  710. set blockset_is_ooc1 false
  711. if { {BlockSrcs} == $fs_type } {
  712. set current_fs_files [get_files -quiet -of_objects [get_filesets $tcl_obj] -norecurse]
  713. if { [llength $current_fs_files] == 1 } {
  714. set only_file_in_fs [lindex $current_fs_files 0]
  715. set file_type [get_property FILE_TYPE $only_file_in_fs]
  716. set blockset_is_ooc1 [expr {$file_type == {IP}} ? true : false]
  717. }
  718. }
  719. if { $blockset_is_ooc1} {
  720. # We do not write properties for OOC1
  721. } elseif { ({RTL} == [get_property design_mode [get_filesets $tcl_obj]]) } {
  722. set repo_paths [get_ip_repo_paths $tcl_obj]
  723. if { [llength $repo_paths] > 0 } {
  724. lappend l_script_data "# Set IP repository paths"
  725. lappend l_script_data "set obj \[get_filesets $tcl_obj\]"
  726. set path_list [list]
  727. foreach path $repo_paths {
  728. if { $a_global_vars(b_absolute_path) || [need_abs_path $path] } {
  729. lappend path_list $path
  730. } else {
  731. set rel_file_path "[get_relative_file_path_for_source $path [get_script_execution_dir]]"
  732. # Filter out IP repositories outside of the project directory
  733. if { [string first .. $rel_file_path] == 0 } { continue }
  734. set path "\[file normalize \"\$origin_dir/$rel_file_path\"\]"
  735. lappend path_list $path
  736. }
  737. }
  738. set repo_path_str [join $path_list " "]
  739. lappend l_script_data "set_property \"ip_repo_paths\" \"${repo_path_str}\" \$obj"
  740. lappend l_script_data ""
  741. lappend l_script_data "# Rebuild user ip_repo's index before adding any source files"
  742. lappend l_script_data "update_ip_catalog -rebuild"
  743. lappend l_script_data ""
  744. }
  745. }
  746. }
  747. # is this a IP block fileset? if yes, then set the current srcset object (IP's will be added to current source fileset)
  748. if { [is_ip_fileset $tcl_obj] } {
  749. set srcset [current_fileset -srcset]
  750. lappend l_script_data "# Set '$srcset' fileset object"
  751. lappend l_script_data "set obj \[$get_what_fs $srcset\]"
  752. } else {
  753. lappend l_script_data "# Set '$tcl_obj' fileset object"
  754. lappend l_script_data "set obj \[$get_what_fs $tcl_obj\]"
  755. }
  756. if { {Constrs} == $fs_type } {
  757. lappend l_script_data ""
  758. write_constrs $proj_dir $proj_name $tcl_obj $type
  759. } else {
  760. write_files $proj_dir $proj_name $tcl_obj $type
  761. }
  762. # is this a IP block fileset? if yes, do not write block fileset properties (block fileset doesnot exist in new project)
  763. if { [is_ip_fileset $tcl_obj] } {
  764. # do not write ip fileset properties
  765. } else {
  766. lappend l_script_data "# Set '$tcl_obj' fileset properties"
  767. lappend l_script_data "set obj \[$get_what_fs $tcl_obj\]"
  768. write_props $proj_dir $proj_name $get_what_fs $tcl_obj "fileset"
  769. }
  770. }
  771. }
  772. proc wr_runs { proj_dir proj_name } {
  773. # Summary: write runs and properties
  774. # This helper command is used to script help.
  775. # Argument Usage:
  776. # proj_name: project name
  777. # Return Value:
  778. # None
  779. variable l_script_data
  780. # write runs (synthesis, Implementation)
  781. set runs [get_runs -filter {IS_SYNTHESIS == 1}]
  782. write_specified_run $proj_dir $proj_name $runs
  783. if { {RTL} == [get_property design_mode [current_fileset]] } {
  784. lappend l_script_data "# set the current synth run"
  785. lappend l_script_data "current_run -synthesis \[get_runs [current_run -synthesis]\]\n"
  786. }
  787. set runs [get_runs -filter {IS_IMPLEMENTATION == 1}]
  788. write_specified_run $proj_dir $proj_name $runs
  789. lappend l_script_data "# set the current impl run"
  790. lappend l_script_data "current_run -implementation \[get_runs [current_run -implementation]\]"
  791. lappend l_script_data ""
  792. lappend l_script_data "# Change current directory to project folder"
  793. lappend l_script_data "cd \[file dirname \[info script\]\]"
  794. }
  795. proc wr_proj_info { proj_name } {
  796. # Summary: write generated project status message
  797. # This helper command is used to script help.
  798. # Argument Usage:
  799. # proj_name: project name
  800. # Return Value:
  801. # None
  802. variable l_script_data
  803. lappend l_script_data "\nputs \"INFO: Project created:\${_xil_proj_name_}\""
  804. }
  805. proc write_header { proj_dir proj_name file } {
  806. # Summary: write script header
  807. # This helper command is used to script help.
  808. # Argument Usage:
  809. # Return Value:
  810. # None
  811. variable a_global_vars
  812. variable l_local_files
  813. variable l_remote_files
  814. set version_txt [split [version] "\n"]
  815. set version [lindex $version_txt 0]
  816. set copyright [lindex $version_txt 2]
  817. set product [lindex [split $version " "] 0]
  818. set version_id [join [lrange $version 1 end] " "]
  819. set tcl_file [file tail $file]
  820. puts $a_global_vars(fh) "#*****************************************************************************************"
  821. puts $a_global_vars(fh) "# $product (TM) $version_id"
  822. puts $a_global_vars(fh) "#\n# $tcl_file: Tcl script for re-creating project '$proj_name'\n#"
  823. puts $a_global_vars(fh) "# $copyright"
  824. puts $a_global_vars(fh) "#\n# This file contains the $product Tcl commands for re-creating the project to the state*"
  825. puts $a_global_vars(fh) "# when this script was generated. In order to re-create the project, please source this"
  826. puts $a_global_vars(fh) "# file in the $product Tcl Shell."
  827. puts $a_global_vars(fh) "#"
  828. puts $a_global_vars(fh) "# * Note that the runs in the created project will be configured the same way as the"
  829. puts $a_global_vars(fh) "# original project, however they will not be launched automatically. To regenerate the"
  830. puts $a_global_vars(fh) "# run results please launch the synthesis/implementation runs as needed.\n#"
  831. puts $a_global_vars(fh) "#*****************************************************************************************"
  832. }
  833. proc print_local_file_msg { msg_type } {
  834. # Summary: print warning on finding local sources
  835. # This helper command is used to script help.
  836. # Argument Usage:
  837. # Return Value:
  838. # None
  839. puts ""
  840. if { [string equal $msg_type "warning"] } {
  841. 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\
  842. 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\
  843. under the header section."
  844. } else {
  845. 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\
  846. controlled data. The list of these local source(s) can be found in the generated script under the header section."
  847. }
  848. puts ""
  849. }
  850. proc get_ip_repo_paths { tcl_obj } {
  851. # Summary:
  852. # Iterate over the fileset properties and get the ip_repo_paths (if set)
  853. # Argument Usage:
  854. # tcl_obj : fileset
  855. # Return Value:
  856. # List of repo paths
  857. set repo_path_list [list]
  858. foreach path [get_property ip_repo_paths [get_filesets $tcl_obj]] {
  859. lappend repo_path_list $path
  860. }
  861. return $repo_path_list
  862. }
  863. proc filter { prop val { file {} } } {
  864. # Summary: filter special properties
  865. # This helper command is used to script help.
  866. # Argument Usage:
  867. # Return Value:
  868. # true (1) if found, false (1) otherwise
  869. variable l_filetype_filter
  870. variable l_valid_ip_extns
  871. set prop [string toupper $prop]
  872. if { [expr { $prop == "BOARD" } || \
  873. { $prop == "IS_HD" } || \
  874. { $prop == "IS_PARTIAL_RECONFIG" } || \
  875. { $prop == "ADD_STEP" }]} {
  876. return 1
  877. }
  878. if { [string equal type "project"] } {
  879. if { [expr { $prop == "DIRECTORY" }] } {
  880. return 1
  881. }
  882. }
  883. # error reported if file_type is set
  884. # e.g ERROR: [Vivado 12-563] The file type 'IP' is not user settable.
  885. set val [string tolower $val]
  886. if { [string equal $prop "FILE_TYPE"] } {
  887. if { [lsearch $l_filetype_filter $val] != -1 } {
  888. return 1
  889. }
  890. }
  891. # filter readonly is_managed property for ip
  892. if { [string equal $prop "IS_MANAGED"] } {
  893. if { [lsearch -exact $l_valid_ip_extns [string tolower [file extension $file]]] >= 0 } {
  894. return 1
  895. }
  896. }
  897. # filter ip_repo_paths (ip_repo_paths is set before adding sources)
  898. if { [string equal -nocase $prop {ip_repo_paths}] } {
  899. return 1
  900. }
  901. # filter sim_types
  902. if { ([string equal -nocase $prop {allowed_sim_models}]) || ([string equal -nocase $prop {preferred_sim_model}]) } {
  903. return 1
  904. }
  905. return 0
  906. }
  907. proc is_local_to_project { file } {
  908. # Summary: check if file is local to the project directory structure
  909. # This helper command is used to script help.
  910. # Argument Usage:
  911. # Return Value:
  912. # true (1), if file is local to the project (inside project directory structure)
  913. # false (0), if file is outside the project directory structure
  914. # Remove quotes for proper normalize output
  915. set file [string trim $file "\""]
  916. set dir [get_property directory [current_project]]
  917. set proj_comps [split [string trim [file normalize [string map {\\ /} $dir]]] "/"]
  918. set file_comps [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
  919. set is_local 1
  920. for {set i 1} {$i < [llength $proj_comps]} {incr i} {
  921. if { [lindex $proj_comps $i] != [lindex $file_comps $i] } {
  922. set is_local 0;break
  923. }
  924. }
  925. return $is_local
  926. }
  927. proc is_ip_readonly_prop { name } {
  928. # Summary: Return true if dealing with following IP properties that are not settable for an IP in read-only state
  929. # Argument Usage:
  930. # name: property name
  931. # Return Value:
  932. # true if success, false otherwise
  933. if { [regexp -nocase {synth_checkpoint_mode} $name] ||
  934. [regexp -nocase {is_locked} $name] ||
  935. [regexp -nocase {generate_synth_checkpoint} $name] } {
  936. return true
  937. }
  938. return false
  939. }
  940. proc write_properties { prop_info_list get_what tcl_obj {delim "#"} } {
  941. # Summary: write object properties
  942. # This helper command is used to script help.
  943. # Argument Usage:
  944. # Return Value:
  945. # None
  946. variable a_global_vars
  947. variable l_script_data
  948. if {[llength $prop_info_list] > 0} {
  949. set b_add_closing_brace 0
  950. foreach x $prop_info_list {
  951. set elem [split $x $delim]
  952. set name [lindex $elem 0]
  953. set value [lindex $elem 1]
  954. if { ([is_ip_readonly_prop $name]) && ([string equal $get_what "get_files"]) } {
  955. set cmd_str "if \{ !\[get_property \"is_locked\" \$file_obj\] \} \{"
  956. lappend l_script_data "$cmd_str"
  957. set cmd_str " set_property -name \"$name\" -value \"$value\" -objects"
  958. set b_add_closing_brace 1
  959. } else {
  960. set cmd_str "set_property -name \"$name\" -value \"$value\" -objects"
  961. }
  962. if { [string equal $get_what "get_files"] } {
  963. lappend l_script_data "$cmd_str \$file_obj"
  964. if { $b_add_closing_brace } {
  965. lappend l_script_data "\}"
  966. set b_add_closing_brace 0
  967. }
  968. } else {
  969. # comment "is_readonly" project property
  970. if { [string equal $get_what "get_projects"] && [string equal "$name" "is_readonly"] } {
  971. if { ! $a_global_vars(b_arg_all_props) && !$a_global_vars(b_arg_quiet) } {
  972. send_msg_id Vivado-projutils-012 INFO "The current project is in 'read_only' state. The generated script will create a writable project."
  973. }
  974. continue
  975. }
  976. lappend l_script_data "$cmd_str \$obj"
  977. }
  978. }
  979. }
  980. lappend l_script_data ""
  981. }
  982. proc align_project_properties { prop proj_name proj_file_path } {
  983. # Summary:
  984. # Argument Usage:
  985. # Return Value:
  986. variable a_global_vars
  987. set dir_suffix {}
  988. if { {} == $prop } {
  989. return $proj_file_path
  990. }
  991. # align project properties to have project name variable
  992. if {[string equal -nocase $prop "ip_output_repo"] ||
  993. [string equal -nocase $prop "sim.ipstatic.compiled_library_dir"] } {
  994. set dir_suffix "cache"
  995. } else {
  996. if {[string equal -nocase $prop "sim.central_dir"] ||
  997. [string equal -nocase $prop "ip.user_files_dir"] ||
  998. [string equal -nocase $prop "sim.ipstatic.source_dir"] } {
  999. set dir_suffix "ip_user_files"
  1000. }}
  1001. # skip other properties
  1002. if { {} == $dir_suffix } {
  1003. return $proj_file_path
  1004. }
  1005. set match_str "${proj_name}/${proj_name}.${dir_suffix}"
  1006. set proj_file_path [string map {\\ /} $proj_file_path]
  1007. if { [regexp $match_str $proj_file_path] } {
  1008. set proj_file_path [regsub -all "${proj_name}" $proj_file_path "\$\{_xil_proj_name_\}"]
  1009. } else {
  1010. set match_str "${proj_name}.${dir_suffix}"
  1011. set proj_file_path [regsub "${proj_name}\.${dir_suffix}" $proj_file_path "\$\{_xil_proj_name_\}\.${dir_suffix}"]
  1012. }
  1013. return $proj_file_path
  1014. }
  1015. proc write_props { proj_dir proj_name get_what tcl_obj type {delim "#"}} {
  1016. # Summary: write first class object properties
  1017. # This helper command is used to script help.
  1018. # Argument Usage:
  1019. # Return Value:
  1020. # none
  1021. variable a_global_vars
  1022. variable l_script_data
  1023. variable b_project_board_set
  1024. if {[string equal $type "project"]} {
  1025. # escape empty spaces in project name
  1026. set tcl_obj [ list "$tcl_obj"]
  1027. }
  1028. if { [string first " " $get_what 0] != -1 } {
  1029. # For cases where get_what is multiple workds like "get_dashboard_gadgets -of_object..."
  1030. set current_obj [ eval $get_what $tcl_obj]
  1031. } else {
  1032. set current_obj [$get_what $tcl_obj]
  1033. }
  1034. if { $current_obj == "" } { return }
  1035. set obj_name [get_property name $current_obj]
  1036. set read_only_props [rdi::get_attr_specs -class [get_property class $current_obj] -filter {is_readonly}]
  1037. set prop_info_list [list]
  1038. set properties [list_property $current_obj]
  1039. foreach prop $properties {
  1040. if { [is_deprecated_property $prop] } { continue }
  1041. # skip read-only properties
  1042. if { [lsearch $read_only_props $prop] != -1 } { continue }
  1043. if { ([string equal $type "gadget"]) && ([string equal -nocase $prop "type"]) } {
  1044. continue
  1045. }
  1046. # To handle the work-around solution of CR-988588 set board_part to base_board_part value then set board_connections
  1047. if { ([ string equal $type "project" ]) && ([ string equal [ string tolower $prop ] "board_connections" ]) } {
  1048. continue
  1049. }
  1050. if { ([ string equal $type "project" ]) && $b_project_board_set && ([ string equal [ string tolower $prop ] "board_part" ]) } {
  1051. set board_part_val [get_property $prop $current_obj]
  1052. set base_board_part_val [get_property base_board_part $current_obj]
  1053. set board_connections_val [get_property board_connections $current_obj]
  1054. if { $base_board_part_val != "" && $base_board_part_val != $board_part_val } {
  1055. set prop_entry "[string tolower $prop]$delim$base_board_part_val"
  1056. lappend prop_info_list $prop_entry
  1057. set prop_entry "board_connections$delim$board_connections_val"
  1058. lappend prop_info_list $prop_entry
  1059. continue
  1060. }
  1061. }
  1062. # skip writing PR-Configuration, attached right after creation of impl run
  1063. if { ([get_property pr_flow [current_project]] == 1) && [string equal $type "run"] } {
  1064. set isImplRun [get_property is_implementation $current_obj]
  1065. if { ($isImplRun == 1) && [string equal -nocase $prop "pr_configuration"] } {
  1066. continue
  1067. }
  1068. }
  1069. set prop_type "unknown"
  1070. if { [string equal $type "run"] } {
  1071. # skip steps.<step_name>.reports dynamic read only property (to be populated by creation of reports)
  1072. if { [regexp -nocase "STEPS\..*\.REPORTS" $prop] || [string equal -nocase "REPORT_STRATEGY" $prop] } {
  1073. continue;
  1074. }
  1075. if { [regexp "STEPS" $prop] } {
  1076. # skip step properties
  1077. } else {
  1078. set attr_names [rdi::get_attr_specs -class [get_property class [get_runs $tcl_obj] ]]
  1079. if { [lsearch $attr_names $prop] != -1 } {
  1080. set prop_type [get_property type [lindex $attr_names [lsearch $attr_names $prop]]]
  1081. }
  1082. }
  1083. } else {
  1084. set attr_spec [rdi::get_attr_specs -quiet $prop -object $current_obj]
  1085. if { {} == $attr_spec } {
  1086. set prop_lower [string tolower $prop]
  1087. set attr_spec [rdi::get_attr_specs -quiet $prop_lower -object $current_obj]
  1088. }
  1089. set prop_type [get_property type $attr_spec]
  1090. }
  1091. set def_val [list_property_value -default $prop $current_obj]
  1092. set dump_prop_name [string tolower ${obj_name}_${type}_$prop]
  1093. set cur_val [get_property $prop $current_obj]
  1094. # filter special properties
  1095. if { [filter $prop $cur_val] } { continue }
  1096. # do not set "runs" or "project" part, if "board_part" is set
  1097. if { ([string equal $type "project"] || [string equal $type "run"]) &&
  1098. [string equal -nocase $prop "part"] &&
  1099. $b_project_board_set } {
  1100. continue
  1101. }
  1102. # do not set "fileset" target_part, if "board_part" is set
  1103. if { [string equal $type "fileset"] &&
  1104. [string equal -nocase $prop "target_part"] &&
  1105. $b_project_board_set } {
  1106. continue
  1107. }
  1108. # do not set default_rm for partitionDef initially as RM is not created at time of creation of pdef
  1109. if { [string equal $type "partitionDef"] &&
  1110. [string equal -nocase $prop "default_rm"] } {
  1111. continue
  1112. }
  1113. # re-align values
  1114. set cur_val [get_target_bool_val $def_val $cur_val]
  1115. set abs_proj_file_path [get_property $prop $current_obj]
  1116. set path_match [string match $proj_dir* $abs_proj_file_path]
  1117. if { ($path_match == 1) && ($a_global_vars(b_absolute_path) != 1) && ![need_abs_path $abs_proj_file_path] } {
  1118. # changing the absolute path to relative
  1119. set abs_path_length [string length $proj_dir]
  1120. set proj_file_path [string replace $abs_proj_file_path 0 $abs_path_length "\$proj_dir/"]
  1121. set proj_file_path [align_project_properties $prop $proj_name $proj_file_path]
  1122. set prop_entry "[string tolower $prop]$delim$proj_file_path"
  1123. } else {
  1124. set abs_proj_file_path [align_project_properties $prop $proj_name $abs_proj_file_path]
  1125. set prop_entry "[string tolower $prop]$delim$abs_proj_file_path"
  1126. }
  1127. # handle the board_part_repo_paths property
  1128. if {[string equal -nocase $prop "board_part_repo_paths"]} {
  1129. set board_repo_paths [list]
  1130. set board_repo_paths [get_property $prop $current_obj]
  1131. if { [llength $board_repo_paths] > 0 } {
  1132. set board_paths [list]
  1133. foreach path $board_repo_paths {
  1134. if { $a_global_vars(b_absolute_path) || [need_abs_path $path] } {
  1135. lappend board_paths $path
  1136. } else {
  1137. set board_part_path [get_relative_file_path_for_source $path [get_script_execution_dir]]
  1138. # Limit board repo to those inside the project folder
  1139. if { [string first .. $board_part_path] == -1 } {
  1140. lappend board_paths "\[file normalize \"\$origin_dir/$board_part_path\"\]"
  1141. }
  1142. }
  1143. }
  1144. # Only set property if there is something in the list
  1145. if { [llength $board_paths] > 0 } {
  1146. set prop_entry "[string tolower $prop]$delim[join $board_paths " "]"
  1147. # Else, skip
  1148. } else {
  1149. continue
  1150. }
  1151. }
  1152. }
  1153. # re-align include dir path wrt origin dir
  1154. if { [string equal -nocase $prop "include_dirs"] } {
  1155. if { [llength $abs_proj_file_path] > 0 } {
  1156. if { !$a_global_vars(b_absolute_path) } {
  1157. set incl_paths $abs_proj_file_path
  1158. set rel_paths [list]
  1159. foreach path $incl_paths {
  1160. if { ![need_abs_path $path] } {
  1161. lappend rel_paths "\[file normalize \"\$origin_dir/[get_relative_file_path_for_source $path [get_script_execution_dir]]\"\]"
  1162. }
  1163. }
  1164. set prop_entry "[string tolower $prop]$delim[join $rel_paths " "]"
  1165. }
  1166. }
  1167. }
  1168. # fix paths wrt the original project dir
  1169. if {([string equal -nocase $prop "top_file"]) && ($cur_val != "") } {
  1170. set file $cur_val
  1171. set srcs_dir "${proj_name}.srcs"
  1172. set file_dirs [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
  1173. set src_file [join [lrange $file_dirs [lsearch -exact $file_dirs "$srcs_dir"] end] "/"]
  1174. if { [is_local_to_project $file] || [need_abs_path $file]} {
  1175. set proj_file_path "\$proj_dir/$src_file"
  1176. } else {
  1177. set proj_file_path "[get_relative_file_path_for_source $src_file [get_script_execution_dir]]"
  1178. }
  1179. set prop_entry "[string tolower $prop]$delim$proj_file_path"
  1180. } elseif {([string equal -nocase $prop "target_constrs_file"] ||
  1181. [string equal -nocase $prop "target_ucf"]) &&
  1182. ($cur_val != "") } {
  1183. set file $cur_val
  1184. set fs_name $tcl_obj
  1185. set path_dirs [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
  1186. set src_file [join [lrange $path_dirs [lsearch -exact $path_dirs "$fs_name"] end] "/"]
  1187. set file_object [lindex [get_files -quiet -of_objects [get_filesets $fs_name] [list $file]] 0]
  1188. set file_props [list_property $file_object]
  1189. if { [lsearch $file_props "IMPORTED_FROM"] != -1 } {
  1190. if { $a_global_vars(b_arg_no_copy_srcs) } {
  1191. set proj_file_path "\$orig_proj_dir/${proj_name}.srcs/$src_file"
  1192. } else {
  1193. set proj_file_path "\$proj_dir/\$\{_xil_proj_name_\}.srcs/$src_file"
  1194. }
  1195. } else {
  1196. # is file new inside project?
  1197. if { [is_local_to_project $file] } {
  1198. set path_dirs [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
  1199. set local_constrs_file [join [lrange $path_dirs end-1 end] "/"]
  1200. set local_constrs_file [string trimleft $local_constrs_file "/"]
  1201. set local_constrs_file [string trimleft $local_constrs_file "\\"]
  1202. set file $local_constrs_file
  1203. set proj_file_path "\[get_files *$local_constrs_file\]"
  1204. } else {
  1205. if { $a_global_vars(b_absolute_path) || [need_abs_path $file] } {
  1206. set proj_file_path "$file"
  1207. } else {
  1208. set file_no_quotes [string trim $file "\""]
  1209. set rel_file_path [get_relative_file_path_for_source $file_no_quotes [get_script_execution_dir]]
  1210. set proj_file_path "\[file normalize \"\$origin_dir/$rel_file_path\"\]"
  1211. }
  1212. }
  1213. }
  1214. set prop_entry "[string tolower $prop]$delim$proj_file_path"
  1215. }
  1216. # re-align compiled_library_dir
  1217. if { [string equal -nocase $prop "compxlib.compiled_library_dir"] ||
  1218. [string equal -nocase $prop "compxlib.modelsim_compiled_library_dir"] ||
  1219. [string equal -nocase $prop "compxlib.questa_compiled_library_dir"] ||
  1220. [string equal -nocase $prop "compxlib.ies_compiled_library_dir"] ||
  1221. [string equal -nocase $prop "compxlib.vcs_compiled_library_dir"] ||
  1222. [string equal -nocase $prop "compxlib.riviera_compiled_library_dir"] ||
  1223. [string equal -nocase $prop "compxlib.activehdl_compiled_library_dir"] } {
  1224. set compile_lib_dir_path $cur_val
  1225. set cache_dir "${proj_name}.cache"
  1226. set path_dirs [split [string trim [file normalize [string map {\\ /} $cur_val]]] "/"]
  1227. if {[lsearch -exact $path_dirs "$cache_dir"] > 0} {
  1228. set dir_path [join [lrange $path_dirs [lsearch -exact $path_dirs "$cache_dir"] end] "/"]
  1229. set compile_lib_dir_path "\$proj_dir/$dir_path"
  1230. set compile_lib_dir_path [regsub $cache_dir $compile_lib_dir_path "\$\{_xil_proj_name_\}\.cache"]
  1231. }
  1232. set prop_entry "[string tolower $prop]$delim$compile_lib_dir_path"
  1233. }
  1234. # process run step tcl pre/post properties
  1235. if { [string equal $type "run"] } {
  1236. if { [regexp "STEPS" $prop] } {
  1237. if { [regexp "TCL.PRE" $prop] || [regexp "TCL.POST" $prop] } {
  1238. if { ($cur_val != "") } {
  1239. set file $cur_val
  1240. set srcs_dir "${proj_name}.srcs"
  1241. set file_dirs [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
  1242. set src_file [join [lrange $file_dirs [lsearch -exact $file_dirs "$srcs_dir"] end] "/"]
  1243. set tcl_file_path {}
  1244. if { [is_local_to_project $file] } {
  1245. set tcl_file_path "\$proj_dir/$src_file"
  1246. } else {
  1247. if { $a_global_vars(b_absolute_path)|| [need_abs_path $file] } {
  1248. set tcl_file_path "$file"
  1249. } else {
  1250. set rel_file_path "[get_relative_file_path_for_source $src_file [get_script_execution_dir]]"
  1251. set tcl_file_path "\[file normalize \"\$origin_dir/$rel_file_path\"\]"
  1252. }
  1253. }
  1254. set prop_entry "[string tolower $prop]$delim$tcl_file_path"
  1255. }
  1256. }
  1257. }
  1258. }
  1259. if { $a_global_vars(b_arg_all_props) } {
  1260. lappend prop_info_list $prop_entry
  1261. } else {
  1262. if { $def_val != $cur_val } {
  1263. lappend prop_info_list $prop_entry
  1264. }
  1265. }
  1266. if { $a_global_vars(b_arg_dump_proj_info) } {
  1267. if { ([string equal -nocase $prop "top_file"] ||
  1268. [string equal -nocase $prop "target_constrs_file"] ||
  1269. [string equal -nocase $prop "target_ucf"] ) && [string equal $type "fileset"] } {
  1270. # fix path
  1271. set file $cur_val
  1272. set srcs_dir "${proj_name}.srcs"
  1273. set file_dirs [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
  1274. set src_file [join [lrange $file_dirs [lsearch -exact $file_dirs "$srcs_dir"] end] "/"]
  1275. set cur_val "\$PSRCDIR/$src_file"
  1276. }
  1277. puts $a_global_vars(def_val_fh) "$prop:($prop_type) DEFAULT_VALUE ($def_val)==CURRENT_VALUE ($cur_val)"
  1278. puts $a_global_vars(dp_fh) "${dump_prop_name}=$cur_val"
  1279. }
  1280. }
  1281. if { {fileset} == $type } {
  1282. set fs_type [get_property fileset_type [get_filesets $tcl_obj]]
  1283. if { {SimulationSrcs} == $fs_type } {
  1284. if { ![get_property is_readonly [current_project]] } {
  1285. add_simulator_props $get_what $tcl_obj prop_info_list
  1286. }
  1287. }
  1288. }
  1289. # write properties now
  1290. write_properties $prop_info_list $get_what $tcl_obj $delim
  1291. }
  1292. proc add_simulator_props { get_what tcl_obj prop_info_list_arg } {
  1293. # Summary: write file and file properties
  1294. # This helper command is used to script help.
  1295. # Argument Usage:
  1296. # Return Value:
  1297. # none
  1298. upvar $prop_info_list_arg prop_info_list
  1299. set target_simulator [get_property target_simulator [current_project]]
  1300. set simulators [get_simulators]
  1301. foreach simulator [get_simulators] {
  1302. if { $target_simulator == $simulator } { continue }
  1303. set_property target_simulator $simulator [current_project]
  1304. set prefix [string tolower [lindex [split $simulator {.}] 0]]
  1305. write_simulator_props $prefix $get_what $tcl_obj prop_info_list
  1306. }
  1307. set_property target_simulator $target_simulator [current_project]
  1308. }
  1309. proc write_simulator_props { prefix get_what tcl_obj prop_info_list_arg } {
  1310. # Summary: write non-default simulator properties
  1311. # Argument Usage:
  1312. # Return Value:
  1313. # none
  1314. upvar $prop_info_list_arg prop_info_list
  1315. variable a_global_vars
  1316. variable l_script_data
  1317. set read_only_props [rdi::get_attr_specs -class [get_property class $tcl_obj] -filter {is_readonly}]
  1318. foreach prop [list_property [$get_what $tcl_obj]] {
  1319. if { [lsearch $read_only_props $prop] != -1 } { continue }
  1320. if { [is_deprecated_property $prop] } { continue }
  1321. set sim_prefix [string tolower [lindex [split $prop {.}] 0]]
  1322. if { $prefix != $sim_prefix } { continue }
  1323. set attr_spec [rdi::get_attr_specs -quiet $prop -object [$get_what $tcl_obj]]
  1324. if { {} == $attr_spec } {
  1325. set prop_lower [string tolower $prop]
  1326. set attr_spec [rdi::get_attr_specs -quiet $prop_lower -object [$get_what $tcl_obj]]
  1327. }
  1328. set prop_type [get_property type $attr_spec]
  1329. set def_val [list_property_value -default $prop $tcl_obj]
  1330. set cur_val [get_property $prop $tcl_obj]
  1331. set cur_val [get_target_bool_val $def_val $cur_val]
  1332. set prop_entry "[string tolower $prop]#[get_property $prop [$get_what $tcl_obj]]"
  1333. if { $def_val != $cur_val } {
  1334. lappend prop_info_list $prop_entry
  1335. }
  1336. }
  1337. }
  1338. proc is_deprecated_property { property } {
  1339. # Summary: filter old properties
  1340. # Argument Usage:
  1341. # Return Value:
  1342. set property [string tolower $property]
  1343. if { [string equal $property "board"] ||
  1344. [string equal $property "verilog_dir"] ||
  1345. [string equal $property "compxlib.compiled_library_dir"] ||
  1346. [string equal $property "runtime"] ||
  1347. [string equal $property "unit_under_test"] ||
  1348. [string equal $property "xelab.snapshot"] ||
  1349. [string equal $property "xelab.debug_level"] ||
  1350. [string equal $property "xelab.relax"] ||
  1351. [string equal $property "xelab.mt_level"] ||
  1352. [string equal $property "xelab.load_glbl"] ||
  1353. [string equal $property "xelab.rangecheck"] ||
  1354. [string equal $property "xelab.sdf_delay"] ||
  1355. [string equal $property "xelab.unifast"] ||
  1356. [string equal $property "xelab.nosort"] ||
  1357. [string equal $property "xelab.more_options"] ||
  1358. [string equal $property "xsim.view"] ||
  1359. [string equal $property "xsim.wdb"] ||
  1360. [string equal $property "xsim.saif"] ||
  1361. [string equal $property "xsim.tclbatch"] ||
  1362. [string equal $property "xsim.more_options"] ||
  1363. [string equal $property "modelsim.custom_do"] ||
  1364. [string equal $property "modelsim.custom_udo"] ||
  1365. [string equal $property "modelsim.vhdl_syntax"] ||
  1366. [string equal $property "modelsim.use_explicit_decl"] ||
  1367. [string equal $property "modelsim.log_all_signals"] ||
  1368. [string equal $property "modelsim.sdf_delay"] ||
  1369. [string equal $property "modelsim.saif"] ||
  1370. [string equal $property "modelsim.incremental"] ||
  1371. [string equal $property "modelsim.unifast"] ||
  1372. [string equal $property "modelsim.64bit"] ||
  1373. [string equal $property "modelsim.vsim_more_options"] ||
  1374. [string equal $property "modelsim.vlog_more_options"] ||
  1375. [string equal $property "modelsim.vcom_more_options"] ||
  1376. [string equal $property "xsim.simulate.uut"] ||
  1377. [string equal $property "modelsim.simulate.uut"] ||
  1378. [string equal $property "questa.simulate.uut"] ||
  1379. [string equal $property "ies.simulate.uut"] ||
  1380. [string equal $property "vcs.simulate.uut"] ||
  1381. [string equal $property "platform.xocc_link_xp_switches_default"] ||
  1382. [string equal $property "platform.xocc_compile_xp_switches_default"] ||
  1383. [string equal $property "dsa"] ||
  1384. [regexp {dsa\..*} $property ] } {
  1385. return true
  1386. }
  1387. return false
  1388. }
  1389. proc write_files { proj_dir proj_name tcl_obj type } {
  1390. # Summary: write file and file properties
  1391. # This helper command is used to script help.
  1392. # Argument Usage:
  1393. # Return Value:
  1394. # none
  1395. variable a_global_vars
  1396. variable l_script_data
  1397. set l_local_file_list [list]
  1398. set l_remote_file_list [list]
  1399. # return if empty fileset
  1400. if {[llength [get_files -quiet -of_objects [get_filesets $tcl_obj]]] == 0 } {
  1401. lappend l_script_data "# Empty (no sources present)\n"
  1402. return
  1403. }
  1404. set fs_name [get_filesets $tcl_obj]
  1405. set import_coln [list]
  1406. set add_file_coln [list]
  1407. # Create BD wrapper file names (without extensions) to be skipped later
  1408. set bd_wrapper_names {}
  1409. foreach bd_file [get_files *.bd] { lappend bd_wrapper_names [file rootname [file tail $bd_file]]_wrapper }
  1410. foreach file [get_files -quiet -norecurse -of_objects [get_filesets $tcl_obj]] {
  1411. if { [file extension $file] == ".xcix" } { continue }
  1412. # Skip direct import/add of BD files if -use_bd_files is not provided
  1413. if { [file extension $file] == ".bd" && !$a_global_vars(b_arg_use_bd_files) } { continue }
  1414. # Skip generated BD file wrappers
  1415. if { [lsearch -exact $bd_wrapper_names [file rootname [file tail $file]]] != -1 } { continue }
  1416. set path_dirs [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
  1417. set begin [lsearch -exact $path_dirs "$proj_name.srcs"]
  1418. set src_file [join [lrange $path_dirs $begin+1 end] "/"]
  1419. # fetch first object
  1420. set file_object [lindex [get_files -quiet -of_objects [get_filesets $fs_name] [list $file]] 0]
  1421. set file_props [list_property $file_object]
  1422. if { [lsearch $file_props "IMPORTED_FROM"] != -1 } {
  1423. # import files
  1424. set imported_path [get_property "imported_from" $file]
  1425. set rel_file_path [get_relative_file_path_for_source $file [get_script_execution_dir]]
  1426. set proj_file_path "\$\{origin_dir\}/$rel_file_path"
  1427. set file "\"[file normalize $proj_dir/${proj_name}.srcs/$src_file]\""
  1428. if { $a_global_vars(b_arg_no_copy_srcs) } {
  1429. # add to the local collection
  1430. lappend l_remote_file_list $file
  1431. if { $a_global_vars(b_absolute_path) || [need_abs_path $file] } {
  1432. lappend add_file_coln "$file"
  1433. } else {
  1434. lappend add_file_coln "\[file normalize \"$proj_file_path\"\]"
  1435. }
  1436. } else {
  1437. # add to the import collection
  1438. lappend l_local_file_list $file
  1439. if { $a_global_vars(b_absolute_path) || [need_abs_path $file] } {
  1440. lappend import_coln "$file"
  1441. } else {
  1442. lappend import_coln "\[file normalize \"$proj_file_path\"\]"
  1443. }
  1444. }
  1445. } else {
  1446. set file "\"$file\""
  1447. # is local? add to local project, add to collection and then import this collection by default unless -no_copy_sources is specified
  1448. if { [is_local_to_project $file] } {
  1449. if { $a_global_vars(b_arg_dump_proj_info) } {
  1450. set src_file "\$PSRCDIR/$src_file"
  1451. }
  1452. # add to the import collection
  1453. if { $a_global_vars(b_absolute_path)|| [need_abs_path $file] } {
  1454. lappend import_coln $file
  1455. } else {
  1456. set file_no_quotes [string trim $file "\""]
  1457. set org_file_path "\$\{origin_dir\}/[get_relative_file_path_for_source $file_no_quotes [get_script_execution_dir]]"
  1458. lappend import_coln "\[file normalize \"$org_file_path\" \]"
  1459. }
  1460. lappend l_local_file_list $file
  1461. } else {
  1462. if {$a_global_vars(b_absolute_path) || [need_abs_path $file] } {
  1463. lappend add_file_coln [string trim $file "\""]
  1464. } else {
  1465. set file_no_quotes [string trim $file "\""]
  1466. set org_file_path "\$\{origin_dir\}/[get_relative_file_path_for_source $file_no_quotes [get_script_execution_dir]]"
  1467. lappend add_file_coln "\[file normalize \"$org_file_path\"\]"
  1468. }
  1469. lappend l_remote_file_list $file
  1470. }
  1471. }
  1472. }
  1473. # set flag that local sources were found and print warning at the end
  1474. if { (!$a_global_vars(b_local_sources)) && ([llength l_local_file_list] > 0) } {
  1475. set a_global_vars(b_local_sources) 1
  1476. }
  1477. if {[llength $add_file_coln]>0} {
  1478. lappend l_script_data "set files \[list \\"
  1479. foreach file $add_file_coln {
  1480. lappend l_script_data " $file \\"
  1481. }
  1482. lappend l_script_data "\]"
  1483. lappend l_script_data "add_files -norecurse -fileset \$obj \$files"
  1484. lappend l_script_data ""
  1485. }
  1486. # now import local files if -no_copy_sources is not specified
  1487. if { [llength $import_coln] > 0 } {
  1488. if { ! $a_global_vars(b_arg_no_copy_srcs)} {
  1489. lappend l_script_data "# Import local files from the original project"
  1490. lappend l_script_data "set files \[list \\"
  1491. foreach ifile $import_coln {
  1492. lappend l_script_data " $ifile\\"
  1493. }
  1494. lappend l_script_data "\]"
  1495. # is this a IP block fileset? if yes, import files into current source fileset
  1496. if { [is_ip_fileset $tcl_obj] } {
  1497. lappend l_script_data "set imported_files \[import_files -fileset [current_fileset -srcset] \$files\]"
  1498. } else {
  1499. lappend l_script_data "set imported_files \[import_files -fileset $tcl_obj \$files\]"
  1500. }
  1501. } else {
  1502. lappend l_script_data "# Add local files from the original project (-no_copy_sources specified)"
  1503. lappend l_script_data "set files \[list \\"
  1504. foreach ifile $import_coln {
  1505. lappend l_script_data " $ifile\\"
  1506. }
  1507. lappend l_script_data "\]"
  1508. # is this a IP block fileset? if yes, add files into current source fileset
  1509. if { [is_ip_fileset $tcl_obj] } {
  1510. lappend l_script_data "set added_files \[add_files -fileset [current_fileset -srcset] \$files\]"
  1511. } else {
  1512. lappend l_script_data "set added_files \[add_files -fileset $tcl_obj \$files\]"
  1513. }
  1514. }
  1515. lappend l_script_data ""
  1516. }
  1517. # write fileset file properties for remote files (added sources)
  1518. write_fileset_file_properties $tcl_obj $fs_name $proj_dir $l_remote_file_list "remote"
  1519. # write fileset file properties for local files (imported sources)
  1520. write_fileset_file_properties $tcl_obj $fs_name $proj_dir $l_local_file_list "local"
  1521. }
  1522. proc write_constrs { proj_dir proj_name tcl_obj type } {
  1523. # Summary: write constrs fileset files and properties
  1524. # Argument Usage:
  1525. # Return Value:
  1526. # none
  1527. variable a_global_vars
  1528. variable l_script_data
  1529. set fs_name [get_filesets $tcl_obj]
  1530. # return if empty fileset
  1531. if {[llength [get_files -quiet -of_objects [get_filesets $tcl_obj]]] == 0 } {
  1532. lappend l_script_data "# Empty (no sources present)\n"
  1533. return
  1534. }
  1535. foreach file [get_files -quiet -norecurse -of_objects [get_filesets $tcl_obj]] {
  1536. lappend l_script_data "# Add/Import constrs file and set constrs file properties"
  1537. set constrs_file {}
  1538. set file_category {}
  1539. set path_dirs [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
  1540. set begin [lsearch -exact $path_dirs "$proj_name.srcs"]
  1541. set src_file [join [lrange $path_dirs $begin+1 end] "/"]
  1542. set file_object [lindex [get_files -quiet -of_objects [get_filesets $fs_name] [list $file]] 0]
  1543. set file_props [list_property $file_object]
  1544. # constrs sources imported?
  1545. if { [lsearch $file_props "IMPORTED_FROM"] != -1 } {
  1546. set imported_path [get_property "imported_from" $file]
  1547. set rel_file_path [get_relative_file_path_for_source $file [get_script_execution_dir]]
  1548. set proj_file_path \$\{origin_dir\}/$rel_file_path
  1549. set file "\"[file normalize $proj_dir/${proj_name}.srcs/$src_file]\""
  1550. # donot copy imported constrs in new project? set it as remote file in new project.
  1551. if { $a_global_vars(b_arg_no_copy_srcs) } {
  1552. set constrs_file $file
  1553. set file_category "remote"
  1554. if { $a_global_vars(b_absolute_path) || [need_abs_path $imported_path] } {
  1555. add_constrs_file "$file"
  1556. } else {
  1557. set str "\"\[file normalize $proj_file_path\]\""
  1558. add_constrs_file $str
  1559. }
  1560. } else {
  1561. # copy imported constrs in new project. Set it as local file in new project.
  1562. set constrs_file $file
  1563. set file_category "local"
  1564. if { $a_global_vars(b_absolute_path) || [need_abs_path $file] } {
  1565. import_constrs_file $tcl_obj "$file"
  1566. } else {
  1567. set str "\"\[file normalize $proj_file_path\]\""
  1568. import_constrs_file $tcl_obj $str
  1569. }
  1570. }
  1571. } else {
  1572. # constrs sources were added, so check if these are local or added from remote location
  1573. set file "\"$file\""
  1574. set constrs_file $file
  1575. # is added constrs local to the project? import it in the new project and set it as local in the new project
  1576. if { [is_local_to_project $file] } {
  1577. # file is added from within project, so set it as local in the new project
  1578. set file_category "local"
  1579. if { $a_global_vars(b_arg_dump_proj_info) } {
  1580. set src_file "\$PSRCDIR/$src_file"
  1581. }
  1582. set file_no_quotes [string trim $file "\""]
  1583. set org_file_path "\$origin_dir/[get_relative_file_path_for_source $file_no_quotes [get_script_execution_dir]]"
  1584. set str "\"\[file normalize \"$org_file_path\"\]\""
  1585. if { $a_global_vars(b_arg_no_copy_srcs)} {
  1586. add_constrs_file "$str"
  1587. } else {
  1588. import_constrs_file $tcl_obj $str
  1589. }
  1590. } else {
  1591. # file is added from remote location, so set it as remote in the new project
  1592. set file_category "remote"
  1593. # find relative file path of the added constrs if no_copy in the new project
  1594. if { $a_global_vars(b_arg_no_copy_srcs) && (!$a_global_vars(b_absolute_path))&& ![need_abs_path $file] } {
  1595. set file_no_quotes [string trim $file "\""]
  1596. set rel_file_path [get_relative_file_path_for_source $file_no_quotes [get_script_execution_dir]]
  1597. set file_1 "\"\[file normalize \"\$origin_dir/$rel_file_path\"\]\""
  1598. add_constrs_file "$file_1"
  1599. } else {
  1600. add_constrs_file "$file"
  1601. }
  1602. }
  1603. # set flag that local sources were found and print warning at the end
  1604. if { !$a_global_vars(b_local_sources) } {
  1605. set a_global_vars(b_local_sources) 1
  1606. }
  1607. }
  1608. write_constrs_fileset_file_properties $tcl_obj $fs_name $proj_dir $constrs_file $file_category
  1609. }
  1610. }
  1611. proc add_constrs_file { file_str } {
  1612. # Summary: add constrs file
  1613. # This helper command is used to script help.
  1614. # Argument Usage:
  1615. # Return Value:
  1616. # none
  1617. variable a_global_vars
  1618. variable l_script_data
  1619. if { $a_global_vars(b_absolute_path) || [need_abs_path $file_str]} {
  1620. lappend l_script_data "set file $file_str"
  1621. } else {
  1622. if { $a_global_vars(b_arg_no_copy_srcs) } {
  1623. lappend l_script_data "set file $file_str"
  1624. } else {
  1625. set file_no_quotes [string trim $file_str "\""]
  1626. set rel_file_path [get_relative_file_path_for_source $file_no_quotes [get_script_execution_dir]]
  1627. lappend l_script_data "set file \"\[file normalize \"\$origin_dir/$rel_file_path\"\]\""
  1628. }
  1629. }
  1630. lappend l_script_data "set file_added \[add_files -norecurse -fileset \$obj \[list \$file\]\]"
  1631. }
  1632. proc import_constrs_file { tcl_obj file_str } {
  1633. # Summary: import constrs file
  1634. # This helper command is used to script help.
  1635. # Argument Usage:
  1636. # Return Value:
  1637. # none
  1638. variable a_global_vars
  1639. variable l_script_data
  1640. # now import local files if -no_copy_sources is not specified
  1641. if { ! $a_global_vars(b_arg_no_copy_srcs)} {
  1642. lappend l_script_data "set file $file_str"
  1643. lappend l_script_data "set file_imported \[import_files -fileset $tcl_obj \[list \$file\]\]"
  1644. }
  1645. }
  1646. proc write_constrs_fileset_file_properties { tcl_obj fs_name proj_dir file file_category } {
  1647. # Summary: write constrs fileset file properties
  1648. # This helper command is used to script help.
  1649. # Argument Usage:
  1650. # Return Value:
  1651. # none
  1652. variable a_global_vars
  1653. variable l_script_data
  1654. variable l_local_files
  1655. variable l_remote_files
  1656. set file_prop_count 0
  1657. # collect local/remote files for the header section
  1658. if { [string equal $file_category "local"] } {
  1659. lappend l_local_files $file
  1660. } elseif { [string equal $file_category "remote"] } {
  1661. lappend l_remote_files $file
  1662. }
  1663. set file [string trim $file "\""]
  1664. # fix file path for local files
  1665. if { [string equal $file_category "local"] } {
  1666. set path_dirs [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
  1667. set src_file [join [lrange $path_dirs end-1 end] "/"]
  1668. set src_file [string trimleft $src_file "/"]
  1669. set src_file [string trimleft $src_file "\\"]
  1670. set file $src_file
  1671. }
  1672. set file_object ""
  1673. if { [string equal $file_category "local"] } {
  1674. set file_object [lindex [get_files -quiet -of_objects [get_filesets $fs_name] [list "*$file"]] 0]
  1675. } elseif { [string equal $file_category "remote"] } {
  1676. set file_object [lindex [get_files -quiet -of_objects [get_filesets $fs_name] [list $file]] 0]
  1677. }
  1678. # get the constrs file properties
  1679. set file_props [list_property $file_object]
  1680. set prop_info_list [list]
  1681. set prop_count 0
  1682. foreach file_prop $file_props {
  1683. set is_readonly [get_property is_readonly [rdi::get_attr_specs $file_prop -object $file_object]]
  1684. if { [string equal $is_readonly "1"] } {
  1685. continue
  1686. }
  1687. set prop_type [get_property type [rdi::get_attr_specs $file_prop -object $file_object]]
  1688. set def_val [list_property_value -default $file_prop $file_object]
  1689. set cur_val [get_property $file_prop $file_object]
  1690. # filter special properties
  1691. if { [filter $file_prop $cur_val $file] } { continue }
  1692. # re-align values
  1693. set cur_val [get_target_bool_val $def_val $cur_val]
  1694. set dump_prop_name [string tolower ${fs_name}_file_${file_prop}]
  1695. set prop_entry ""
  1696. if { [string equal $file_category "local"] } {
  1697. set prop_entry "[string tolower $file_prop]#[get_property $file_prop $file_object]"
  1698. } elseif { [string equal $file_category "remote"] } {
  1699. set prop_value_entry [get_property $file_prop $file_object]
  1700. set prop_entry "[string tolower $file_prop]#$prop_value_entry"
  1701. }
  1702. # include all properties?
  1703. if { $a_global_vars(b_arg_all_props) } {
  1704. lappend prop_info_list $prop_entry
  1705. incr prop_count
  1706. } else {
  1707. # include only non-default (default behavior)
  1708. if { $def_val != $cur_val } {
  1709. lappend prop_info_list $prop_entry
  1710. incr prop_count
  1711. }
  1712. }
  1713. if { $a_global_vars(b_arg_dump_proj_info) } {
  1714. puts $a_global_vars(def_val_fh) "[file tail $file]=$file_prop ($prop_type) :DEFAULT_VALUE ($def_val)==CURRENT_VALUE ($cur_val)"
  1715. puts $a_global_vars(dp_fh) "$dump_prop_name=$cur_val"
  1716. }
  1717. }
  1718. # write properties now
  1719. if { $prop_count>0 } {
  1720. if { {remote} == $file_category } {
  1721. if { $a_global_vars(b_absolute_path) || [need_abs_path $file]} {
  1722. lappend l_script_data "set file \"$file\""
  1723. } else {
  1724. lappend l_script_data "set file \"\$origin_dir/[get_relative_file_path_for_source $file [get_script_execution_dir]]\""
  1725. lappend l_script_data "set file \[file normalize \$file\]"
  1726. }
  1727. } else {
  1728. lappend l_script_data "set file \"$file\""
  1729. }
  1730. lappend l_script_data "set file_obj \[get_files -of_objects \[get_filesets $tcl_obj\] \[list \"*\$file\"\]\]"
  1731. set get_what "get_files"
  1732. write_properties $prop_info_list $get_what $tcl_obj
  1733. incr file_prop_count
  1734. }
  1735. if { $file_prop_count == 0 } {
  1736. lappend l_script_data "# None"
  1737. }
  1738. }
  1739. proc write_specified_run { proj_dir proj_name runs } {
  1740. # Summary: write the specified run information
  1741. # This helper command is used to script help.
  1742. # Argument Usage:
  1743. # Return Value:
  1744. # none
  1745. variable a_global_vars
  1746. variable l_script_data
  1747. set get_what "get_runs"
  1748. foreach tcl_obj $runs {
  1749. # is block fileset based run that contains IP? donot create OOC run
  1750. if { [is_ip_run $tcl_obj] } {
  1751. continue
  1752. }
  1753. # fetch run attributes
  1754. set part [get_property part [$get_what $tcl_obj]]
  1755. set parent_run [get_property parent [$get_what $tcl_obj]]
  1756. set src_set [get_property srcset [$get_what $tcl_obj]]
  1757. set constrs_set [get_property constrset [$get_what $tcl_obj]]
  1758. set strategy [get_property strategy [$get_what $tcl_obj]]
  1759. set parent_run_str ""
  1760. if { $parent_run != "" } {
  1761. set parent_run_str " -parent_run $parent_run"
  1762. }
  1763. set fileset_type [get_property fileset_type [get_property srcset [$get_what $tcl_obj]]]
  1764. set isImplRun [get_property is_implementation [$get_what $tcl_obj]]
  1765. set isPRProject [get_property pr_flow [current_project]]
  1766. set def_flow_type_val [list_property_value -default flow [$get_what $tcl_obj]]
  1767. set cur_flow_type_val [get_property flow [$get_what $tcl_obj]]
  1768. set def_strat_type_val [list_property_value -default strategy [$get_what $tcl_obj]]
  1769. set cur_strat_type_val [get_property strategy [$get_what $tcl_obj]]
  1770. set isChildImplRun 0
  1771. if { $isPRProject == 1 && $isImplRun == 1 && $parent_run != "" } {
  1772. set isChildImplRun [get_property is_implementation [$get_what $parent_run]]
  1773. if { $isChildImplRun == 1 } {
  1774. set prConfig [get_property pr_configuration [get_runs $tcl_obj]]
  1775. if { [get_pr_configurations $prConfig] == "" } {
  1776. # review this change. Either skip this run creation or flag error while sourcing script...???
  1777. continue
  1778. }
  1779. }
  1780. }
  1781. set cmd_str " create_run -name $tcl_obj -part $part -flow {$cur_flow_type_val} -strategy \"$cur_strat_type_val\""
  1782. set retVal [get_param project.enableReportConfiguration]
  1783. set report_strategy ""
  1784. if { $retVal == 1 } {
  1785. set cmd_str " $cmd_str -report_strategy {No Reports}"
  1786. set report_strategy [get_property report_strategy $tcl_obj]
  1787. }
  1788. if { $isChildImplRun == 1 } {
  1789. set cmd_str " $cmd_str -pr_config $prConfig"
  1790. }
  1791. lappend l_script_data "# Create '$tcl_obj' run (if not found)"
  1792. lappend l_script_data "if \{\[string equal \[get_runs -quiet $tcl_obj\] \"\"\]\} \{"
  1793. lappend l_script_data "$cmd_str -constrset $constrs_set$parent_run_str"
  1794. lappend l_script_data "\} else \{"
  1795. lappend l_script_data " set_property strategy \"$cur_strat_type_val\" \[get_runs $tcl_obj\]"
  1796. lappend l_script_data " set_property flow \"$cur_flow_type_val\" \[get_runs $tcl_obj\]"
  1797. lappend l_script_data "\}"
  1798. if { ($isImplRun == 1) && ($isPRProject == 1 && $isChildImplRun == 0) && ({DesignSrcs} == $fileset_type) } {
  1799. set prConfig [get_property pr_configuration [get_runs $tcl_obj]]
  1800. if { [get_pr_configurations $prConfig] != "" } {
  1801. lappend l_script_data "set_property pr_configuration $prConfig \[get_runs $tcl_obj\]"
  1802. }
  1803. }
  1804. write_report_strategy $tcl_obj $report_strategy
  1805. lappend l_script_data "set obj \[$get_what $tcl_obj\]"
  1806. write_props $proj_dir $proj_name $get_what $tcl_obj "run"
  1807. }
  1808. }
  1809. proc get_fileset_type_switch { fileset_type } {
  1810. # Summary: Return the fileset type switch for a given fileset
  1811. # Argument Usage:
  1812. # Return Value:
  1813. # Fileset type switch name
  1814. variable a_fileset_types
  1815. set fs_switch ""
  1816. foreach {fs_data} $a_fileset_types {
  1817. set fs_type [lindex $fs_data 0]
  1818. if { [string equal -nocase $fileset_type $fs_type] } {
  1819. set fs_switch [lindex $fs_data 1]
  1820. set fs_switch "-$fs_switch"
  1821. break
  1822. }
  1823. }
  1824. return $fs_switch
  1825. }
  1826. proc get_target_bool_val { def_val cur_val } {
  1827. # Summary: Resolve current boolean property value wrt its default value
  1828. # Argument Usage:
  1829. # Return Value:
  1830. # Resolved boolean value
  1831. set target_val $cur_val
  1832. if { [string equal $def_val "false"] && [string equal $cur_val "0"] } { set target_val "false" } \
  1833. elseif { [string equal $def_val "true"] && [string equal $cur_val "1"] } { set target_val "true" } \
  1834. elseif { [string equal $def_val "false"] && [string equal $cur_val "1"] } { set target_val "true" } \
  1835. elseif { [string equal $def_val "true"] && [string equal $cur_val "0"] } { set target_val "false" } \
  1836. elseif { [string equal $def_val "{}"] && [string equal $cur_val ""] } { set target_val "{}" }
  1837. return $target_val
  1838. }
  1839. proc write_fileset_file_properties { tcl_obj fs_name proj_dir l_file_list file_category } {
  1840. # Summary:
  1841. # Write fileset file properties for local and remote files
  1842. # Argument Usage:
  1843. # tcl_obj: object to inspect
  1844. # fs_name: fileset name
  1845. # l_file_list: list of files (local or remote)
  1846. # file_category: file catwgory (local or remote)
  1847. # Return Value:
  1848. # none
  1849. variable a_global_vars
  1850. variable l_script_data
  1851. variable l_local_files
  1852. variable l_remote_files
  1853. # is this a IP block fileset? if yes, set current source fileset
  1854. if { [is_ip_fileset $tcl_obj] } {
  1855. lappend l_script_data "# Set '[current_fileset -srcset]' fileset file properties for $file_category files"
  1856. } else {
  1857. lappend l_script_data "# Set '$tcl_obj' fileset file properties for $file_category files"
  1858. }
  1859. set file_prop_count 0
  1860. # collect local/remote files
  1861. foreach file $l_file_list {
  1862. if { [string equal $file_category "local"] } {
  1863. lappend l_local_files $file
  1864. } elseif { [string equal $file_category "remote"] } {
  1865. lappend l_remote_files $file
  1866. } else {}
  1867. }
  1868. foreach file $l_file_list {
  1869. set file [string trim $file "\""]
  1870. # fix file path for local files
  1871. if { [string equal $file_category "local"] } {
  1872. set path_dirs [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
  1873. set src_file [join [lrange $path_dirs end-1 end] "/"]
  1874. set src_file [string trimleft $src_file "/"]
  1875. set src_file [string trimleft $src_file "\\"]
  1876. set file $src_file
  1877. }
  1878. set file_object ""
  1879. if { [string equal $file_category "local"] } {
  1880. set file_object [lindex [get_files -quiet -of_objects [get_filesets $fs_name] [list "*$file"]] 0]
  1881. } elseif { [string equal $file_category "remote"] } {
  1882. set file_object [lindex [get_files -quiet -of_objects [get_filesets $fs_name] [list $file]] 0]
  1883. }
  1884. set file_props [list_property $file_object]
  1885. set prop_info_list [list]
  1886. set prop_count 0
  1887. foreach file_prop $file_props {
  1888. set is_readonly [get_property is_readonly [rdi::get_attr_specs $file_prop -object $file_object]]
  1889. if { [string equal $is_readonly "1"] } {
  1890. continue
  1891. }
  1892. # Fix for CR-939211
  1893. if { ([file extension $file] == ".bd") && ([string equal -nocase $file_prop "generate_synth_checkpoint"] || [string equal -nocase $file_prop "synth_checkpoint_mode"]) } {
  1894. continue
  1895. }
  1896. set prop_type [get_property type [rdi::get_attr_specs $file_prop -object $file_object]]
  1897. set def_val [list_property_value -default $file_prop $file_object]
  1898. set cur_val [get_property $file_prop $file_object]
  1899. # filter special properties
  1900. if { [filter $file_prop $cur_val $file] } { continue }
  1901. # re-align values
  1902. set cur_val [get_target_bool_val $def_val $cur_val]
  1903. set dump_prop_name [string tolower ${fs_name}_file_${file_prop}]
  1904. set prop_entry ""
  1905. if { [string equal $file_category "local"] } {
  1906. set prop_entry "[string tolower $file_prop]#[get_property $file_prop $file_object]"
  1907. } elseif { [string equal $file_category "remote"] } {
  1908. set prop_value_entry [get_property $file_prop $file_object]
  1909. set prop_entry "[string tolower $file_prop]#$prop_value_entry"
  1910. } else {}
  1911. if { $a_global_vars(b_arg_all_props) } {
  1912. lappend prop_info_list $prop_entry
  1913. incr prop_count
  1914. } else {
  1915. if { $def_val != $cur_val } {
  1916. lappend prop_info_list $prop_entry
  1917. incr prop_count
  1918. }
  1919. }
  1920. if { $a_global_vars(b_arg_dump_proj_info) } {
  1921. puts $a_global_vars(def_val_fh) "[file tail $file]=$file_prop ($prop_type) :DEFAULT_VALUE ($def_val)==CURRENT_VALUE ($cur_val)"
  1922. puts $a_global_vars(dp_fh) "$dump_prop_name=$cur_val"
  1923. }
  1924. }
  1925. # write properties now
  1926. if { $prop_count>0 } {
  1927. if { {remote} == $file_category } {
  1928. if { $a_global_vars(b_absolute_path) || [need_abs_path $file]} {
  1929. lappend l_script_data "set file \"$file\""
  1930. } else {
  1931. lappend l_script_data "set file \"\$origin_dir/[get_relative_file_path_for_source $file [get_script_execution_dir]]\""
  1932. lappend l_script_data "set file \[file normalize \$file\]"
  1933. }
  1934. } else {
  1935. lappend l_script_data "set file \"$file\""
  1936. }
  1937. # is this a IP block fileset? if yes, get files from current source fileset
  1938. if { [is_ip_fileset $tcl_obj] } {
  1939. lappend l_script_data "set file_obj \[get_files -of_objects \[get_filesets [current_fileset -srcset]\] \[list \"*\$file\"\]\]"
  1940. } else {
  1941. lappend l_script_data "set file_obj \[get_files -of_objects \[get_filesets $tcl_obj\] \[list \"*\$file\"\]\]"
  1942. }
  1943. set get_what "get_files"
  1944. write_properties $prop_info_list $get_what $tcl_obj
  1945. incr file_prop_count
  1946. }
  1947. }
  1948. if { $file_prop_count == 0 } {
  1949. lappend l_script_data "# None"
  1950. }
  1951. lappend l_script_data ""
  1952. }
  1953. proc get_script_execution_dir { } {
  1954. # Summary: Return script directory path from where the script will be executed
  1955. # Argument Usage:
  1956. # none
  1957. # Return Value:
  1958. # Path to the script direc
  1959. variable a_global_vars
  1960. # default: return script directory path
  1961. set scr_exe_dir $a_global_vars(s_path_to_script_dir)
  1962. # is -path_to_relative specified and the path exists? return this dir
  1963. set rel_to_dir $a_global_vars(s_relative_to)
  1964. if { ("." != $rel_to_dir) } {
  1965. set rel_to_dir [file normalize $rel_to_dir]
  1966. if { [file exists $rel_to_dir] } {
  1967. set scr_exe_dir $rel_to_dir
  1968. }
  1969. }
  1970. return $scr_exe_dir
  1971. }
  1972. # TODO: This is the same as xcs_get_relative_file_path for simulators, see common/utils.tcl
  1973. # Remember to add the 'source .../common/utils.tcl' in the write_project_tcl proc to load the common file
  1974. proc get_relative_file_path_for_source { file_path_to_convert relative_to } {
  1975. # Summary: Get the relative path wrt to path specified
  1976. # Argument Usage:
  1977. # file_path_to_convert: input file to make relative to specfied path
  1978. # Return Value:
  1979. # Relative path wrt the path specified
  1980. variable a_xport_sim_vars
  1981. # make sure we are dealing with a valid relative_to directory. If regular file or is not a directory, get directory
  1982. if { [file isfile $relative_to] || ![file isdirectory $relative_to] } {
  1983. set relative_to [file dirname $relative_to]
  1984. }
  1985. set cwd [file normalize [pwd]]
  1986. if { [file pathtype $file_path_to_convert] eq "relative" } {
  1987. # is relative_to path same as cwd?, just return this path, no further processing required
  1988. if { [string equal $relative_to $cwd] } {
  1989. return $file_path_to_convert
  1990. }
  1991. # the specified path is "relative" but something else, so make it absolute wrt current working dir
  1992. set file_path_to_convert [file join $cwd $file_path_to_convert]
  1993. }
  1994. # is relative_to "relative"? convert to absolute as well wrt cwd
  1995. if { [file pathtype $relative_to] eq "relative" } {
  1996. set relative_to [file join $cwd $relative_to]
  1997. }
  1998. # normalize
  1999. set file_path_to_convert [file normalize $file_path_to_convert]
  2000. set relative_to [file normalize $relative_to]
  2001. set file_path $file_path_to_convert
  2002. set file_comps [file split $file_path]
  2003. set relative_to_comps [file split $relative_to]
  2004. set found_match false
  2005. set index 0
  2006. set fc_comps_len [llength $file_comps]
  2007. set rt_comps_len [llength $relative_to_comps]
  2008. # compare each dir element of file_to_convert and relative_to, set the flag and
  2009. # get the final index till these sub-dirs matched. Break if limit reaches.
  2010. while { [lindex $file_comps $index] == [lindex $relative_to_comps $index] } {
  2011. if { !$found_match } { set found_match true }
  2012. incr index
  2013. if { ($index == $fc_comps_len) || ($index == $rt_comps_len) } {
  2014. break;
  2015. }
  2016. }
  2017. # any common dirs found? convert path to relative
  2018. if { $found_match } {
  2019. set parent_dir_path ""
  2020. set rel_index $index
  2021. # keep traversing the relative_to dirs and build "../" levels
  2022. while { [lindex $relative_to_comps $rel_index] != "" } {
  2023. set parent_dir_path "../$parent_dir_path"
  2024. incr rel_index
  2025. }
  2026. #
  2027. # at this point we have parent_dir_path setup with exact number of sub-dirs to go up
  2028. #
  2029. # now build up part of path which is relative to matched part
  2030. set rel_path ""
  2031. set rel_index $index
  2032. while { [lindex $file_comps $rel_index] != "" } {
  2033. set comps [lindex $file_comps $rel_index]
  2034. if { $rel_path == "" } {
  2035. # first dir
  2036. set rel_path $comps
  2037. } else {
  2038. # append remaining dirs
  2039. set rel_path "${rel_path}/$comps"
  2040. }
  2041. incr rel_index
  2042. }
  2043. # prepend parent dirs, this is the complete resolved path now
  2044. set resolved_path "${parent_dir_path}${rel_path}"
  2045. return $resolved_path
  2046. }
  2047. # no common dirs found, just return the normalized path
  2048. return $file_path
  2049. }
  2050. proc is_ip_fileset { fileset } {
  2051. # Summary: Find IP's if any from the specified fileset and return true if 'generate_synth_checkpoint' is set to 1
  2052. # Argument Usage:
  2053. # fileset: fileset name
  2054. # Return Value:
  2055. # true (1) if success, false (0) otherwise
  2056. # make sure fileset is block fileset type
  2057. set isPRFlow [get_property pr_flow [current_project]]
  2058. set isRMFileset 0
  2059. if { $isPRFlow == 1 } {
  2060. set allReconfigModules [get_reconfig_modules]
  2061. foreach reconfigmodule $allReconfigModules {
  2062. set rmFileset [get_filesets -of_objects [get_reconfig_modules $reconfigmodule]]
  2063. if { [string equal $rmFileset $fileset] } {
  2064. set isRMFileset 1
  2065. break
  2066. }
  2067. }
  2068. }
  2069. if { $isRMFileset == 1 } {
  2070. return false
  2071. }
  2072. if { {BlockSrcs} != [get_property fileset_type [get_filesets $fileset]] } {
  2073. return false
  2074. }
  2075. set ip_filter "FILE_TYPE == \"IP\" || FILE_TYPE==\"Block Designs\""
  2076. set ips [get_files -all -quiet -of_objects [get_filesets $fileset] -filter $ip_filter]
  2077. set b_found false
  2078. foreach ip $ips {
  2079. if { [get_property generate_synth_checkpoint [lindex [get_files -quiet -all [list "$ip"]] 0]] } {
  2080. set b_found true
  2081. break
  2082. }
  2083. }
  2084. if { $b_found } {
  2085. return true
  2086. }
  2087. return false
  2088. }
  2089. proc is_proxy_ip_fileset { fileset } {
  2090. # Summary: Determine if the fileset is an OOC run for a proxy IP that has a parent composite
  2091. # Argument Usage:
  2092. # fileset: fileset name
  2093. # Return Value:
  2094. # true (1) if the fileset contains an IP at its root with a parent composite, false (0) otherwise
  2095. # make sure fileset is block fileset type
  2096. if { {BlockSrcs} != [get_property fileset_type [get_filesets $fileset]] } {
  2097. return false
  2098. }
  2099. set ip_with_parent_filter "FILE_TYPE == IP && PARENT_COMPOSITE_FILE != \"\""
  2100. if {[llength [get_files -norecurse -quiet -of_objects [get_filesets $fileset] -filter $ip_with_parent_filter]] == 1} {
  2101. return true
  2102. }
  2103. return false
  2104. }
  2105. proc is_ip_run { run } {
  2106. # Summary: Find IP's if any from the fileset linked with the block fileset run
  2107. # Argument Usage:
  2108. # run: run name
  2109. # Return Value:
  2110. # true (1) if success, false (0) otherwise
  2111. set fileset [get_property srcset [get_runs $run]]
  2112. return [is_ip_fileset $fileset]
  2113. }
  2114. proc is_win_os {} {
  2115. # Summary: Determine if OS is Windows
  2116. # Return Value:
  2117. # true (1) if windows, false (0) otherwise
  2118. set os [lindex $::tcl_platform(os) 0]
  2119. set plat [lindex $::tcl_platform(platform) 0]
  2120. if { [string compare -nocase -length 3 $os "win"] == 0 ||
  2121. [string compare -nocase -length 3 $plat "win"] == 0 } {
  2122. return true
  2123. } else { return false }
  2124. }
  2125. proc need_abs_path { src } {
  2126. # Summary: Determine if src provided is in a different network mount than execution directory
  2127. # Argument Usage:
  2128. # src: source file to check
  2129. # Return Value:
  2130. # true (1) if src is in a different drive than script execution directory, false (0) otherwise
  2131. variable a_os
  2132. if { $a_os eq "win" } {
  2133. set src_path [file normalize [string trim $src "\""]]
  2134. set ref_path [file normalize [get_script_execution_dir]]
  2135. if { [string compare -nocase -length 2 $src_path $ref_path] != 0 } {
  2136. return true;
  2137. }
  2138. }
  2139. return false
  2140. }
  2141. proc wr_dashboards { proj_dir proj_name } {
  2142. # Summary: write dashboards and properties
  2143. # This helper command is used to script help.
  2144. # Argument Usage:
  2145. # proj_name: project name
  2146. # Return Value:
  2147. # None
  2148. # get current dash board
  2149. # get all dash boards
  2150. # For each dash boards
  2151. # create dash board
  2152. write_specified_dashboard $proj_dir $proj_name
  2153. }
  2154. proc write_specified_gadget { proj_dir proj_name gadget } {
  2155. # Summary: write the specified gadget
  2156. # This helper command is used to script help.
  2157. # Argument Usage:
  2158. # Return Value:
  2159. # none
  2160. variable l_script_data
  2161. set gadgetName [get_property name [get_dashboard_gadgets [list "$gadget"]]]
  2162. set gadgetType [get_property type [get_dashboard_gadgets [list "$gadget"]]]
  2163. set cmd_str "create_dashboard_gadget -name {$gadgetName} -type $gadgetType"
  2164. lappend l_script_data "# Create '$gadgetName' gadget (if not found)"
  2165. lappend l_script_data "if \{\[string equal \[get_dashboard_gadgets \[ list \"$gadget\" \] \] \"\"\]\} \{"
  2166. lappend l_script_data "$cmd_str"
  2167. lappend l_script_data "\}"
  2168. lappend l_script_data "set obj \[get_dashboard_gadgets \[ list \"$gadget\" \] \]"
  2169. set tcl_obj [get_dashboard_gadgets [list "$gadget"] ]
  2170. set get_what "get_dashboard_gadgets "
  2171. write_props $proj_dir $proj_name $get_what $tcl_obj "gadget" "$"
  2172. }
  2173. proc write_specified_dashboard { proj_dir proj_name } {
  2174. # Summary: write the specified dashboard
  2175. # This helper command is used to script help.
  2176. # Argument Usage:
  2177. # Return Value:
  2178. # none
  2179. variable l_script_data
  2180. #Create map of gadgets wrt to their position, so that gadget position can be restored.
  2181. set gadgetPositionMap [dict create]
  2182. ##get gadgets of this dashboard
  2183. set gadgets [get_dashboard_gadgets ]
  2184. foreach gd $gadgets {
  2185. write_specified_gadget $proj_dir $proj_name $gd
  2186. set gadgetCol [get_property COL [get_dashboard_gadgets [list "$gd"]]]
  2187. set gadgetRow [get_property ROW [get_dashboard_gadgets [list "$gd"]]]
  2188. dict set gadgetPositionMap $gadgetCol $gadgetRow $gd
  2189. }
  2190. #if current dashboard is "default_dashboard"
  2191. #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.
  2192. set default_gadgets {"drc_1" "methodology_1" "power_1" "timing_1" "utilization_1" "utilization_2"}
  2193. foreach dgd $default_gadgets {
  2194. #if dgd is not in gadgets, then delete dgd
  2195. if {$dgd ni $gadgets } {
  2196. lappend l_script_data "# Delete the gadget '$dgd' "
  2197. lappend l_script_data "if \{\[string equal \[get_dashboard_gadgets \[ list \"$dgd\" \] \] \"$dgd\"\]\} \{"
  2198. set cmd_str "delete_dashboard_gadgets -gadgets $dgd"
  2199. lappend l_script_data "$cmd_str"
  2200. lappend l_script_data "\}"
  2201. }
  2202. }
  2203. foreach col [lsort [dict keys $gadgetPositionMap]] {
  2204. set rowDict [dict get $gadgetPositionMap $col]
  2205. foreach row [lsort [dict keys $rowDict]] {
  2206. set gadgetName [dict get $rowDict $row]
  2207. set cmd_str "move_dashboard_gadget -name {$gadgetName} -row $row -col $col"
  2208. lappend l_script_data "$cmd_str"
  2209. }
  2210. }
  2211. }
  2212. proc wr_prflow { proj_dir proj_name } {
  2213. # Summary: write partial reconfiguration and properties
  2214. # This helper command is used to script help.
  2215. # Argument Usage:
  2216. # proj_name: project name
  2217. # Return Value:
  2218. # None
  2219. if { [get_property pr_flow [current_project]] == 0 } {
  2220. return
  2221. }
  2222. # write below properties only if it's a pr project
  2223. wr_pdefs $proj_dir $proj_name
  2224. wr_reconfigModules $proj_dir $proj_name
  2225. wr_prConf $proj_dir $proj_name
  2226. }
  2227. proc wr_pdefs { proj_dir proj_name } {
  2228. # Summary: write partial reconfiguration and properties
  2229. # This helper command is used to script help.
  2230. # Argument Usage:
  2231. # proj_name: project name
  2232. # Return Value:
  2233. # None
  2234. # write pDef i.e. create partition def
  2235. set partitionDefs [get_partition_def]
  2236. foreach partitionDef $partitionDefs {
  2237. write_specified_partition_definition $proj_dir $proj_name $partitionDef
  2238. }
  2239. }
  2240. proc write_specified_partition_definition { proj_dir proj_name pDef } {
  2241. # Summary: write the specified partition definition
  2242. # This helper command is used to script help.
  2243. # Argument Usage:
  2244. # Return Value:
  2245. # none
  2246. variable l_script_data
  2247. set get_what "get_partition_defs"
  2248. set pdefName [get_property name [$get_what $pDef]]
  2249. set moduleName [get_property module_name [$get_what $pDef]]
  2250. set pdef_library [get_property library [$get_what $pDef]]
  2251. set default_library [get_property default_lib [current_project]]
  2252. set cmd_str "create_partition_def -name $pdefName -module $moduleName"
  2253. if { ($pdef_library != "") && (![string equal $pdef_library $default_library]) } {
  2254. set cmd_str "$cmd_str -library $pdef_library"
  2255. }
  2256. lappend l_script_data "# Create '$pdefName' partition definition"
  2257. lappend l_script_data "$cmd_str"
  2258. lappend l_script_data "set obj \[$get_what $pDef\]"
  2259. write_props $proj_dir $proj_name $get_what $pDef "partitionDef"
  2260. }
  2261. proc wr_reconfigModules { proj_dir proj_name } {
  2262. # Summary: write reconfiguration modules for RPs
  2263. # This helper command is used to script help.
  2264. # Argument Usage:
  2265. # proj_name: project name
  2266. # Return Value:
  2267. # None
  2268. # write reconfigurations modules
  2269. set reconfigModules [get_reconfig_modules]
  2270. variable a_global_vars
  2271. # associate a bd with rm to be used with write_specified_reconfig_module
  2272. set bd_rm_map [dict create]
  2273. foreach rm $reconfigModules {
  2274. set rm_bds [get_files -norecurse -quiet -of_objects [get_reconfig_modules $rm] *.bd]
  2275. foreach rm_bd1 $rm_bds {
  2276. dict set bd_rm_map $rm_bd1 $rm
  2277. }
  2278. }
  2279. set done_bds [list]
  2280. foreach rm $reconfigModules {
  2281. set rm_bds [get_files -norecurse -quiet -of_objects [get_reconfig_modules $rm] *.bd]
  2282. # get the dependent bd for a rm and process it first, this is required for 2RP support
  2283. set rm_bd_dep [lindex [get_files -references -quiet -of_objects [get_reconfig_modules $rm] *.bd] 0]
  2284. if {[llength $rm_bd_dep] == 1} {
  2285. if {$rm_bd ni $done_bds} {
  2286. if { !$a_global_vars(b_arg_use_bd_files) } {
  2287. write_bd_as_proc $rm_bd_dep
  2288. }
  2289. set rm1 [dict get $bd_rm_map $rm_bd_dep]
  2290. write_specified_reconfig_module $proj_dir $proj_name $rm1
  2291. lappend done_bds $rm_bd_dep
  2292. }
  2293. }
  2294. foreach rm_bd $rm_bds {
  2295. # process bd only if it has not already been processed
  2296. if {$rm_bd ni $done_bds} {
  2297. if { !$a_global_vars(b_arg_use_bd_files) } {
  2298. write_bd_as_proc $rm_bd
  2299. }
  2300. set rm1 [dict get $bd_rm_map $rm_bd]
  2301. write_specified_reconfig_module $proj_dir $proj_name $rm1
  2302. lappend done_bds $rm_bd
  2303. }
  2304. }
  2305. # when no RM BDs are present
  2306. if {[llength $rm_bds] == 0} {
  2307. write_specified_reconfig_module $proj_dir $proj_name $rm
  2308. }
  2309. }
  2310. }
  2311. proc write_specified_reconfig_module { proj_dir proj_name reconfModule } {
  2312. # Summary: write the specified partial reconfiguration module information
  2313. # This helper command is used to script help.
  2314. # Argument Usage:
  2315. # Return Value:
  2316. # none
  2317. variable l_script_data
  2318. set get_what "get_reconfig_modules"
  2319. # fetch all the run attritubes and properties of passed reconfig modules
  2320. set name [get_property name [$get_what $reconfModule]]
  2321. set partitionDefName [get_property partition_def [$get_what $reconfModule]]
  2322. set isGateLevelSet [get_property is_gate_level [$get_what $reconfModule]]
  2323. lappend l_script_data "# Create '$reconfModule' reconfigurable module"
  2324. lappend l_script_data "set partitionDef \[get_partition_defs $partitionDefName\]"
  2325. if { $isGateLevelSet } {
  2326. set moduleName [get_property module_name [$get_what $reconfModule]]
  2327. if { $moduleName == "" } {
  2328. return
  2329. }
  2330. lappend l_script_data "create_reconfig_module -name $name -top $moduleName -partition_def \$partitionDef -gate_level"
  2331. } else {
  2332. lappend l_script_data "create_reconfig_module -name $name -partition_def \$partitionDef"
  2333. }
  2334. # write default_rm property for pDef if RM and its corresponding property for pDef->defaultRM is same
  2335. set defaultRM_for_pDef [get_property default_rm [get_partition_def $partitionDefName]]
  2336. if { [string equal $reconfModule $defaultRM_for_pDef] } {
  2337. lappend l_script_data "set_property default_rm $reconfModule \$partitionDef"
  2338. }
  2339. lappend l_script_data "set obj \[$get_what $reconfModule\]"
  2340. write_props $proj_dir $proj_name $get_what $reconfModule "reconfigModule"
  2341. write_reconfigmodule_files $proj_dir $proj_name $reconfModule
  2342. }
  2343. proc wr_prConf {proj_dir proj_name} {
  2344. # Summary: write reconfiguration modules for RPs
  2345. # This helper command is used to script help.
  2346. # Argument Usage:
  2347. # proj_name: project name
  2348. # Return Value:
  2349. # None
  2350. # write pr configurations
  2351. set prConfigurations [get_pr_configurations]
  2352. foreach prConfig $prConfigurations {
  2353. write_specified_prConfiguration $proj_dir $proj_name $prConfig
  2354. }
  2355. }
  2356. proc write_specified_prConfiguration { proj_dir proj_name prConfig } {
  2357. # Summary: write the specified pr reconfiguration
  2358. # This helper command is used to script help.
  2359. # Argument Usage:
  2360. # Return Value:
  2361. # none
  2362. variable l_script_data
  2363. set get_what "get_pr_configurations"
  2364. # fetch pr config properties
  2365. set name [get_property name [$get_what $prConfig]]
  2366. lappend l_script_data "# Create '$prConfig' pr configurations"
  2367. lappend l_script_data "create_pr_configuration -name $name"
  2368. lappend l_script_data "set obj \[$get_what $prConfig\]"
  2369. write_props $proj_dir $proj_name $get_what $prConfig "prConfiguration"
  2370. }
  2371. proc write_reconfigmodule_files { proj_dir proj_name reconfigModule } {
  2372. # Summary: write file and file properties
  2373. # This helper command is used to script help.
  2374. # Argument Usage:
  2375. # Return Value:
  2376. # none
  2377. variable a_global_vars
  2378. variable l_script_data
  2379. set l_local_file_list [list]
  2380. set l_remote_file_list [list]
  2381. # return if empty fileset
  2382. if {[llength [get_files -quiet -norecurse -of_objects [get_filesets -of_objects $reconfigModule]]] == 0 } {
  2383. lappend l_script_data "# Empty (no sources present)\n"
  2384. return
  2385. }
  2386. set fileset [get_filesets -of_objects $reconfigModule]
  2387. set fs_name [get_property name $fileset]
  2388. set import_coln [list]
  2389. set add_file_coln [list]
  2390. set bd_list [list]
  2391. foreach file [get_files -quiet -norecurse -of_objects [get_filesets -of_objects $reconfigModule]] {
  2392. if { [file extension $file ] ==".bd" && !$a_global_vars(b_arg_use_bd_files)} {
  2393. lappend bd_list $file
  2394. continue
  2395. }
  2396. set path_dirs [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
  2397. set begin [lsearch -exact $path_dirs "$proj_name.srcs"]
  2398. set src_file [join [lrange $path_dirs $begin+1 end] "/"]
  2399. # fetch first object
  2400. set file_object [lindex [get_files -quiet -norecurse -of_objects [get_filesets -of_objects $reconfigModule] [list $file]] 0]
  2401. set file_props [list_property $file_object]
  2402. if { [lsearch $file_props "IMPORTED_FROM"] != -1 } {
  2403. # import files
  2404. set imported_path [get_property "imported_from" $file]
  2405. set rel_file_path [get_relative_file_path_for_source $file [get_script_execution_dir]]
  2406. set proj_file_path "\$origin_dir/$rel_file_path"
  2407. set file "\"[file normalize $proj_dir/${proj_name}.srcs/$src_file]\""
  2408. if { $a_global_vars(b_arg_no_copy_srcs) } {
  2409. # add to the local collection
  2410. lappend l_remote_file_list $file
  2411. if { $a_global_vars(b_absolute_path) || [need_abs_path $file]} {
  2412. lappend add_file_coln "$file"
  2413. } else {
  2414. lappend add_file_coln "\"\[file normalize \"$proj_file_path\"\]\""
  2415. }
  2416. } else {
  2417. # add to the import collection
  2418. lappend l_local_file_list $file
  2419. if { $a_global_vars(b_absolute_path) || [need_abs_path $file]} {
  2420. lappend import_coln "$file"
  2421. } else {
  2422. lappend import_coln "\"\[file normalize \"$proj_file_path\"\]\""
  2423. }
  2424. }
  2425. } else {
  2426. set file "\"$file\""
  2427. # is local? add to local project, add to collection and then import this collection by default unless -no_copy_sources is specified
  2428. if { [is_local_to_project $file] } {
  2429. if { $a_global_vars(b_arg_dump_proj_info) } {
  2430. set src_file "\$PSRCDIR/$src_file"
  2431. }
  2432. # add to the import collection
  2433. set file_no_quotes [string trim $file "\""]
  2434. set org_file_path "\$origin_dir/[get_relative_file_path_for_source $file_no_quotes [get_script_execution_dir]]"
  2435. lappend import_coln "\"\[file normalize \"$org_file_path\"\]\""
  2436. lappend l_local_file_list $file
  2437. } else {
  2438. lappend l_remote_file_list $file
  2439. }
  2440. # add file to collection
  2441. if { $a_global_vars(b_arg_no_copy_srcs) && (!$a_global_vars(b_absolute_path)) && ![need_abs_path $file]} {
  2442. set file_no_quotes [string trim $file "\""]
  2443. set rel_file_path [get_relative_file_path_for_source $file_no_quotes [get_script_execution_dir]]
  2444. set file1 "\"\[file normalize \"\$origin_dir/$rel_file_path\"\]\""
  2445. lappend add_file_coln "$file1"
  2446. } else {
  2447. lappend add_file_coln "$file"
  2448. }
  2449. }
  2450. }
  2451. if {[llength $bd_list] > 0 } {
  2452. foreach bd_file $bd_list {
  2453. set filename [file tail $bd_file]
  2454. lappend l_script_data " move_files \[ get_files $filename \] -of_objects \[get_reconfig_modules $reconfigModule\]"
  2455. }
  2456. }
  2457. if {[llength $add_file_coln]>0} {
  2458. lappend l_script_data "set files \[list \\"
  2459. foreach file $add_file_coln {
  2460. if { $a_global_vars(b_absolute_path) || [need_abs_path $file]} {
  2461. lappend l_script_data " $file\\"
  2462. } else {
  2463. if { $a_global_vars(b_arg_no_copy_srcs) } {
  2464. lappend l_script_data " $file\\"
  2465. } else {
  2466. set file_no_quotes [string trim $file "\""]
  2467. set rel_file_path [get_relative_file_path_for_source $file_no_quotes [get_script_execution_dir]]
  2468. lappend l_script_data " \"\[file normalize \"\$origin_dir/$rel_file_path\"\]\"\\"
  2469. }
  2470. }
  2471. }
  2472. lappend l_script_data "\]"
  2473. lappend l_script_data "add_files -norecurse -of_objects \[get_reconfig_modules $reconfigModule\] \$files"
  2474. lappend l_script_data ""
  2475. }
  2476. # now import local files if -no_copy_sources is not specified
  2477. if { ! $a_global_vars(b_arg_no_copy_srcs)} {
  2478. if { [llength $import_coln] > 0 } {
  2479. lappend l_script_data "# Import local files from the original project"
  2480. lappend l_script_data "set files \[list \\"
  2481. foreach ifile $import_coln {
  2482. lappend l_script_data " $ifile\\"
  2483. }
  2484. lappend l_script_data "\]"
  2485. lappend l_script_data "import_files -of_objects \[get_reconfig_modules $reconfigModule\] \$files"
  2486. lappend l_script_data ""
  2487. }
  2488. }
  2489. # write fileset file properties for remote files (added sources)
  2490. write_reconfigmodule_file_properties $reconfigModule $fs_name $proj_dir $l_remote_file_list "remote"
  2491. # write fileset file properties for local files (imported sources)
  2492. write_reconfigmodule_file_properties $reconfigModule $fs_name $proj_dir $l_local_file_list "local"
  2493. # move sub-design files (XCI/BD) of reconfig modules from sources fileset to reconfig-module (RM) fileset
  2494. add_reconfigmodule_subdesign_files $reconfigModule
  2495. }
  2496. proc add_reconfigmodule_subdesign_files { reconfigModule } {
  2497. # Summary:
  2498. # Argument Usage:
  2499. # Return Value:
  2500. variable l_script_data
  2501. foreach rmSubdesignFileset [get_property subdesign_filesets $reconfigModule] {
  2502. foreach fileObj [get_files -quiet -norecurse -of_objects [get_filesets $rmSubdesignFileset]] {
  2503. set path_dirs [split [string trim [file normalize [string map {\\ /} $fileObj ]]] "/"]
  2504. set path [join [lrange $path_dirs end-1 end] "/"]
  2505. set path [string trimleft $path "/"]
  2506. lappend l_script_data "move_files -of_objects \$obj \[get_files *$path\]"
  2507. lappend l_script_data ""
  2508. }
  2509. }
  2510. }
  2511. proc write_reconfigmodule_file_properties { reconfigModule fs_name proj_dir l_file_list file_category } {
  2512. # Summary:
  2513. # Write fileset file properties for local and remote files
  2514. # Argument Usage:
  2515. # reconfigModule : object to inspect
  2516. # fs_name: fileset name
  2517. # l_file_list: list of files (local or remote)
  2518. # file_category: file catwgory (local or remote)
  2519. # Return Value:
  2520. # none
  2521. variable a_global_vars
  2522. variable l_script_data
  2523. variable l_local_files
  2524. variable l_remote_files
  2525. set l_local_files [list]
  2526. set l_remote_files [list]
  2527. set tcl_obj [get_filesets -of_objects $reconfigModule]
  2528. lappend l_script_data "# Set '$reconfigModule' fileset file properties for $file_category files"
  2529. set file_prop_count 0
  2530. # collect local/remote files
  2531. foreach file $l_file_list {
  2532. if { [string equal $file_category "local"] } {
  2533. lappend l_local_files $file
  2534. } elseif { [string equal $file_category "remote"] } {
  2535. lappend l_remote_files $file
  2536. } else {}
  2537. }
  2538. foreach file $l_file_list {
  2539. set file [string trim $file "\""]
  2540. # fix file path for local files
  2541. if { [string equal $file_category "local"] } {
  2542. set path_dirs [split [string trim [file normalize [string map {\\ /} $file]]] "/"]
  2543. set src_file [join [lrange $path_dirs end-1 end] "/"]
  2544. set src_file [string trimleft $src_file "/"]
  2545. set src_file [string trimleft $src_file "\\"]
  2546. set file $src_file
  2547. }
  2548. set file_object ""
  2549. if { [string equal $file_category "local"] } {
  2550. set file_object [lindex [get_files -quiet -norecurse -of_objects [get_filesets -of_objects $reconfigModule] [list "*$file"]] 0]
  2551. } elseif { [string equal $file_category "remote"] } {
  2552. set file_object [lindex [get_files -quiet -norecurse -of_objects [get_filesets -of_objects $reconfigModule] [list $file]] 0]
  2553. }
  2554. set file_props [list_property $file_object]
  2555. set prop_info_list [list]
  2556. set prop_count 0
  2557. foreach file_prop $file_props {
  2558. set is_readonly [get_property is_readonly [rdi::get_attr_specs $file_prop -object $file_object]]
  2559. if { [string equal $is_readonly "1"] } {
  2560. continue
  2561. }
  2562. set prop_type [get_property type [rdi::get_attr_specs $file_prop -object $file_object]]
  2563. set def_val [list_property_value -default $file_prop $file_object]
  2564. set cur_val [get_property $file_prop $file_object]
  2565. # filter special properties
  2566. if { [filter $file_prop $cur_val $file] } { continue }
  2567. # re-align values
  2568. set cur_val [get_target_bool_val $def_val $cur_val]
  2569. set dump_prop_name [string tolower ${fs_name}_file_${file_prop}]
  2570. set prop_entry ""
  2571. if { [string equal $file_category "local"] } {
  2572. set prop_entry "[string tolower $file_prop]#[get_property $file_prop $file_object]"
  2573. } elseif { [string equal $file_category "remote"] } {
  2574. set prop_value_entry [get_property $file_prop $file_object]
  2575. set prop_entry "[string tolower $file_prop]#$prop_value_entry"
  2576. } else {}
  2577. if { $a_global_vars(b_arg_all_props) } {
  2578. lappend prop_info_list $prop_entry
  2579. incr prop_count
  2580. } else {
  2581. if { $def_val != $cur_val } {
  2582. lappend prop_info_list $prop_entry
  2583. incr prop_count
  2584. }
  2585. }
  2586. if { $a_global_vars(b_arg_dump_proj_info) } {
  2587. puts $a_global_vars(def_val_fh) "[file tail $file]=$file_prop ($prop_type) :DEFAULT_VALUE ($def_val)==CURRENT_VALUE ($cur_val)"
  2588. puts $a_global_vars(dp_fh) "$dump_prop_name=$cur_val"
  2589. }
  2590. }
  2591. # write properties now
  2592. if { $prop_count>0 } {
  2593. if { {remote} == $file_category } {
  2594. if { $a_global_vars(b_absolute_path) || [need_abs_path $file]} {
  2595. lappend l_script_data "set file \"$file\""
  2596. } else {
  2597. lappend l_script_data "set file \"\$origin_dir/[get_relative_file_path_for_source $file [get_script_execution_dir]]\""
  2598. lappend l_script_data "set file \[file normalize \$file\]"
  2599. }
  2600. } else {
  2601. lappend l_script_data "set file \"$file\""
  2602. }
  2603. lappend l_script_data "set obj \[get_files -of_objects \[get_reconfig_modules $reconfigModule\] \[list \"*\$file\"\]\]"
  2604. set get_what "get_files -of_objects "
  2605. write_properties $prop_info_list $get_what $tcl_obj
  2606. incr file_prop_count
  2607. }
  2608. }
  2609. if { $file_prop_count == 0 } {
  2610. lappend l_script_data "# None"
  2611. }
  2612. lappend l_script_data ""
  2613. }
  2614. proc write_report_strategy { run report_strategy } {
  2615. # Summary:
  2616. # create report one by one as per its configuration.
  2617. # Argument Usage:
  2618. # run FCO:
  2619. # Return Value: none
  2620. set retVal [get_param project.enableReportConfiguration]
  2621. if { $retVal == 0 } {
  2622. return
  2623. }
  2624. set reports [get_report_configs -of_objects [get_runs $run]]
  2625. if { [llength $reports] == 0 } {
  2626. return
  2627. }
  2628. variable l_script_data
  2629. lappend l_script_data "set obj \[get_runs $run\]"
  2630. lappend l_script_data "set_property set_report_strategy_name 1 \$obj"
  2631. lappend l_script_data "set_property report_strategy {$report_strategy} \$obj"
  2632. lappend l_script_data "set_property set_report_strategy_name 0 \$obj"
  2633. foreach report $reports {
  2634. set report_name [get_property name $report]
  2635. set report_spec [get_property report_type $report]
  2636. set step [get_property run_step $report]
  2637. lappend l_script_data "# Create '$report' report (if not found)"
  2638. lappend l_script_data "if \{ \[ string equal \[get_report_configs -of_objects \[get_runs $run\] $report\] \"\" \] \} \{"
  2639. lappend l_script_data " create_report_config -report_name $report_name -report_type $report_spec -steps $step -runs $run"
  2640. lappend l_script_data "\}"
  2641. lappend l_script_data "set obj \[get_report_configs -of_objects \[get_runs $run\] $report\]"
  2642. lappend l_script_data "if { \$obj != \"\" } {"
  2643. write_report_props $report
  2644. lappend l_script_data "}"
  2645. }
  2646. }
  2647. proc write_report_props { report } {
  2648. # Summary:
  2649. # iterate over all report options and send all non default values to -->set_property <property> <curr_value> [report FCO]
  2650. # Argument Usage:
  2651. # report FCO:
  2652. # Return Value: none
  2653. variable l_script_data
  2654. variable a_global_vars
  2655. set obj_name [get_property name $report]
  2656. set read_only_props [rdi::get_attr_specs -class [get_property class $report] -filter {is_readonly}]
  2657. set prop_info_list [list]
  2658. set properties [list_property $report]
  2659. foreach prop $properties {
  2660. if { [string equal -nocase $prop "OPTIONS.pb"] || [string equal -nocase $prop "OPTIONS.rpx"] } {
  2661. #skipping read_only property
  2662. continue
  2663. }
  2664. if { [lsearch $read_only_props $prop] != -1 } { continue }
  2665. set def_val [list_property_value -default $prop $report]
  2666. set cur_val [get_property $prop $report]
  2667. # filter special properties
  2668. if { [filter $prop $cur_val] } { continue }
  2669. set cur_val [get_target_bool_val $def_val $cur_val]
  2670. set prop_entry "[string tolower $prop]#[get_property $prop $report]"
  2671. if { $a_global_vars(b_arg_all_props) } {
  2672. lappend prop_info_list $prop_entry
  2673. } elseif { $def_val != $cur_val } {
  2674. lappend prop_info_list $prop_entry
  2675. }
  2676. }
  2677. write_properties $prop_info_list "get_report_configs" $report
  2678. }
  2679. proc suppress_messages {} {
  2680. variable levels_to_suppress
  2681. set levels_to_suppress { {STATUS} {INFO} {WARNING} {CRITICAL WARNING} }
  2682. set msg_rules [split [ debug::get_msg_control_rules -as_tcl ] \n]
  2683. foreach line $msg_rules {
  2684. set idx_suppress [lsearch $line "-suppress"]
  2685. if { $idx_suppress >= 0 } {
  2686. set idx_severity [lsearch $line "-severity"]
  2687. if { $idx_suppress == $idx_severity + 2 } {
  2688. set lvl_idx [ lsearch $levels_to_suppress [lindex $line $idx_suppress-1 ] ]
  2689. if { $lvl_idx >= 0 } {
  2690. set levels_to_suppress [ lreplace $levels_to_suppress $lvl_idx $lvl_idx]
  2691. }
  2692. }
  2693. }
  2694. }
  2695. foreach level $levels_to_suppress {
  2696. set_msg_config -quiet -suppress -severity $level
  2697. }
  2698. }
  2699. proc reset_msg_setting {} {
  2700. variable levels_to_suppress
  2701. foreach level $levels_to_suppress {
  2702. reset_msg_config -quiet -suppress -severity $level
  2703. }
  2704. }
  2705. }