forked from DigilentInc/vivado-library
-
Notifications
You must be signed in to change notification settings - Fork 350
Expand file tree
/
Copy pathbd.tcl
More file actions
219 lines (174 loc) · 8.42 KB
/
Copy pathbd.tcl
File metadata and controls
219 lines (174 loc) · 8.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
################################################################
# This is a generated script based on design: design_1
#
# Though there are limitations about the generated script,
# the main purpose of this utility is to make learning
# IP Integrator Tcl commands easier.
################################################################
namespace eval _tcl {
proc get_script_folder {} {
set script_path [file normalize [info script]]
set script_folder [file dirname $script_path]
return $script_folder
}
}
variable script_folder
set script_folder [_tcl::get_script_folder]
################################################################
# Check if script is running in correct Vivado version.
################################################################
set scripts_vivado_version 2019.1
set current_vivado_version [version -short]
if { [string first $scripts_vivado_version $current_vivado_version] == -1 } {
puts ""
common::send_msg_id "BD_TCL-1002" "WARNING" "This script was generated using Vivado <$scripts_vivado_version> without IP versions in the create_bd_cell commands, but is now being run in <$current_vivado_version> of Vivado. There may have been major IP version changes between Vivado <$scripts_vivado_version> and <$current_vivado_version>, which could impact the parameter settings of the IPs."
}
################################################################
# START
################################################################
# To test this script, run the following commands from Vivado Tcl console:
# source design_1_script.tcl
# The design that will be created by this Tcl script contains the following
# module references:
# PmodHYGRO_remap
# Please add the sources of those modules before sourcing this Tcl script.
set bCheckIPsPassed 1
##################################################################
# CHECK IPs
##################################################################
set bCheckIPs 1
if { $bCheckIPs == 1 } {
set list_check_ips "\
xilinx.com:ip:axi_iic:*\
xilinx.com:ip:axi_timer:*\
digilentinc.com:ip:pmod_bridge:*\
"
set list_ips_missing ""
common::send_msg_id "BD_TCL-006" "INFO" "Checking if the following IPs exist in the project's IP catalog: $list_check_ips ."
foreach ip_vlnv $list_check_ips {
set ip_obj [get_ipdefs -all $ip_vlnv]
if { $ip_obj eq "" } {
lappend list_ips_missing $ip_vlnv
}
}
if { $list_ips_missing ne "" } {
catch {common::send_msg_id "BD_TCL-115" "ERROR" "The following IPs are not found in the IP Catalog:\n $list_ips_missing\n\nResolution: Please add the repository containing the IP(s) to the project." }
set bCheckIPsPassed 0
}
}
##################################################################
# CHECK Modules
##################################################################
set bCheckModules 1
if { $bCheckModules == 1 } {
set list_check_mods "\
PmodHYGRO_remap\
"
set list_mods_missing ""
common::send_msg_id "BD_TCL-006" "INFO" "Checking if the following modules exist in the project's sources: $list_check_mods ."
foreach mod_vlnv $list_check_mods {
if { [can_resolve_reference $mod_vlnv] == 0 } {
lappend list_mods_missing $mod_vlnv
}
}
if { $list_mods_missing ne "" } {
catch {common::send_msg_id "BD_TCL-115" "ERROR" "The following module(s) are not found in the project: $list_mods_missing" }
common::send_msg_id "BD_TCL-008" "INFO" "Please add source files for the missing module(s) above."
set bCheckIPsPassed 0
}
}
if { $bCheckIPsPassed != 1 } {
common::send_msg_id "BD_TCL-1003" "WARNING" "Will not continue with creation of design due to the error(s) above."
return 3
}
##################################################################
# DESIGN PROCs
##################################################################
# Hierarchical cell: PmodHYGRO_0
proc create_hier_cell_PmodHYGRO_0 { parentCell nameHier } {
variable script_folder
if { $parentCell eq "" || $nameHier eq "" } {
catch {common::send_msg_id "BD_TCL-102" "ERROR" "create_hier_cell_PmodHYGRO_0() - Empty argument(s)!"}
return
}
# Get object for parentCell
set parentObj [get_bd_cells $parentCell]
if { $parentObj == "" } {
catch {common::send_msg_id "BD_TCL-100" "ERROR" "Unable to find parent cell <$parentCell>!"}
return
}
# Make sure parentObj is hier blk
set parentType [get_property TYPE $parentObj]
if { $parentType ne "hier" } {
catch {common::send_msg_id "BD_TCL-101" "ERROR" "Parent <$parentObj> has TYPE = <$parentType>. Expected to be <hier>."}
return
}
# Save current instance; Restore later
set oldCurInst [current_bd_instance .]
# Set parent object as current
current_bd_instance $parentObj
# Create cell and set as current instance
set hier_obj [create_bd_cell -type hier $nameHier]
current_bd_instance $hier_obj
# Create interface pins
create_bd_intf_pin -mode Slave -vlnv xilinx.com:interface:aximm_rtl:1.0 AXI_LITE_I2C
create_bd_intf_pin -mode Slave -vlnv xilinx.com:interface:aximm_rtl:1.0 AXI_LITE_TIMER
create_bd_intf_pin -mode Master -vlnv digilentinc.com:interface:pmod_rtl:1.0 Pmod_out
# Create pins
create_bd_pin -dir O i2c_interrupt
create_bd_pin -dir I -type clk s_axi_aclk
create_bd_pin -dir I -type rst s_axi_aresetn
create_bd_pin -dir O timer_interrupt
# Create instance: PmodHYGRO_remap_0, and set properties
set block_name PmodHYGRO_remap
set block_cell_name PmodHYGRO_remap_0
if { [catch {set PmodHYGRO_remap_0 [create_bd_cell -type module -reference $block_name $block_cell_name] } errmsg] } {
catch {common::send_msg_id "BD_TCL-105" "ERROR" "Unable to add referenced block <$block_name>. Please add the files for ${block_name}'s definition into the project."}
return 1
} elseif { $PmodHYGRO_remap_0 eq "" } {
catch {common::send_msg_id "BD_TCL-106" "ERROR" "Unable to referenced block <$block_name>. Please add the files for ${block_name}'s definition into the project."}
return 1
}
# Create instance: axi_iic_0, and set properties
set axi_iic_0 [ create_bd_cell -type ip -vlnv xilinx.com:ip:axi_iic axi_iic_0 ]
set_property -dict [ list \
CONFIG.C_GPO_WIDTH {2} \
] $axi_iic_0
# Create instance: axi_timer_0, and set properties
set axi_timer_0 [ create_bd_cell -type ip -vlnv xilinx.com:ip:axi_timer axi_timer_0 ]
set_property -dict [ list \
CONFIG.enable_timer2 {0} \
] $axi_timer_0
# Create instance: pmod_bridge_0, and set properties
set pmod_bridge_0 [ create_bd_cell -type ip -vlnv digilentinc.com:ip:pmod_bridge pmod_bridge_0 ]
set_property -dict [ list \
CONFIG.Bottom_Row_Interface {Disabled} \
CONFIG.PMOD {Custom} \
CONFIG.Top_Row_Interface {I2C} \
CONFIG.USE_BOARD_FLOW {true} \
CONFIG.Use_Pullups_Top_Row {true} \
] $pmod_bridge_0
# Create interface connections
connect_bd_intf_net -intf_net AXI_LITE_I2C [get_bd_intf_pins AXI_LITE_I2C] [get_bd_intf_pins axi_iic_0/S_AXI]
connect_bd_intf_net -intf_net AXI_LITE_TIMER [get_bd_intf_pins AXI_LITE_TIMER] [get_bd_intf_pins axi_timer_0/S_AXI]
connect_bd_intf_net -intf_net Conn1 [get_bd_intf_pins Pmod_out] [get_bd_intf_pins pmod_bridge_0/Pmod_out]
connect_bd_intf_net -intf_net PmodHYGRO_remap_0_GPIO_TOP [get_bd_intf_pins PmodHYGRO_remap_0/GPIO_TOP] [get_bd_intf_pins pmod_bridge_0/I2C_GPIO_Top_Row]
connect_bd_intf_net -intf_net axi_iic_0_IIC [get_bd_intf_pins axi_iic_0/IIC] [get_bd_intf_pins pmod_bridge_0/I2C_Top_Row]
# Create port connections
connect_bd_net -net PmodHYGRO_axi_aclk [get_bd_pins s_axi_aclk] [get_bd_pins axi_iic_0/s_axi_aclk] [get_bd_pins axi_timer_0/s_axi_aclk]
connect_bd_net -net PmodHYGRO_axi_aresetn [get_bd_pins s_axi_aresetn] [get_bd_pins axi_iic_0/s_axi_aresetn] [get_bd_pins axi_timer_0/s_axi_aresetn]
connect_bd_net -net PmodHYGRO_i2c_interrupt [get_bd_pins i2c_interrupt] [get_bd_pins axi_iic_0/iic2intc_irpt]
connect_bd_net -net PmodHYGRO_timer_interrupt [get_bd_pins timer_interrupt] [get_bd_pins axi_timer_0/interrupt]
connect_bd_net -net axi_iic_0_gpo [get_bd_pins PmodHYGRO_remap_0/iic_gpo] [get_bd_pins axi_iic_0/gpo]
# Restore current instance
current_bd_instance $oldCurInst
}
proc available_tcl_procs { } {
puts "##################################################################"
puts "# Available Tcl procedures to recreate hierarchical blocks:"
puts "#"
puts "# create_hier_cell_PmodHYGRO_0 parentCell nameHier"
puts "#"
puts "##################################################################"
}
available_tcl_procs