design_1.tcl 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. ################################################################
  2. # This is a generated script based on design: design_1
  3. #
  4. # Though there are limitations about the generated script,
  5. # the main purpose of this utility is to make learning
  6. # IP Integrator Tcl commands easier.
  7. ################################################################
  8. namespace eval _tcl {
  9. proc get_script_folder {} {
  10. set script_path [file normalize [info script]]
  11. set script_folder [file dirname $script_path]
  12. return $script_folder
  13. }
  14. }
  15. variable script_folder
  16. set script_folder [_tcl::get_script_folder]
  17. ################################################################
  18. # Check if script is running in correct Vivado version.
  19. ################################################################
  20. set scripts_vivado_version 2018.3
  21. set current_vivado_version [version -short]
  22. if { [string first $scripts_vivado_version $current_vivado_version] == -1 } {
  23. puts ""
  24. catch {common::send_msg_id "BD_TCL-109" "ERROR" "This script was generated using Vivado <$scripts_vivado_version> and is being run in <$current_vivado_version> of Vivado. Please run the script in Vivado <$scripts_vivado_version> then open the design in Vivado <$current_vivado_version>. Upgrade the design by running \"Tools => Report => Report IP Status...\", then run write_bd_tcl to create an updated script."}
  25. return 1
  26. }
  27. ################################################################
  28. # START
  29. ################################################################
  30. # To test this script, run the following commands from Vivado Tcl console:
  31. # source design_1_script.tcl
  32. # If there is no project opened, this script will create a
  33. # project, but make sure you do not have an existing project
  34. # <./myproj/project_1.xpr> in the current working folder.
  35. set list_projs [get_projects -quiet]
  36. if { $list_projs eq "" } {
  37. create_project project_1 myproj -part xc7a100tcsg324-1
  38. }
  39. # CHANGE DESIGN NAME HERE
  40. variable design_name
  41. set design_name design_1
  42. # If you do not already have an existing IP Integrator design open,
  43. # you can create a design using the following command:
  44. # create_bd_design $design_name
  45. # Creating design if needed
  46. set errMsg ""
  47. set nRet 0
  48. set cur_design [current_bd_design -quiet]
  49. set list_cells [get_bd_cells -quiet]
  50. if { ${design_name} eq "" } {
  51. # USE CASES:
  52. # 1) Design_name not set
  53. set errMsg "Please set the variable <design_name> to a non-empty value."
  54. set nRet 1
  55. } elseif { ${cur_design} ne "" && ${list_cells} eq "" } {
  56. # USE CASES:
  57. # 2): Current design opened AND is empty AND names same.
  58. # 3): Current design opened AND is empty AND names diff; design_name NOT in project.
  59. # 4): Current design opened AND is empty AND names diff; design_name exists in project.
  60. if { $cur_design ne $design_name } {
  61. common::send_msg_id "BD_TCL-001" "INFO" "Changing value of <design_name> from <$design_name> to <$cur_design> since current design is empty."
  62. set design_name [get_property NAME $cur_design]
  63. }
  64. common::send_msg_id "BD_TCL-002" "INFO" "Constructing design in IPI design <$cur_design>..."
  65. } elseif { ${cur_design} ne "" && $list_cells ne "" && $cur_design eq $design_name } {
  66. # USE CASES:
  67. # 5) Current design opened AND has components AND same names.
  68. set errMsg "Design <$design_name> already exists in your project, please set the variable <design_name> to another value."
  69. set nRet 1
  70. } elseif { [get_files -quiet ${design_name}.bd] ne "" } {
  71. # USE CASES:
  72. # 6) Current opened design, has components, but diff names, design_name exists in project.
  73. # 7) No opened design, design_name exists in project.
  74. set errMsg "Design <$design_name> already exists in your project, please set the variable <design_name> to another value."
  75. set nRet 2
  76. } else {
  77. # USE CASES:
  78. # 8) No opened design, design_name not in project.
  79. # 9) Current opened design, has components, but diff names, design_name not in project.
  80. common::send_msg_id "BD_TCL-003" "INFO" "Currently there is no design <$design_name> in project, so creating one..."
  81. create_bd_design $design_name
  82. common::send_msg_id "BD_TCL-004" "INFO" "Making design <$design_name> as current_bd_design."
  83. current_bd_design $design_name
  84. }
  85. common::send_msg_id "BD_TCL-005" "INFO" "Currently the variable <design_name> is equal to \"$design_name\"."
  86. if { $nRet != 0 } {
  87. catch {common::send_msg_id "BD_TCL-114" "ERROR" $errMsg}
  88. return $nRet
  89. }
  90. set bCheckIPsPassed 1
  91. ##################################################################
  92. # There are no IPs nor Modules to check.
  93. ##################################################################
  94. if { $bCheckIPsPassed != 1 } {
  95. common::send_msg_id "BD_TCL-1003" "WARNING" "Will not continue with creation of design due to the error(s) above."
  96. return 3
  97. }
  98. ##################################################################
  99. # DESIGN PROCs
  100. ##################################################################
  101. # Procedure to create entire design; Provide argument to make
  102. # procedure reusable. If parentCell is "", will use root.
  103. proc create_root_design { parentCell } {
  104. variable script_folder
  105. variable design_name
  106. if { $parentCell eq "" } {
  107. set parentCell [get_bd_cells /]
  108. }
  109. # Get object for parentCell
  110. set parentObj [get_bd_cells $parentCell]
  111. if { $parentObj == "" } {
  112. catch {common::send_msg_id "BD_TCL-100" "ERROR" "Unable to find parent cell <$parentCell>!"}
  113. return
  114. }
  115. # Make sure parentObj is hier blk
  116. set parentType [get_property TYPE $parentObj]
  117. if { $parentType ne "hier" } {
  118. catch {common::send_msg_id "BD_TCL-101" "ERROR" "Parent <$parentObj> has TYPE = <$parentType>. Expected to be <hier>."}
  119. return
  120. }
  121. # Save current instance; Restore later
  122. set oldCurInst [current_bd_instance .]
  123. # Set parent object as current
  124. current_bd_instance $parentObj
  125. # Create interface ports
  126. # Create ports
  127. # Create port connections
  128. # Create address segments
  129. # Restore current instance
  130. current_bd_instance $oldCurInst
  131. validate_bd_design
  132. save_bd_design
  133. }
  134. # End of create_root_design()
  135. ##################################################################
  136. # MAIN FLOW
  137. ##################################################################
  138. create_root_design ""