[2229] | 1 | ############################################################### |
---|
| 2 | # Copyright (c) 2004 Xilinx, Inc. All Rights Reserved. |
---|
| 3 | # You may copy and modify these files for your own internal use solely with |
---|
| 4 | # Xilinx programmable logic devices and Xilinx EDK system or create IP |
---|
| 5 | # modules solely for Xilinx programmable logic devices and Xilinx EDK system. |
---|
| 6 | # No rights are granted to distribute any files unless they are distributed in |
---|
| 7 | # Xilinx programmable logic devices. |
---|
| 8 | # |
---|
| 9 | # $Id: xilnet_v2_1_0.tcl,v 1.2.8.6 2005/11/15 23:41:10 salindac Exp $ |
---|
| 10 | # ############################################################## |
---|
| 11 | #uses "xillib.tcl" |
---|
| 12 | |
---|
| 13 | # NOTE: |
---|
| 14 | # In order to use the WARPxilnet library, the Ethernet instances within the |
---|
| 15 | # design need to have either "ETH_A" or "ETH_B" somewhere in the instance |
---|
| 16 | # name. Due to some limitations with the Xilinx TCL generation capabilities |
---|
| 17 | # this script cannot pass instance names up to the MLD file to be displayed |
---|
| 18 | # as parameter names. Therefore, this driver has two parameters: |
---|
| 19 | # 1) ETH_A_uses_xilnet |
---|
| 20 | # 2) ETH_B_uses_xilnet |
---|
| 21 | # that are used to control if a given Ethernet instance is controlled by the |
---|
| 22 | # WARPxilnet library. If an instance is not controlled by this library, then |
---|
| 23 | # the library will not allocate buffers or control structures in order to |
---|
| 24 | # minimize code and data space of this library. |
---|
| 25 | # |
---|
| 26 | # This library will complain if: |
---|
| 27 | # 1) There are more than two Ethernet instances, but will complete and |
---|
| 28 | # allocate buffers and control structures for all instances |
---|
| 29 | # 2) If none of the Ethernet instances contain either "ETH_A" or "ETH_B". |
---|
| 30 | # In this case, the *_uses_xilnet parameters will be ignored and |
---|
| 31 | # buffers and control structures will be allocated for all instances |
---|
| 32 | # 3) If the *_uses_xilnet parameter is set to '1' and the corresponding |
---|
| 33 | # "ETH_*" doesn't exist, then the driver will error out, except in |
---|
| 34 | # the situation of case 2) above. |
---|
| 35 | # |
---|
| 36 | |
---|
| 37 | |
---|
| 38 | set ethernet_ninstances 0 |
---|
| 39 | set ethernet_use_axi 0 |
---|
| 40 | set ethernet_use_axi_dma 0 |
---|
| 41 | set ethernet_use_axi_fifo 0 |
---|
| 42 | set ethernet_use_temac 0 |
---|
| 43 | |
---|
| 44 | |
---|
| 45 | proc get_ethernet_periphs {mhs_handle} { |
---|
| 46 | global ethernet_ninstances |
---|
| 47 | global ethernet_use_axi |
---|
| 48 | global ethernet_use_temac |
---|
| 49 | |
---|
| 50 | set ipinst_list [xget_hw_ipinst_handle $mhs_handle "*"] |
---|
| 51 | set ethernet_ninstances 0 |
---|
| 52 | set ethernet_use_axi 0 |
---|
| 53 | set ethernet_use_temac 0 |
---|
| 54 | set ethernet_periphs_list {} |
---|
| 55 | |
---|
| 56 | foreach periph $ipinst_list { |
---|
| 57 | set periph_type [xget_hw_value $periph] |
---|
| 58 | set periph_name [xget_value $periph "name"] |
---|
| 59 | |
---|
| 60 | # puts "\# Peripheral: type = $periph_type name = $periph_name " |
---|
| 61 | |
---|
| 62 | if { $periph_type == "axi_ethernet" } { |
---|
| 63 | |
---|
| 64 | incr ethernet_use_axi |
---|
| 65 | incr ethernet_ninstances |
---|
[2688] | 66 | |
---|
| 67 | # puts "\# Putting ($periph_name $periph) into list: $ethernet_periphs_list " |
---|
[2229] | 68 | |
---|
[2688] | 69 | if { [regexp -nocase {eth_a} $periph_name] } { |
---|
| 70 | if { [llength $ethernet_periphs_list] > 0 } { |
---|
| 71 | set ethernet_periphs_list [linsert $ethernet_periphs_list 0 $periph] |
---|
| 72 | } else { |
---|
| 73 | lappend ethernet_periphs_list $periph |
---|
| 74 | } |
---|
| 75 | } else { |
---|
| 76 | if { [regexp -nocase {eth_b} $periph_name] } { |
---|
| 77 | lappend ethernet_periphs_list $periph |
---|
| 78 | } else { |
---|
| 79 | lappend ethernet_periphs_list $periph |
---|
| 80 | } |
---|
| 81 | } |
---|
| 82 | |
---|
[2229] | 83 | # puts "\# Ethernet $ethernet_ninstances: type = $periph_type name = $periph_name " |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | if { $periph_type == "xps_ll_temac" || |
---|
| 87 | $periph_type == "opb_ethernetlite" || |
---|
| 88 | $periph_type == "xps_ethernetlite" } { |
---|
| 89 | |
---|
| 90 | incr ethernet_use_temac |
---|
| 91 | incr ethernet_ninstances |
---|
| 92 | lappend ethernet_periphs_list $periph |
---|
| 93 | |
---|
| 94 | # puts "\# Ethernet $ethernet_ninstances: type = $periph_type name = $periph_name " |
---|
| 95 | } |
---|
| 96 | } |
---|
| 97 | |
---|
[2688] | 98 | |
---|
| 99 | # puts "\# Final List ($ethernet_ninstances elements): $ethernet_periphs_list " |
---|
| 100 | |
---|
| 101 | # foreach eth_inst $ethernet_periphs_list { |
---|
| 102 | # set periph_name [xget_value $eth_inst "name"] |
---|
| 103 | # |
---|
| 104 | # puts "\# Ethernet name = $periph_name " |
---|
| 105 | # } |
---|
| 106 | |
---|
[2229] | 107 | return $ethernet_periphs_list |
---|
| 108 | } |
---|
| 109 | |
---|
| 110 | |
---|
| 111 | proc get_ethernet_interface_periph {mhs_handle inst_handle} { |
---|
| 112 | |
---|
| 113 | set p2p_busifs_i [xget_hw_busifs_by_subproperty $inst_handle "BUS_TYPE" "INITIATOR"] |
---|
| 114 | |
---|
| 115 | # Add p2p periphs |
---|
| 116 | foreach p2p_busif $p2p_busifs_i { |
---|
| 117 | |
---|
| 118 | set bus_name [string toupper [xget_hw_value $p2p_busif]] |
---|
| 119 | set conn_busif_handle [xget_hw_connected_busifs_handle $mhs_handle $bus_name "TARGET"] |
---|
| 120 | |
---|
| 121 | if { [string compare -nocase $conn_busif_handle ""] == 0} { |
---|
| 122 | continue |
---|
| 123 | } else { |
---|
| 124 | # if there is a single match, we know if it is FIFO or DMA |
---|
| 125 | # no need for further iterations |
---|
| 126 | set conn_busif_name [xget_hw_name $conn_busif_handle] |
---|
| 127 | set target_periph [xget_hw_parent_handle $conn_busif_handle] |
---|
| 128 | |
---|
| 129 | set target_type [xget_hw_value $target_periph] |
---|
| 130 | set target_name [string toupper [xget_hw_name $target_periph]] |
---|
| 131 | |
---|
| 132 | # puts "\# Bus Name = $bus_name Type = $conn_busif_name" |
---|
| 133 | # puts "\# Target Name = $target_name Type = $target_type" |
---|
| 134 | |
---|
| 135 | return $target_periph |
---|
| 136 | } |
---|
| 137 | } |
---|
| 138 | |
---|
| 139 | return |
---|
| 140 | } |
---|
| 141 | |
---|
| 142 | |
---|
| 143 | proc get_periph_instances {mhs_handle inst_type} { |
---|
| 144 | set ipinst_list [xget_hw_ipinst_handle $mhs_handle "*"] |
---|
| 145 | set periphs_list {} |
---|
| 146 | |
---|
| 147 | foreach periph $ipinst_list { |
---|
| 148 | set periph_type [xget_hw_value $periph] |
---|
| 149 | set periph_name [xget_value $periph "name"] |
---|
| 150 | |
---|
| 151 | if { $periph_type == $inst_type } { |
---|
| 152 | |
---|
| 153 | lappend periphs_list $periph |
---|
| 154 | |
---|
| 155 | # puts "\# Instance: type = $periph_type name = $periph_name " |
---|
| 156 | } |
---|
| 157 | } |
---|
| 158 | |
---|
| 159 | return $periphs_list |
---|
| 160 | } |
---|
| 161 | |
---|
| 162 | |
---|
| 163 | proc net_drc {lib_handle} { |
---|
| 164 | |
---|
| 165 | puts "XilNet DRC ..." |
---|
| 166 | } |
---|
| 167 | |
---|
| 168 | proc net_open_file {filename desc} { |
---|
| 169 | set config_inc [open $filename w] |
---|
| 170 | xprint_generated_header $config_inc $desc |
---|
| 171 | return $config_inc |
---|
| 172 | } |
---|
| 173 | |
---|
| 174 | proc net_open_include_file {file_name} { |
---|
| 175 | set filename [file join "./src/" $file_name] |
---|
| 176 | return [net_open_file $filename "WARP/XilNet Configuration Parameters"] |
---|
| 177 | } |
---|
| 178 | |
---|
| 179 | proc net_open_config_file {file_name} { |
---|
| 180 | set filename [file join "./src/" $file_name] |
---|
| 181 | return [net_open_file $filename "WARP/XilNet MAC Configuration File"] |
---|
| 182 | } |
---|
| 183 | |
---|
| 184 | proc generate {lib_handle} { |
---|
| 185 | global ethernet_ninstances |
---|
| 186 | |
---|
| 187 | global ethernet_use_axi |
---|
| 188 | global ethernet_use_axi_dma |
---|
| 189 | global ethernet_use_axi_fifo |
---|
| 190 | |
---|
| 191 | set ethernet_use_axi_dma 0 |
---|
| 192 | set ethernet_use_axi_fifo 0 |
---|
| 193 | |
---|
| 194 | set sw_proc_handle [xget_processor] |
---|
| 195 | set hw_proc_handle [xget_handle $sw_proc_handle "IPINST"] |
---|
| 196 | set mhs_handle [xget_hw_parent_handle $hw_proc_handle] |
---|
| 197 | set emac_inst_list [get_ethernet_periphs $mhs_handle] |
---|
| 198 | |
---|
| 199 | # Error checking |
---|
| 200 | if {$ethernet_ninstances == 0} { |
---|
| 201 | error "Invalid configuration: 0 Ethernet instances found." "" "mdt_error" |
---|
| 202 | return |
---|
| 203 | } |
---|
| 204 | |
---|
| 205 | # Initialize variables for loop |
---|
| 206 | set eth_inst_num 0 |
---|
| 207 | set h_file [net_open_include_file "xilnet_config.h"] |
---|
| 208 | set c_file [net_open_config_file "xilnet_config.c"] |
---|
| 209 | |
---|
| 210 | set eth_a_uses_drvr [xget_value $lib_handle "PARAMETER" "ETH_A_uses_xilnet"] |
---|
| 211 | set eth_b_uses_drvr [xget_value $lib_handle "PARAMETER" "ETH_B_uses_xilnet"] |
---|
| 212 | set fifo_buf_size [xget_value $lib_handle "PARAMETER" "fifo_buf_size"] |
---|
| 213 | set dma_buf_size [xget_value $lib_handle "PARAMETER" "dma_buf_size"] |
---|
| 214 | set dma_rcvd_buf_cnt [xget_value $lib_handle "PARAMETER" "dma_rcvd_buf_cnt"] |
---|
| 215 | set udp_conns [xget_value $lib_handle "PARAMETER" "no_of_tcp_conns"] |
---|
| 216 | |
---|
| 217 | set inf_type_list {} |
---|
| 218 | set ignore_list {} |
---|
| 219 | |
---|
| 220 | # puts "\# --------------------------------------" |
---|
| 221 | # puts "\# Num Ethernet instances = $ethernet_ninstances " |
---|
| 222 | |
---|
| 223 | # Check Ethernet instances and instance names |
---|
| 224 | # 1) There are more than two Ethernet instances, but will complete and |
---|
| 225 | # allocate buffers and control structures for all instances |
---|
| 226 | # 2) If none of the Ethernet instances contain either "ETH_A" or "ETH_B". |
---|
| 227 | # In this case, the *_uses_xilnet parameters will be ignored and |
---|
| 228 | # buffers and control structures will be allocated for all instances |
---|
| 229 | # 3) If the *_uses_xilnet parameter is set to '1' and the corresponding |
---|
| 230 | # "ETH_*" doesn't exist, then the driver will error out, except in |
---|
| 231 | # the situation of case 2) above. |
---|
| 232 | # |
---|
| 233 | if {$ethernet_ninstances > 2} { |
---|
| 234 | puts "\# --------------------------------------" |
---|
| 235 | puts "\# WARPxilnet WARNING:" |
---|
| 236 | puts "\# More than 2 Ethernet instances." |
---|
| 237 | puts "\# Ignoring ETH_*_uses_xilnet parameters." |
---|
| 238 | puts "\# --------------------------------------" |
---|
| 239 | } else { |
---|
| 240 | |
---|
| 241 | set eth_name_matches 0 |
---|
| 242 | set eth_a_exists 0 |
---|
| 243 | set eth_b_exists 0 |
---|
| 244 | foreach inst $emac_inst_list { |
---|
| 245 | set inst_name [string toupper [xget_hw_name $inst]] |
---|
| 246 | if { [regexp -nocase {eth_a} $inst_name] } { |
---|
| 247 | incr eth_name_matches |
---|
| 248 | incr eth_a_exists |
---|
| 249 | } |
---|
| 250 | if { [regexp -nocase {eth_b} $inst_name] } { |
---|
| 251 | incr eth_name_matches |
---|
| 252 | incr eth_b_exists |
---|
| 253 | } |
---|
| 254 | } |
---|
| 255 | |
---|
| 256 | if { $eth_name_matches == 0 } { |
---|
| 257 | puts "\# --------------------------------------" |
---|
| 258 | puts "\# WARPxilnet WARNING:" |
---|
| 259 | puts "\# No Ethernet instances contain either \"ETH_A\" or \"ETH_B\"." |
---|
| 260 | puts "\# Ignoring ETH_*_uses_xilnet parameters." |
---|
| 261 | puts "\# --------------------------------------" |
---|
| 262 | } else { |
---|
| 263 | if { $eth_a_uses_drvr == 1 && $eth_a_exists == 0 } { |
---|
| 264 | error "Invalid configuration: ETH_A does not exist but required by library." "" "mdt_error" |
---|
| 265 | return |
---|
| 266 | } |
---|
| 267 | if { $eth_b_uses_drvr == 1 && $eth_b_exists == 0 } { |
---|
| 268 | error "Invalid configuration: ETH_B does not exist but required by library." "" "mdt_error" |
---|
| 269 | return |
---|
| 270 | } |
---|
| 271 | } |
---|
| 272 | } |
---|
| 273 | |
---|
| 274 | |
---|
| 275 | # For code size reasons, we need to determine if we need to use the AXI FIFO or the AXI DMA |
---|
| 276 | # based on the interface type. If we are not using AXI, then we can ignore this check. |
---|
| 277 | # |
---|
| 278 | if { $ethernet_use_axi != 0 } { |
---|
| 279 | |
---|
| 280 | foreach inst $emac_inst_list { |
---|
| 281 | set inst_type [xget_hw_value $inst] |
---|
| 282 | set inst_name [string toupper [xget_hw_name $inst]] |
---|
| 283 | set ignore 0 |
---|
| 284 | |
---|
| 285 | # Check if we should ignore this Ethernet instance |
---|
| 286 | # NOTE: This implementation relies on the fact that all the checks above passed |
---|
| 287 | # |
---|
| 288 | if { [regexp -nocase {eth_a} $inst_name] && $eth_a_uses_drvr == 0 } { incr ignore } |
---|
| 289 | if { [regexp -nocase {eth_b} $inst_name] && $eth_b_uses_drvr == 0 } { incr ignore } |
---|
| 290 | |
---|
| 291 | # If we are not ignoring this interface, then increment the global variables |
---|
| 292 | # |
---|
| 293 | if { $ignore == 0 } { |
---|
| 294 | |
---|
| 295 | # Determine the interface attached to the axi_ethernet |
---|
| 296 | set inf_inst [get_ethernet_interface_periph $mhs_handle $inst] |
---|
| 297 | |
---|
| 298 | if { [llength $inf_inst] != 0 } { |
---|
| 299 | set inf_inst_type [xget_hw_value $inf_inst] |
---|
| 300 | |
---|
| 301 | switch $inf_inst_type { |
---|
| 302 | "axi_fifo_mm_s" { |
---|
| 303 | incr ethernet_use_axi_fifo |
---|
| 304 | } |
---|
| 305 | |
---|
| 306 | "axi_dma" { |
---|
| 307 | incr ethernet_use_axi_dma |
---|
| 308 | } |
---|
| 309 | } |
---|
| 310 | } |
---|
| 311 | } |
---|
| 312 | } |
---|
| 313 | } |
---|
| 314 | |
---|
| 315 | |
---|
| 316 | # Process the instances and print the config header and c files |
---|
| 317 | print_h_file_header $h_file $udp_conns |
---|
| 318 | print_c_file_header $c_file |
---|
| 319 | |
---|
| 320 | foreach inst $emac_inst_list { |
---|
| 321 | set inst_type [xget_hw_value $inst] |
---|
| 322 | set inst_name [string toupper [xget_hw_name $inst]] |
---|
| 323 | set ignore 0 |
---|
| 324 | |
---|
| 325 | # Check if we should ignore this Ethernet instance |
---|
| 326 | # NOTE: This implementation relies on the fact that all the checks above passed |
---|
| 327 | # |
---|
| 328 | if { [regexp -nocase {eth_a} $inst_name] && $eth_a_uses_drvr == 0 } { incr ignore } |
---|
| 329 | if { [regexp -nocase {eth_b} $inst_name] && $eth_b_uses_drvr == 0 } { incr ignore } |
---|
| 330 | |
---|
| 331 | |
---|
| 332 | # puts "\# Name = $inst_name " |
---|
| 333 | # puts "\# Type = $inst_type " |
---|
| 334 | # puts "\# Ignore = $ignore " |
---|
| 335 | |
---|
| 336 | # Print out header file delimiter |
---|
| 337 | puts $h_file "" |
---|
| 338 | puts $h_file "/************************* Ethernet $eth_inst_num Definitions ****************************/" |
---|
| 339 | puts $h_file "" |
---|
| 340 | |
---|
| 341 | # Print out c file delimiter |
---|
| 342 | puts $c_file "" |
---|
| 343 | puts $c_file "/************************* Ethernet $eth_inst_num Definitions ****************************/" |
---|
| 344 | puts $c_file "" |
---|
| 345 | |
---|
| 346 | if { [string compare -nocase $inst_type "opb_ethernetlite"] == 0 || |
---|
| 347 | [string compare -nocase $inst_type "xps_ethernetlite"] == 0} { |
---|
| 348 | |
---|
| 349 | error "TBD: ethernetlite not yet supported. Please change HW design for $inst_name." "" "mdt_error" |
---|
| 350 | return |
---|
| 351 | |
---|
| 352 | } elseif { [string compare -nocase $inst_type "xps_ll_temac"] == 0} { |
---|
| 353 | |
---|
| 354 | # Determine the interface attached to the temac |
---|
| 355 | set inf_inst [get_ethernet_interface_periph $mhs_handle $inst] |
---|
| 356 | |
---|
| 357 | if { [llength $inf_inst] != 0 } { |
---|
| 358 | set inf_inst_type [xget_hw_value $inf_inst] |
---|
| 359 | set inf_inst_name [string toupper [xget_hw_name $inf_inst]] |
---|
| 360 | |
---|
| 361 | } else { |
---|
| 362 | error "Unable to find interface for $inst_name. Some common causes are |
---|
| 363 | 1. The interface of the TEMAC is left unconnected. |
---|
| 364 | 2. A custom peripheral is connected to the interface. The WARP Xilnet has been designed for use with the LL FIFO peripheral only." "" "mdt_error" |
---|
| 365 | } |
---|
| 366 | |
---|
| 367 | set inf_dma_inst [get_periph_instances $mhs_handle "xps_central_dma"] |
---|
| 368 | |
---|
| 369 | if { [llength $inf_dma_inst] != 0 } { |
---|
| 370 | set inf_dma_inst_type [xget_hw_value $inf_dma_inst] |
---|
| 371 | set inf_dma_inst_name [string toupper [xget_hw_name $inf_dma_inst]] |
---|
| 372 | |
---|
| 373 | print_h_file_temac $h_file $eth_inst_num $inst_name $inf_inst_name $inf_dma_inst_name $dma_rcvd_buf_cnt $fifo_buf_size $ignore |
---|
| 374 | print_c_file_temac $c_file $eth_inst_num $ignore |
---|
| 375 | |
---|
| 376 | } else { |
---|
| 377 | error "Unable to find the central dma interface for $inst_name. Some common causes are |
---|
| 378 | 1. A custom peripheral is used for dma to the temac. The WARP Xilnet has been designed for use with the CENTRAL DMA peripherals only." "" "mdt_error" |
---|
| 379 | } |
---|
| 380 | |
---|
| 381 | # Append one entry for TEMAC |
---|
| 382 | lappend inf_type_list $inst_type |
---|
| 383 | lappend ignore_list $ignore |
---|
| 384 | |
---|
| 385 | } elseif { [string compare -nocase $inst_type "axi_ethernet"] == 0} { |
---|
| 386 | |
---|
| 387 | # Determine the interface attached to the axi_ethernet |
---|
| 388 | set inf_inst [get_ethernet_interface_periph $mhs_handle $inst] |
---|
| 389 | |
---|
| 390 | if { [llength $inf_inst] != 0 } { |
---|
| 391 | set inf_inst_type [xget_hw_value $inf_inst] |
---|
| 392 | set inf_inst_name [string toupper [xget_hw_name $inf_inst]] |
---|
| 393 | |
---|
| 394 | lappend inf_type_list $inf_inst_type |
---|
| 395 | lappend ignore_list $ignore |
---|
| 396 | |
---|
| 397 | switch $inf_inst_type { |
---|
| 398 | "axi_fifo_mm_s" { |
---|
| 399 | print_h_file_fifo $h_file $eth_inst_num $inst_name $inf_inst_name $dma_rcvd_buf_cnt $fifo_buf_size $ignore |
---|
| 400 | print_c_file_fifo $c_file $eth_inst_num $ignore |
---|
| 401 | } |
---|
| 402 | |
---|
| 403 | "axi_dma" { |
---|
| 404 | print_h_file_dma $h_file $eth_inst_num $inst_name $inf_inst_name $dma_rcvd_buf_cnt $dma_buf_size $ignore |
---|
| 405 | print_c_file_dma $c_file $eth_inst_num $ignore |
---|
| 406 | } |
---|
| 407 | |
---|
| 408 | "default" { |
---|
| 409 | error "Unable to handle AXI connections for target type $target_periph_type. Some common causes are |
---|
| 410 | 1. The AXI4 Stream interface of the AXI Ethernet is left unconnected. |
---|
| 411 | 2. A custom peripheral is connected to the AXI interface. The WARP Xilnet has been designed for use with the AXI Streaming FIFO, and AXI DMA peripherals only." "" "mdt_error" |
---|
| 412 | } |
---|
| 413 | } |
---|
| 414 | } else { |
---|
[2688] | 415 | if { [regexp -nocase {eth_a} $inst_name] && $eth_a_uses_drvr == 0 || [regexp -nocase {eth_b} $inst_name] && $eth_b_uses_drvr == 0 } { |
---|
| 416 | print_h_file_fifo $h_file $eth_inst_num $inst_name "error" $dma_rcvd_buf_cnt $fifo_buf_size $ignore |
---|
| 417 | print_c_file_fifo $c_file $eth_inst_num $ignore |
---|
| 418 | } else { |
---|
| 419 | error "Unable to find AXI interface for $inst_name. Some common causes are |
---|
| 420 | 1. The AXI4 Stream interface of the AXI Ethernet is left unconnected. |
---|
| 421 | 2. A custom peripheral is connected to the AXI interface. The WARP Xilnet has been designed for use with the AXI Streaming FIFO, and AXI DMA peripherals only." "" "mdt_error" |
---|
| 422 | } |
---|
[2229] | 423 | } |
---|
| 424 | |
---|
| 425 | } else { |
---|
| 426 | error "$inst_name is not a TEMAC or ETHERNETLITE or AXI ETHERNET core. WARPXilNet can work only with such cores." "" "mdt_error" |
---|
| 427 | } |
---|
| 428 | |
---|
| 429 | # increment the instance number for the next iteration of the for loop |
---|
| 430 | incr eth_inst_num |
---|
| 431 | } |
---|
| 432 | |
---|
| 433 | print_h_file_footer $h_file |
---|
| 434 | print_c_file_footer $c_file $inf_type_list $ignore_list |
---|
| 435 | |
---|
| 436 | close $h_file |
---|
| 437 | close $c_file |
---|
| 438 | |
---|
| 439 | } |
---|
| 440 | |
---|
| 441 | |
---|
| 442 | proc print_h_file_header {file_handle udp_conns} { |
---|
| 443 | global ethernet_ninstances |
---|
| 444 | global ethernet_use_axi |
---|
| 445 | global ethernet_use_axi_dma |
---|
| 446 | global ethernet_use_axi_fifo |
---|
| 447 | global ethernet_use_temac |
---|
| 448 | |
---|
| 449 | # puts "\# USE DMA = $ethernet_use_axi_dma" |
---|
| 450 | # puts "\# USE FIFO = $ethernet_use_axi_fifo" |
---|
| 451 | |
---|
| 452 | # Check that if we only have an AXI interface, that we are either using |
---|
| 453 | # the DMA or the FIFO. Otherwise, xilnet should be removed to save code |
---|
| 454 | # space. |
---|
| 455 | if { $ethernet_use_axi != 0 && $ethernet_use_temac == 0 } { |
---|
| 456 | if { $ethernet_use_axi_fifo == 0 && $ethernet_use_axi_dma == 0 } { |
---|
| 457 | puts "\# --------------------------------------" |
---|
| 458 | puts "\# WARPxilnet WARNING:" |
---|
| 459 | puts "\# For a design only containing AXI Ethernet peripherals," |
---|
| 460 | puts "\# not using either the AXI DMA or AXI FIFO interfaces." |
---|
| 461 | puts "\# To save code space, please remove WARPxilnet library." |
---|
| 462 | puts "\# --------------------------------------" |
---|
| 463 | } |
---|
| 464 | } |
---|
| 465 | |
---|
| 466 | |
---|
| 467 | puts $file_handle "\#ifndef _XILNET_CONFIG_H" |
---|
| 468 | puts $file_handle "\#define _XILNET_CONFIG_H" |
---|
| 469 | puts $file_handle "" |
---|
| 470 | puts $file_handle "\#ifdef __cplusplus" |
---|
| 471 | puts $file_handle "extern \"C\" \{" |
---|
| 472 | puts $file_handle "\#endif" |
---|
| 473 | puts $file_handle "" |
---|
| 474 | |
---|
| 475 | # Uncomment the next line and clean the project to enable debug output on the UART |
---|
| 476 | # |
---|
| 477 | # puts $file_handle "\#define _DEBUG_" |
---|
| 478 | |
---|
| 479 | # Uncomment the next line and clean the project to enable performance monitoring on oscilloscope: |
---|
| 480 | # - Ethernet receive toggles GPIO 1 (see xilnet_eth.c) |
---|
| 481 | # - Ethernet transmit toggles GPIO 2 (see xilnet_eth.c) |
---|
| 482 | # |
---|
| 483 | # puts $file_handle "\#define _PERFORMANCE_MONITOR_" |
---|
| 484 | |
---|
| 485 | puts $file_handle "" |
---|
| 486 | puts $file_handle "/***************************** Include Files *********************************/" |
---|
| 487 | puts $file_handle "\#include <xilnet_xilsock.h>" |
---|
| 488 | puts $file_handle "\#include <xilnet_eth.h>" |
---|
| 489 | puts $file_handle "\#include <xparameters.h>" |
---|
| 490 | puts $file_handle "" |
---|
| 491 | |
---|
| 492 | # Determine HW includes |
---|
| 493 | # |
---|
| 494 | if { $ethernet_use_axi_dma != 0 } { |
---|
| 495 | puts $file_handle "\#include <xaxidma.h>" |
---|
| 496 | } |
---|
| 497 | if { $ethernet_use_axi_fifo != 0 } { |
---|
| 498 | puts $file_handle "\#include <xllfifo.h>" |
---|
| 499 | } |
---|
| 500 | if { $ethernet_use_temac != 0 } { |
---|
| 501 | puts $file_handle "\#include <xlltemac.h>" |
---|
| 502 | puts $file_handle "\#include <xllfifo.h>" |
---|
| 503 | puts $file_handle "\#include <xdmacentral.h>" |
---|
| 504 | puts $file_handle "\#include <xdmacentral_l.h>" |
---|
| 505 | } |
---|
| 506 | |
---|
| 507 | puts $file_handle "" |
---|
| 508 | puts $file_handle "/*************************** Constant Definitions ****************************/" |
---|
| 509 | puts $file_handle "" |
---|
| 510 | puts $file_handle "// Xilnet Global Defines" |
---|
| 511 | puts $file_handle "\#define XILNET_NUM_ETH_DEVICES $ethernet_ninstances // Define the number of Ethernet devices" |
---|
| 512 | |
---|
| 513 | if { $ethernet_use_axi_dma != 0 } { |
---|
| 514 | puts $file_handle "\#define XILNET_BD_ALIGNMENT XAXIDMA_BD_MINIMUM_ALIGNMENT // Buffer Descriptor alignment" |
---|
| 515 | } |
---|
| 516 | |
---|
| 517 | puts $file_handle "" |
---|
| 518 | puts $file_handle "// Define UDP connections" |
---|
| 519 | puts $file_handle "\#define XILNET_MAX_UDP_CONNS $udp_conns // maximum no of open udp conns" |
---|
| 520 | puts $file_handle "\#define NO_OF_XILSOCKS XILNET_MAX_UDP_CONNS // Number of sockets per Ethernet Device" |
---|
| 521 | puts $file_handle "" |
---|
| 522 | puts $file_handle "// Define Ethernet interface types" |
---|
| 523 | puts $file_handle "\#define XILNET_AXI_DMA_INF 1" |
---|
| 524 | puts $file_handle "\#define XILNET_AXI_FIFO_INF 2" |
---|
| 525 | puts $file_handle "\#define XILNET_TEMAC_INF 3" |
---|
| 526 | puts $file_handle "" |
---|
| 527 | puts $file_handle "// Define which interfaces are used" |
---|
| 528 | |
---|
| 529 | # Set defines for code inclusion in the WARPxilnet library |
---|
| 530 | # |
---|
| 531 | if { $ethernet_use_axi_dma != 0 } { |
---|
| 532 | puts $file_handle "\#define XILNET_AXI_DMA_INF_USED" |
---|
| 533 | } |
---|
| 534 | if { $ethernet_use_axi_fifo != 0 } { |
---|
| 535 | puts $file_handle "\#define XILNET_AXI_FIFO_INF_USED" |
---|
| 536 | } |
---|
| 537 | if { $ethernet_use_temac != 0 } { |
---|
| 538 | puts $file_handle "\#define XILNET_TEMAC_INF_USED" |
---|
| 539 | } |
---|
| 540 | |
---|
| 541 | puts $file_handle "" |
---|
| 542 | |
---|
| 543 | } |
---|
| 544 | |
---|
| 545 | |
---|
| 546 | proc print_h_file_fifo {file_handle inst_num inst_name inf_name num_rcv_buf buf_size ignore} { |
---|
| 547 | |
---|
| 548 | puts $file_handle "// Ethernet device $inst_num" |
---|
| 549 | puts $file_handle "\#define $inst_name XILNET_ETH_$inst_num // External name of Ethernet device" |
---|
| 550 | puts $file_handle "\#define XILNET_ETH_$inst_num $inst_num // Internal name of Ethernet device" |
---|
| 551 | puts $file_handle "" |
---|
| 552 | # Only one receive buffer supported for FIFO mode |
---|
| 553 | if { $ignore == 0 } { |
---|
[2688] | 554 | puts $file_handle [format "\#define XILNET_ETH_%s_INF_DEVICE_ID XPAR_%s_DEVICE_ID" $inst_num $inf_name] |
---|
[2229] | 555 | puts $file_handle [format "\#define XILNET_ETH_%s_NUM_RECV_BUF 1" $inst_num] |
---|
| 556 | puts $file_handle [format "\#define XILNET_ETH_%s_BUF_SIZE %s" $inst_num $buf_size] |
---|
| 557 | puts $file_handle "" |
---|
| 558 | puts $file_handle "// Variables for ETH $inst_num" |
---|
| 559 | puts $file_handle [format "extern XLlFifo ETH_%s_FIFO_Instance;" $inst_num] |
---|
| 560 | puts $file_handle "" |
---|
| 561 | puts $file_handle "// Buffers for ETH $inst_num" |
---|
| 562 | puts $file_handle [format "extern unsigned int recvBuffer_eth_%s\[XILNET_ETH_%s_NUM_RECV_BUF*((XILNET_ETH_%s_BUF_SIZE+3)/4)\];" $inst_num $inst_num $inst_num] |
---|
| 563 | puts $file_handle [format "extern unsigned int sendBuffer_eth_%s\[(XILNET_ETH_%s_BUF_SIZE+3)/4\];" $inst_num $inst_num] |
---|
| 564 | puts $file_handle "" |
---|
| 565 | } else { |
---|
[2688] | 566 | puts $file_handle [format "\#define XILNET_ETH_%s_INF_DEVICE_ID 0" $inst_num] |
---|
[2229] | 567 | puts $file_handle [format "\#define XILNET_ETH_%s_NUM_RECV_BUF 0" $inst_num] |
---|
| 568 | puts $file_handle [format "\#define XILNET_ETH_%s_BUF_SIZE 0" $inst_num $buf_size] |
---|
| 569 | puts $file_handle "" |
---|
| 570 | } |
---|
| 571 | } |
---|
| 572 | |
---|
| 573 | |
---|
| 574 | proc print_h_file_dma {file_handle inst_num inst_name inf_name num_rcv_buf buf_size ignore} { |
---|
| 575 | |
---|
| 576 | puts $file_handle "// Ethernet device $inst_num" |
---|
| 577 | puts $file_handle "\#define $inst_name XILNET_ETH_$inst_num // External name of Ethernet device" |
---|
| 578 | puts $file_handle "\#define XILNET_ETH_$inst_num $inst_num // Internal name of Ethernet device" |
---|
| 579 | puts $file_handle "" |
---|
| 580 | |
---|
| 581 | if { $ignore == 0 } { |
---|
[2688] | 582 | puts $file_handle [format "\#define XILNET_ETH_%s_INF_DEVICE_ID XPAR_%s_DEVICE_ID" $inst_num $inf_name] |
---|
[2229] | 583 | puts $file_handle [format "\#define XILNET_ETH_%s_NUM_RECV_BUF %s" $inst_num $num_rcv_buf] |
---|
| 584 | puts $file_handle [format "\#define XILNET_ETH_%s_BUF_SIZE %s" $inst_num $buf_size] |
---|
| 585 | |
---|
| 586 | # NOTE: For both Send and Receive, the number of buffer descriptors should equal the number of buffers |
---|
| 587 | puts $file_handle [format "\#define XILNET_ETH_%s_RXBD_CNT XILNET_ETH_%s_NUM_RECV_BUF // Number of RxBDs to use" $inst_num $inst_num] |
---|
| 588 | puts $file_handle [format "\#define XILNET_ETH_%s_TXBD_CNT 1 // Number of TxBDs to use" $inst_num] |
---|
| 589 | |
---|
| 590 | puts $file_handle [format "\#define XILNET_ETH_%s_RXBD_SPACE_BYTES (XAxiDma_BdRingMemCalc(XILNET_BD_ALIGNMENT, XILNET_ETH_%s_RXBD_CNT))" $inst_num $inst_num] |
---|
| 591 | puts $file_handle [format "\#define XILNET_ETH_%s_TXBD_SPACE_BYTES (XAxiDma_BdRingMemCalc(XILNET_BD_ALIGNMENT, XILNET_ETH_%s_TXBD_CNT))" $inst_num $inst_num] |
---|
| 592 | puts $file_handle "" |
---|
| 593 | puts $file_handle "// Variables for ETH $inst_num" |
---|
| 594 | puts $file_handle [format "extern XAxiDma ETH_%s_DMA_Instance;" $inst_num] |
---|
| 595 | puts $file_handle "" |
---|
| 596 | puts $file_handle "// Aligned memory segments to be used for buffer descriptors" |
---|
| 597 | puts $file_handle [format "extern char ETH_%s_RX_BD_space\[XILNET_ETH_%s_RXBD_SPACE_BYTES\] __attribute__ ((aligned(XILNET_BD_ALIGNMENT)));" $inst_num $inst_num] |
---|
| 598 | puts $file_handle [format "extern char ETH_%s_TX_BD_space\[XILNET_ETH_%s_TXBD_SPACE_BYTES\] __attribute__ ((aligned(XILNET_BD_ALIGNMENT)));" $inst_num $inst_num] |
---|
| 599 | puts $file_handle "" |
---|
| 600 | puts $file_handle "// Buffers for ETH $inst_num" |
---|
| 601 | puts $file_handle [format "extern unsigned int recvBuffer_eth_%s\[XILNET_ETH_%s_NUM_RECV_BUF*((XILNET_ETH_%s_BUF_SIZE+3)/4)\];" $inst_num $inst_num $inst_num] |
---|
| 602 | puts $file_handle [format "extern unsigned int sendBuffer_eth_%s\[(XILNET_ETH_%s_BUF_SIZE+3)/4\];" $inst_num $inst_num] |
---|
| 603 | puts $file_handle "" |
---|
| 604 | } else { |
---|
[2688] | 605 | puts $file_handle [format "\#define XILNET_ETH_%s_INF_DEVICE_ID 0" $inst_num] |
---|
[2229] | 606 | puts $file_handle [format "\#define XILNET_ETH_%s_NUM_RECV_BUF 0" $inst_num] |
---|
| 607 | puts $file_handle [format "\#define XILNET_ETH_%s_BUF_SIZE 0" $inst_num] |
---|
| 608 | |
---|
| 609 | # NOTE: For both Send and Receive, the number of buffer descriptors should equal the number of buffers |
---|
| 610 | puts $file_handle [format "\#define XILNET_ETH_%s_RXBD_CNT 0 // Number of RxBDs to use" $inst_num] |
---|
| 611 | puts $file_handle [format "\#define XILNET_ETH_%s_TXBD_CNT 0 // Number of TxBDs to use" $inst_num] |
---|
| 612 | |
---|
| 613 | puts $file_handle [format "\#define XILNET_ETH_%s_RXBD_SPACE_BYTES 0" $inst_num] |
---|
| 614 | puts $file_handle [format "\#define XILNET_ETH_%s_TXBD_SPACE_BYTES 0" $inst_num] |
---|
| 615 | puts $file_handle "" |
---|
| 616 | } |
---|
| 617 | } |
---|
| 618 | |
---|
| 619 | |
---|
| 620 | proc print_h_file_temac {file_handle inst_num inst_name inf_name inf_dma_name num_rcv_buf buf_size ignore} { |
---|
| 621 | |
---|
| 622 | puts $file_handle "// Ethernet device $inst_num" |
---|
| 623 | puts $file_handle "\#define $inst_name XILNET_ETH_$inst_num // External name of Ethernet device" |
---|
| 624 | puts $file_handle "\#define XILNET_ETH_$inst_num $inst_num // Internal name of Ethernet device" |
---|
| 625 | puts $file_handle "" |
---|
| 626 | puts $file_handle [format "\#define XILNET_ETH_%s_INF_DEVICE_ID XPAR_%s_DEVICE_ID" $inst_num $inf_name] |
---|
| 627 | puts $file_handle [format "\#define XILNET_ETH_%s_INF_DMA_DEVICE_ID XPAR_%s_DEVICE_ID" $inst_num $inf_dma_name] |
---|
| 628 | # Only one receive buffer supported for FIFO mode |
---|
| 629 | if { $ignore == 0 } { |
---|
| 630 | puts $file_handle [format "\#define XILNET_ETH_%s_NUM_RECV_BUF 1" $inst_num] |
---|
| 631 | puts $file_handle [format "\#define XILNET_ETH_%s_BUF_SIZE %s" $inst_num $buf_size] |
---|
| 632 | puts $file_handle "" |
---|
| 633 | puts $file_handle "// Variables for ETH $inst_num" |
---|
| 634 | puts $file_handle [format "extern XLlFifo ETH_%s_FIFO_Instance;" $inst_num] |
---|
| 635 | puts $file_handle [format "extern XDmaCentral ETH_%s_DMA_Instance;" $inst_num] |
---|
| 636 | puts $file_handle [format "extern XDmaCentral_Config *ETH_%s_DMA_CFG_ptr;" $inst_num] |
---|
| 637 | puts $file_handle "" |
---|
| 638 | puts $file_handle "// Buffers for ETH $inst_num" |
---|
| 639 | puts $file_handle [format "extern unsigned int recvBuffer_eth_%s\[XILNET_ETH_%s_NUM_RECV_BUF*((XILNET_ETH_%s_BUF_SIZE+3)/4)\];" $inst_num $inst_num $inst_num] |
---|
| 640 | puts $file_handle [format "extern unsigned int sendBuffer_eth_%s\[(XILNET_ETH_%s_BUF_SIZE+3)/4\];" $inst_num $inst_num] |
---|
| 641 | puts $file_handle "" |
---|
| 642 | } else { |
---|
| 643 | puts $file_handle [format "\#define XILNET_ETH_%s_NUM_RECV_BUF 0" $inst_num] |
---|
| 644 | puts $file_handle [format "\#define XILNET_ETH_%s_BUF_SIZE 0" $inst_num] |
---|
| 645 | puts $file_handle "" |
---|
| 646 | } |
---|
| 647 | } |
---|
| 648 | |
---|
| 649 | |
---|
| 650 | proc print_h_file_footer {file_handle} { |
---|
| 651 | |
---|
| 652 | puts $file_handle "" |
---|
| 653 | puts $file_handle "/*********************** Global Variable Definitions *************************/" |
---|
| 654 | puts $file_handle "" |
---|
| 655 | puts $file_handle "// Ethernet Device Structure" |
---|
| 656 | puts $file_handle "extern xilnet_eth_device eth_device\[XILNET_NUM_ETH_DEVICES\];" |
---|
| 657 | puts $file_handle "" |
---|
| 658 | puts $file_handle "/*************************** Function Prototypes *****************************/" |
---|
| 659 | puts $file_handle "" |
---|
| 660 | puts $file_handle "void xilnet_init_eth_device_struct(unsigned int);" |
---|
| 661 | puts $file_handle "" |
---|
| 662 | puts $file_handle "\#endif" |
---|
| 663 | puts $file_handle "" |
---|
| 664 | puts $file_handle "/*****************************************************************************/" |
---|
| 665 | puts $file_handle "" |
---|
| 666 | |
---|
| 667 | } |
---|
| 668 | |
---|
| 669 | |
---|
| 670 | proc print_c_file_header {file_handle} { |
---|
| 671 | global ethernet_ninstances |
---|
| 672 | |
---|
| 673 | puts $file_handle "" |
---|
| 674 | puts $file_handle "/***************************** Include Files *********************************/" |
---|
| 675 | puts $file_handle "" |
---|
| 676 | puts $file_handle "\#include <string.h>" |
---|
| 677 | puts $file_handle "\#include <xilnet_config.h>" |
---|
| 678 | puts $file_handle "" |
---|
| 679 | |
---|
| 680 | } |
---|
| 681 | |
---|
| 682 | |
---|
| 683 | proc print_c_file_fifo {file_handle inst_num ignore} { |
---|
| 684 | |
---|
| 685 | if { $ignore == 0 } { |
---|
| 686 | puts $file_handle "" |
---|
| 687 | puts $file_handle "// Variables for ETH $inst_num" |
---|
| 688 | puts $file_handle [format "XLlFifo ETH_%s_FIFO_Instance;" $inst_num] |
---|
| 689 | puts $file_handle "" |
---|
| 690 | puts $file_handle "// Buffers for ETH $inst_num" |
---|
| 691 | puts $file_handle [format "unsigned int recvBuffer_eth_%s\[XILNET_ETH_%s_NUM_RECV_BUF*((XILNET_ETH_%s_BUF_SIZE+3)/4)\];" $inst_num $inst_num $inst_num] |
---|
| 692 | puts $file_handle [format "unsigned int sendBuffer_eth_%s\[(XILNET_ETH_%s_BUF_SIZE+3)/4\];" $inst_num $inst_num] |
---|
| 693 | puts $file_handle [format "struct xilsock_socket xilsock_sockets_eth_%s\[NO_OF_XILSOCKS\];" $inst_num] |
---|
| 694 | puts $file_handle [format "struct xilnet_udp_conn xilnet_udp_conns_eth_%s\[XILNET_MAX_UDP_CONNS\];" $inst_num] |
---|
| 695 | puts $file_handle "" |
---|
| 696 | } else { |
---|
| 697 | puts $file_handle "" |
---|
| 698 | puts $file_handle "// Variables for ETH $inst_num" |
---|
| 699 | puts $file_handle "// NONE - WARPxilnet library configured to ignore ETH $inst_num" |
---|
| 700 | puts $file_handle "" |
---|
| 701 | puts $file_handle "// Buffers for ETH $inst_num" |
---|
| 702 | puts $file_handle "// NONE - WARPxilnet library configured to ignore ETH $inst_num" |
---|
| 703 | puts $file_handle "" |
---|
| 704 | } |
---|
| 705 | } |
---|
| 706 | |
---|
| 707 | |
---|
| 708 | proc print_c_file_dma {file_handle inst_num ignore} { |
---|
| 709 | |
---|
| 710 | if { $ignore == 0 } { |
---|
| 711 | puts $file_handle "" |
---|
| 712 | puts $file_handle "// Variables for ETH $inst_num" |
---|
| 713 | puts $file_handle [format "XAxiDma ETH_%s_DMA_Instance;" $inst_num] |
---|
| 714 | puts $file_handle "" |
---|
| 715 | puts $file_handle "// Aligned memory segments to be used for buffer descriptors" |
---|
| 716 | puts $file_handle [format "char ETH_%s_RX_BD_space\[XILNET_ETH_%s_RXBD_SPACE_BYTES\] __attribute__ ((aligned(XILNET_BD_ALIGNMENT)));" $inst_num $inst_num] |
---|
| 717 | puts $file_handle [format "char ETH_%s_TX_BD_space\[XILNET_ETH_%s_TXBD_SPACE_BYTES\] __attribute__ ((aligned(XILNET_BD_ALIGNMENT)));" $inst_num $inst_num] |
---|
| 718 | puts $file_handle "" |
---|
| 719 | puts $file_handle "// Buffers for ETH $inst_num" |
---|
| 720 | puts $file_handle [format "unsigned int recvBuffer_eth_%s\[XILNET_ETH_%s_NUM_RECV_BUF*((XILNET_ETH_%s_BUF_SIZE+3)/4)\];" $inst_num $inst_num $inst_num] |
---|
| 721 | puts $file_handle [format "unsigned int sendBuffer_eth_%s\[(XILNET_ETH_%s_BUF_SIZE+3)/4\];" $inst_num $inst_num] |
---|
| 722 | puts $file_handle [format "struct xilsock_socket xilsock_sockets_eth_%s\[NO_OF_XILSOCKS\];" $inst_num] |
---|
| 723 | puts $file_handle [format "struct xilnet_udp_conn xilnet_udp_conns_eth_%s\[XILNET_MAX_UDP_CONNS\];" $inst_num] |
---|
| 724 | puts $file_handle "" |
---|
| 725 | } else { |
---|
| 726 | puts $file_handle "" |
---|
| 727 | puts $file_handle "// Variables for ETH $inst_num" |
---|
| 728 | puts $file_handle "// NONE - WARPxilnet library configured to ignore ETH $inst_num" |
---|
| 729 | puts $file_handle "" |
---|
| 730 | puts $file_handle "// Buffers for ETH $inst_num" |
---|
| 731 | puts $file_handle "// NONE - WARPxilnet library configured to ignore ETH $inst_num" |
---|
| 732 | puts $file_handle "" |
---|
| 733 | } |
---|
| 734 | } |
---|
| 735 | |
---|
| 736 | |
---|
| 737 | proc print_c_file_temac {file_handle inst_num ignore} { |
---|
| 738 | |
---|
| 739 | if { $ignore == 0 } { |
---|
| 740 | puts $file_handle "" |
---|
| 741 | puts $file_handle "// Variables for ETH $inst_num" |
---|
| 742 | puts $file_handle [format "XLlFifo ETH_%s_FIFO_Instance;" $inst_num] |
---|
| 743 | puts $file_handle [format "XDmaCentral ETH_%s_DMA_Instance;" $inst_num] |
---|
| 744 | puts $file_handle "" |
---|
| 745 | puts $file_handle "// Buffers for ETH $inst_num" |
---|
| 746 | puts $file_handle [format "unsigned int recvBuffer_eth_%s\[XILNET_ETH_%s_NUM_RECV_BUF*((XILNET_ETH_%s_BUF_SIZE+3)/4)\];" $inst_num $inst_num $inst_num] |
---|
| 747 | puts $file_handle [format "unsigned int sendBuffer_eth_%s\[(XILNET_ETH_%s_BUF_SIZE+3)/4\];" $inst_num $inst_num] |
---|
| 748 | puts $file_handle [format "struct xilsock_socket xilsock_sockets_eth_%s\[NO_OF_XILSOCKS\];" $inst_num] |
---|
| 749 | puts $file_handle [format "struct xilnet_udp_conn xilnet_udp_conns_eth_%s\[XILNET_MAX_UDP_CONNS\];" $inst_num] |
---|
| 750 | puts $file_handle "" |
---|
| 751 | } else { |
---|
| 752 | puts $file_handle "" |
---|
| 753 | puts $file_handle "// Variables for ETH $inst_num" |
---|
| 754 | puts $file_handle "// NONE - WARPxilnet library configured to ignore ETH $inst_num" |
---|
| 755 | puts $file_handle "" |
---|
| 756 | puts $file_handle "// Buffers for ETH $inst_num" |
---|
| 757 | puts $file_handle "// NONE - WARPxilnet library configured to ignore ETH $inst_num" |
---|
| 758 | puts $file_handle "" |
---|
| 759 | } |
---|
| 760 | } |
---|
| 761 | |
---|
| 762 | |
---|
| 763 | proc print_c_file_footer {file_handle inf_type_list ignore_list} { |
---|
| 764 | |
---|
| 765 | set inst_num 0 |
---|
| 766 | |
---|
| 767 | puts $file_handle "" |
---|
| 768 | puts $file_handle "/*************************** Ethernet Variables ******************************/" |
---|
| 769 | puts $file_handle "" |
---|
| 770 | puts $file_handle "" |
---|
| 771 | puts $file_handle "// Ethernet Device Structure" |
---|
| 772 | puts $file_handle "xilnet_eth_device eth_device\[XILNET_NUM_ETH_DEVICES\];" |
---|
| 773 | puts $file_handle "" |
---|
| 774 | puts $file_handle "" |
---|
| 775 | puts $file_handle "void xilnet_init_eth_device_struct(unsigned int eth_dev_num) \{" |
---|
| 776 | puts $file_handle "" |
---|
| 777 | puts $file_handle " switch( eth_dev_num ) \{" |
---|
| 778 | |
---|
| 779 | foreach inf_type $inf_type_list { |
---|
| 780 | set ignore [lindex $ignore_list $inst_num] |
---|
| 781 | |
---|
| 782 | puts $file_handle [format " case XILNET_ETH_%s:" $inst_num] |
---|
| 783 | if { $ignore == 0 } { |
---|
| 784 | puts $file_handle " eth_device\[eth_dev_num\].uses_driver = 1;" |
---|
| 785 | } else { |
---|
| 786 | puts $file_handle " eth_device\[eth_dev_num\].uses_driver = 0;" |
---|
| 787 | } |
---|
| 788 | |
---|
| 789 | switch $inf_type { |
---|
| 790 | "axi_fifo_mm_s" { |
---|
| 791 | puts $file_handle " eth_device\[eth_dev_num\].inf_type = XILNET_AXI_FIFO_INF;" |
---|
| 792 | puts $file_handle [format " eth_device\[eth_dev_num\].inf_id = XILNET_ETH_%s_INF_DEVICE_ID;" $inst_num] |
---|
| 793 | if { $ignore == 0 } { |
---|
| 794 | puts $file_handle [format " eth_device\[eth_dev_num\].inf_ref = Ð_%s_FIFO_Instance;" $inst_num] |
---|
| 795 | } else { |
---|
| 796 | puts $file_handle " eth_device\[eth_dev_num\].inf_ref = 0;" |
---|
| 797 | } |
---|
| 798 | puts $file_handle " eth_device\[eth_dev_num\].inf_cfg_ref = 0;" |
---|
| 799 | puts $file_handle " eth_device\[eth_dev_num\].inf_dma_id = 0;" |
---|
| 800 | puts $file_handle " eth_device\[eth_dev_num\].inf_dma_ref = 0;" |
---|
| 801 | puts $file_handle " eth_device\[eth_dev_num\].inf_dma_cfg_ref = 0;" |
---|
| 802 | puts $file_handle " eth_device\[eth_dev_num\].dma_rx_ring_ref = 0;" |
---|
| 803 | puts $file_handle " eth_device\[eth_dev_num\].dma_tx_ring_ref = 0;" |
---|
| 804 | puts $file_handle " eth_device\[eth_dev_num\].dma_rx_bd_ref = 0;" |
---|
| 805 | puts $file_handle " eth_device\[eth_dev_num\].dma_tx_bd_ref = 0;" |
---|
| 806 | puts $file_handle " eth_device\[eth_dev_num\].dma_rx_bd_cnt = 0;" |
---|
| 807 | puts $file_handle " eth_device\[eth_dev_num\].dma_tx_bd_cnt = 0;" |
---|
| 808 | } |
---|
| 809 | "axi_dma" { |
---|
| 810 | puts $file_handle " eth_device\[eth_dev_num\].inf_type = XILNET_AXI_DMA_INF;" |
---|
| 811 | puts $file_handle [format " eth_device\[eth_dev_num\].inf_id = XILNET_ETH_%s_INF_DEVICE_ID;" $inst_num] |
---|
| 812 | if { $ignore == 0 } { |
---|
| 813 | puts $file_handle [format " eth_device\[eth_dev_num\].inf_ref = Ð_%s_DMA_Instance;" $inst_num] |
---|
| 814 | } else { |
---|
| 815 | puts $file_handle " eth_device\[eth_dev_num\].inf_ref = 0;" |
---|
| 816 | } |
---|
| 817 | puts $file_handle " eth_device\[eth_dev_num\].inf_cfg_ref = 0;" |
---|
| 818 | puts $file_handle " eth_device\[eth_dev_num\].inf_dma_id = 0;" |
---|
| 819 | puts $file_handle " eth_device\[eth_dev_num\].inf_dma_ref = 0;" |
---|
| 820 | puts $file_handle " eth_device\[eth_dev_num\].inf_dma_cfg_ref = 0;" |
---|
| 821 | puts $file_handle " eth_device\[eth_dev_num\].dma_rx_ring_ref = 0;" |
---|
| 822 | puts $file_handle " eth_device\[eth_dev_num\].dma_tx_ring_ref = 0;" |
---|
| 823 | if { $ignore == 0 } { |
---|
| 824 | puts $file_handle [format " eth_device\[eth_dev_num\].dma_rx_bd_ref = Ð_%s_RX_BD_space;" $inst_num] |
---|
| 825 | puts $file_handle [format " eth_device\[eth_dev_num\].dma_tx_bd_ref = Ð_%s_TX_BD_space;" $inst_num] |
---|
| 826 | } else { |
---|
| 827 | puts $file_handle " eth_device\[eth_dev_num\].dma_rx_bd_ref = 0;" |
---|
| 828 | puts $file_handle " eth_device\[eth_dev_num\].dma_tx_bd_ref = 0;" |
---|
| 829 | } |
---|
| 830 | puts $file_handle [format " eth_device\[eth_dev_num\].dma_rx_bd_cnt = XILNET_ETH_%s_RXBD_CNT;" $inst_num] |
---|
| 831 | puts $file_handle [format " eth_device\[eth_dev_num\].dma_tx_bd_cnt = XILNET_ETH_%s_TXBD_CNT;" $inst_num] |
---|
| 832 | } |
---|
| 833 | "xps_ll_temac" { |
---|
| 834 | puts $file_handle " eth_device\[eth_dev_num\].inf_type = XILNET_TEMAC_INF;" |
---|
| 835 | puts $file_handle [format " eth_device\[eth_dev_num\].inf_id = XILNET_ETH_%s_INF_DEVICE_ID;" $inst_num] |
---|
| 836 | if { $ignore == 0 } { |
---|
| 837 | puts $file_handle [format " eth_device\[eth_dev_num\].inf_ref = Ð_%s_FIFO_Instance;" $inst_num] |
---|
| 838 | } else { |
---|
| 839 | puts $file_handle " eth_device\[eth_dev_num\].inf_ref = 0;" |
---|
| 840 | } |
---|
| 841 | puts $file_handle " eth_device\[eth_dev_num\].inf_cfg_ref = 0;" |
---|
| 842 | puts $file_handle [format " eth_device\[eth_dev_num\].inf_dma_id = XILNET_ETH_%s_INF_DMA_DEVICE_ID;" $inst_num] |
---|
| 843 | if { $ignore == 0 } { |
---|
| 844 | puts $file_handle [format " eth_device\[eth_dev_num\].inf_dma_ref = Ð_%s_DMA_Instance;" $inst_num] |
---|
| 845 | } else { |
---|
| 846 | puts $file_handle " eth_device\[eth_dev_num\].inf_dma_ref = 0;" |
---|
| 847 | } |
---|
| 848 | puts $file_handle " eth_device\[eth_dev_num\].inf_dma_cfg_ref = 0;" |
---|
| 849 | puts $file_handle " eth_device\[eth_dev_num\].dma_rx_ring_ref = 0;" |
---|
| 850 | puts $file_handle " eth_device\[eth_dev_num\].dma_tx_ring_ref = 0;" |
---|
| 851 | puts $file_handle " eth_device\[eth_dev_num\].dma_rx_bd_ref = 0;" |
---|
| 852 | puts $file_handle " eth_device\[eth_dev_num\].dma_tx_bd_ref = 0;" |
---|
| 853 | puts $file_handle " eth_device\[eth_dev_num\].dma_rx_bd_cnt = 0;" |
---|
| 854 | puts $file_handle " eth_device\[eth_dev_num\].dma_tx_bd_cnt = 0;" |
---|
| 855 | } |
---|
[2688] | 856 | "default" { |
---|
| 857 | puts $file_handle " eth_device\[eth_dev_num\].inf_type = XILNET_AXI_FIFO_INF;" |
---|
| 858 | puts $file_handle [format " eth_device\[eth_dev_num\].inf_id = XILNET_ETH_%s_INF_DEVICE_ID;" $inst_num] |
---|
| 859 | if { $ignore == 0 } { |
---|
| 860 | puts $file_handle [format " eth_device\[eth_dev_num\].inf_ref = Ð_%s_FIFO_Instance;" $inst_num] |
---|
| 861 | } else { |
---|
| 862 | puts $file_handle " eth_device\[eth_dev_num\].inf_ref = 0;" |
---|
| 863 | } |
---|
| 864 | puts $file_handle " eth_device\[eth_dev_num\].inf_cfg_ref = 0;" |
---|
| 865 | puts $file_handle " eth_device\[eth_dev_num\].inf_dma_id = 0;" |
---|
| 866 | puts $file_handle " eth_device\[eth_dev_num\].inf_dma_ref = 0;" |
---|
| 867 | puts $file_handle " eth_device\[eth_dev_num\].inf_dma_cfg_ref = 0;" |
---|
| 868 | puts $file_handle " eth_device\[eth_dev_num\].dma_rx_ring_ref = 0;" |
---|
| 869 | puts $file_handle " eth_device\[eth_dev_num\].dma_tx_ring_ref = 0;" |
---|
| 870 | puts $file_handle " eth_device\[eth_dev_num\].dma_rx_bd_ref = 0;" |
---|
| 871 | puts $file_handle " eth_device\[eth_dev_num\].dma_tx_bd_ref = 0;" |
---|
| 872 | puts $file_handle " eth_device\[eth_dev_num\].dma_rx_bd_cnt = 0;" |
---|
| 873 | puts $file_handle " eth_device\[eth_dev_num\].dma_tx_bd_cnt = 0;" |
---|
| 874 | } |
---|
[2229] | 875 | } |
---|
| 876 | |
---|
| 877 | puts $file_handle " eth_device\[eth_dev_num\].xilsock_status_flag = 0;" |
---|
| 878 | puts $file_handle " eth_device\[eth_dev_num\].sync_IP_octet = 255;" |
---|
| 879 | puts $file_handle " eth_device\[eth_dev_num\].is_xilsock_init = 0;" |
---|
| 880 | if { $ignore == 0 } { |
---|
| 881 | puts $file_handle [format " eth_device\[eth_dev_num\].xilsock_sockets = &xilsock_sockets_eth_%s;" $inst_num] |
---|
| 882 | puts $file_handle " eth_device\[eth_dev_num\].is_udp_init = 0;" |
---|
| 883 | puts $file_handle [format " eth_device\[eth_dev_num\].xilnet_udp_conns = &xilnet_udp_conns_eth_%s;" $inst_num] |
---|
| 884 | puts $file_handle [format " eth_device\[eth_dev_num\].buf_size = XILNET_ETH_%s_BUF_SIZE;" $inst_num] |
---|
| 885 | puts $file_handle [format " eth_device\[eth_dev_num\].num_recvbuf = XILNET_ETH_%s_NUM_RECV_BUF;" $inst_num] |
---|
| 886 | puts $file_handle [format " eth_device\[eth_dev_num\].recvbuf = (unsigned int *)&recvBuffer_eth_%s;" $inst_num] |
---|
| 887 | puts $file_handle [format " eth_device\[eth_dev_num\].sendbuf = (unsigned int *)&sendBuffer_eth_%s;" $inst_num] |
---|
| 888 | } else { |
---|
| 889 | puts $file_handle " eth_device\[eth_dev_num\].xilsock_sockets = 0;" |
---|
| 890 | puts $file_handle " eth_device\[eth_dev_num\].is_udp_init = 0;" |
---|
| 891 | puts $file_handle " eth_device\[eth_dev_num\].xilnet_udp_conns = 0;" |
---|
| 892 | puts $file_handle [format " eth_device\[eth_dev_num\].buf_size = XILNET_ETH_%s_BUF_SIZE;" $inst_num] |
---|
| 893 | puts $file_handle [format " eth_device\[eth_dev_num\].num_recvbuf = XILNET_ETH_%s_NUM_RECV_BUF;" $inst_num] |
---|
| 894 | puts $file_handle " eth_device\[eth_dev_num\].recvbuf = 0;" |
---|
| 895 | puts $file_handle " eth_device\[eth_dev_num\].sendbuf = 0;" |
---|
| 896 | } |
---|
| 897 | puts $file_handle " break;" |
---|
| 898 | |
---|
| 899 | incr inst_num |
---|
| 900 | } |
---|
| 901 | |
---|
| 902 | puts $file_handle " default:" |
---|
| 903 | puts $file_handle " xil_printf(\" **** ERROR: Trying to initialize Ethernet device %d. Only %d configured in the HW.\", (eth_dev_num+1), XILNET_NUM_ETH_DEVICES);" |
---|
| 904 | puts $file_handle " break;" |
---|
| 905 | puts $file_handle " \}" |
---|
| 906 | puts $file_handle "\}" |
---|
| 907 | puts $file_handle "" |
---|
| 908 | puts $file_handle "" |
---|
| 909 | puts $file_handle "/*****************************************************************************/" |
---|
| 910 | puts $file_handle "" |
---|
| 911 | |
---|
| 912 | } |
---|
| 913 | |
---|