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

create_project.tcl 5.7KB

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