Advertisement
Vexilurz

Untitled

Mar 12th, 2019
901
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 5.89 KB | None | 0 0
  1. # Run this script to create the Vivado project files NEXT TO THIS script
  2. # If ::create_path global variable is set, the project is created under that path instead of the working dir
  3.  
  4. # Project specific settings. These must be updated for each project.
  5. set proj_name "DMA"
  6.  
  7. if {[info exists ::create_path]} {
  8.     set dest_dir $::create_path
  9. } else {
  10.     set dest_dir [file normalize [file dirname [info script]]]
  11. }
  12. puts "INFO: Creating new project in $dest_dir"
  13. cd $dest_dir
  14.  
  15.  
  16.  
  17. set part "xc7z020clg484-1"
  18. set brd_part "digilentinc.com:zedboard:part0:1.0"
  19.  
  20. # Set the reference directory for source file relative paths (by default the value is script directory path)
  21. set origin_dir ".."
  22.  
  23. # Set the directory path for the original project from where this script was exported
  24. set orig_proj_dir "[file normalize "$origin_dir/proj"]"
  25.  
  26. set src_dir $origin_dir/src
  27. set repo_dir $origin_dir/repo
  28.  
  29. # # Set the board repo
  30. # # Uncomment if distributing board files with project in the "repo/board_files" folder.
  31. # # This is currently untested. It intends to also keep any existing board repo paths, since this is a global Vivado setting (not project specific.
  32. # # Ideally, if the project is closed, and then a new project is created (without closing Vivado), this should still be able to see a board repo specified in init.tcl.
  33. #set_param board.repoPaths "[file normalize "$repo_dir/board_files"]"
  34.  
  35. # Create project
  36. create_project $proj_name $dest_dir
  37.  
  38. # Set the directory path for the new project
  39. set proj_dir [get_property directory [current_project]]
  40.  
  41. # Set project properties
  42. set obj [get_projects $proj_name]
  43. set_property "default_lib" "xil_defaultlib" $obj
  44. set_property "part" $part $obj
  45. set_property "board_part" $brd_part $obj
  46. set_property "simulator_language" "Mixed" $obj
  47. set_property "target_language" "VHDL" $obj
  48.  
  49. # Uncomment the following 3 lines to greatly increase build speed while working with IP cores (and/or block diagrams)
  50. set_property "corecontainer.enable" "0" $obj
  51. set_property "ip_cache_permissions" "read write" $obj
  52. set_property "ip_output_repo" "[file normalize "$origin_dir/repo/cache"]" $obj
  53.  
  54. # Create 'sources_1' fileset (if not found)
  55. if {[string equal [get_filesets -quiet sources_1] ""]} {
  56.   create_fileset -srcset sources_1
  57. }
  58.  
  59. # Create 'constrs_1' fileset (if not found)
  60. if {[string equal [get_filesets -quiet constrs_1] ""]} {
  61.   create_fileset -constrset constrs_1
  62. }
  63.  
  64. # Set IP repository paths
  65. set obj [get_filesets sources_1]
  66. set_property "ip_repo_paths" "[file normalize $repo_dir]" $obj
  67.  
  68. # Refresh IP Repositories
  69. update_ip_catalog -rebuild
  70.  
  71. # Add conventional sources
  72. add_files -quiet $src_dir/hdl
  73.  
  74. # Add IPs
  75. # TODO: handle IP containers files
  76. add_files -quiet [glob -nocomplain ../src/ip/*/*.xci]
  77.  
  78. # Add constraints
  79. add_files -fileset constrs_1 -quiet $src_dir/constraints
  80.  
  81. # Create 'synth_1' run (if not found)
  82. if {[string equal [get_runs -quiet synth_1] ""]} {
  83.   create_run -name synth_1 -part $part -flow {Vivado Synthesis 2015} -strategy "Vivado Synthesis Defaults" -constrset constrs_1
  84. } else {
  85.   set_property strategy "Vivado Synthesis Defaults" [get_runs synth_1]
  86.   set_property flow "Vivado Synthesis 2015" [get_runs synth_1]
  87. }
  88. set obj [get_runs synth_1]
  89. set_property "part" $part $obj
  90. set_property "steps.synth_design.args.flatten_hierarchy" "none" $obj
  91. set_property "steps.synth_design.args.directive" "RuntimeOptimized" $obj
  92. set_property "steps.synth_design.args.fsm_extraction" "off" $obj
  93.  
  94. # set the current synth run
  95. current_run -synthesis [get_runs synth_1]
  96.  
  97. # Create 'impl_1' run (if not found)
  98. if {[string equal [get_runs -quiet impl_1] ""]} {
  99.   create_run -name impl_1 -part $part -flow {Vivado Implementation 2015} -strategy "Vivado Implementation Defaults" -constrset constrs_1 -parent_run synth_1
  100. } else {
  101.   set_property strategy "Vivado Implementation Defaults" [get_runs impl_1]
  102.   set_property flow "Vivado Implementation 2015" [get_runs impl_1]
  103. }
  104. set obj [get_runs impl_1]
  105. set_property "part" $part $obj
  106. set_property "steps.opt_design.args.directive" "RuntimeOptimized" $obj
  107. set_property "steps.place_design.args.directive" "RuntimeOptimized" $obj
  108. set_property "steps.route_design.args.directive" "RuntimeOptimized" $obj
  109.  
  110. # set the current impl run
  111. current_run -implementation [get_runs impl_1]
  112.  
  113. puts "INFO: Project created:$proj_name"
  114.  
  115. # Comment the rest of this script if there is no block design
  116. # Note that this script currently only supports a single block diagram
  117.  
  118. # Uncomment this if building the block diagram from a tcl
  119. # Create block design
  120. # source $origin_dir/src/bd/system.tcl
  121.  
  122. # Uncomment this block if importing an existing block diagram project
  123. # Import block design if it exists
  124. set bd_list [glob -nocomplain $src_dir/bd/*/*.bd]
  125. if {[llength $bd_list] != 0} {
  126.   add_files -norecurse -quiet -fileset sources_1 [glob -nocomplain $src_dir/bd/*/*.bd]
  127.   open_bd_design [glob -nocomplain $src_dir/bd/*/*.bd]
  128.   set design_name [get_bd_designs]
  129.   set file "$origin_dir/src/bd/$design_name/$design_name.bd"
  130.   set file [file normalize $file]
  131.   set file_obj [get_files -of_objects [get_filesets sources_1] [list "*$file"]]
  132.   if { ![get_property "is_locked" $file_obj] } {
  133.     set_property "synth_checkpoint_mode" "Hierarchical" $file_obj
  134.   }
  135.  
  136.   # Generate the wrapper
  137.   set design_name [get_bd_designs]
  138.   add_files -norecurse [make_wrapper -files [get_files $design_name.bd] -top -force]
  139.  
  140.   set obj [get_filesets sources_1]
  141.   set_property "top" "${design_name}_wrapper" $obj
  142. }
  143.  
  144. set sdk_dir $origin_dir/sdk
  145.  
  146. set hw_list [glob -nocomplain $sdk_dir/*hw_platform*]
  147. if {[llength $hw_list] != 0} {
  148.   foreach hw_plat $hw_list {
  149.     file delete -force $hw_plat
  150.   }
  151. }
  152.  
  153. set sdk_list [glob -nocomplain $sdk_dir/*]
  154. set sdk_list [lsearch -inline -all -not -exact $sdk_list "../sdk/.keep"]
  155. if {[llength $sdk_list] != 0} {
  156.     exec xsct -eval "setws -switch ../sdk; importproject ../sdk"
  157. }
  158. #
  159. #
  160. # puts "INFO: Block design ready: $design_name.bd"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement