2014-06-24 16:45:01 +05:30
|
|
|
###############################################################################
|
|
|
|
#
|
|
|
|
# Copyright (C) 2011 - 2014 Xilinx, Inc. All rights reserved.
|
|
|
|
#
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
2015-04-10 10:59:51 +05:30
|
|
|
# of this software and associated documentation files (the "Software"), to deal
|
2014-06-24 16:45:01 +05:30
|
|
|
# in the Software without restriction, including without limitation the rights
|
|
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
# copies of the Software, and to permit persons to whom the Software is
|
|
|
|
# furnished to do so, subject to the following conditions:
|
|
|
|
#
|
|
|
|
# The above copyright notice and this permission notice shall be included in
|
|
|
|
# all copies or substantial portions of the Software.
|
|
|
|
#
|
|
|
|
# Use of the Software is limited solely to applications:
|
|
|
|
# (a) running on a Xilinx device, or
|
|
|
|
# (b) that interact with a Xilinx device through a bus or interconnect.
|
|
|
|
#
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
# XILINX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
2015-04-10 10:59:51 +05:30
|
|
|
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
2014-06-24 16:45:01 +05:30
|
|
|
# OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
# SOFTWARE.
|
|
|
|
#
|
|
|
|
# Except as contained in this notice, the name of the Xilinx shall not be used
|
|
|
|
# in advertising or otherwise to promote the sale, use or other dealings in
|
|
|
|
# this Software without prior written authorization from Xilinx.
|
|
|
|
#
|
|
|
|
###############################################################################
|
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# Modification History
|
|
|
|
#
|
|
|
|
# Ver Who Date Changes
|
|
|
|
# ----- ---- -------- -----------------------------------------------
|
|
|
|
# 1.00a sdm 11/22/11 Created
|
|
|
|
# 3.0 adk 10/12/13 Updated as per the New Tcl API's
|
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
#uses "xillib.tcl"
|
|
|
|
|
|
|
|
proc generate {drv_handle} {
|
|
|
|
xdefine_include_file_zynq $drv_handle "xparameters.h" "XDcfg" "NUM_INSTANCES" "DEVICE_ID" "C_S_AXI_BASEADDR" "C_S_AXI_HIGHADDR"
|
|
|
|
|
|
|
|
xdefine_devcfg_config_file $drv_handle "xdevcfg_g.c" "XDcfg" "DEVICE_ID" "C_S_AXI_BASEADDR"
|
|
|
|
|
|
|
|
xdefine_canonical_xpars_zynq $drv_handle "xparameters.h" "XDcfg" "DEVICE_ID" "C_S_AXI_BASEADDR" "C_S_AXI_HIGHADDR"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
proc xdefine_include_file_zynq {drv_handle file_name drv_string args} {
|
|
|
|
# Open include file
|
2014-06-03 15:21:32 +05:30
|
|
|
set file_handle [::hsm::utils::open_include_file $file_name]
|
2014-06-24 16:45:01 +05:30
|
|
|
|
|
|
|
# Get all peripherals connected to this driver
|
2015-04-10 10:59:51 +05:30
|
|
|
set periphs [::hsm::utils::get_common_driver_ips $drv_handle]
|
2014-06-24 16:45:01 +05:30
|
|
|
|
|
|
|
# Handle special cases
|
|
|
|
set arg "NUM_INSTANCES"
|
|
|
|
set posn [lsearch -exact $args $arg]
|
|
|
|
if {$posn > -1} {
|
2015-04-10 10:59:51 +05:30
|
|
|
puts $file_handle "/* Definitions for driver [string toupper [common::get_property NAME $drv_handle]] */"
|
2014-06-24 16:45:01 +05:30
|
|
|
# Define NUM_INSTANCES
|
2014-06-03 15:21:32 +05:30
|
|
|
puts $file_handle "#define [::hsm::utils::get_driver_param_name $drv_string $arg] [llength $periphs]"
|
2014-06-24 16:45:01 +05:30
|
|
|
set args [lreplace $args $posn $posn]
|
|
|
|
}
|
|
|
|
# Check if it is a driver parameter
|
|
|
|
|
2015-04-10 10:59:51 +05:30
|
|
|
lappend newargs
|
2014-06-24 16:45:01 +05:30
|
|
|
foreach arg $args {
|
2015-04-10 10:59:51 +05:30
|
|
|
set value [common::get_property CONFIG.$arg $drv_handle]
|
2014-06-24 16:45:01 +05:30
|
|
|
if {[llength $value] == 0} {
|
|
|
|
lappend newargs $arg
|
|
|
|
} else {
|
2015-04-10 10:59:51 +05:30
|
|
|
puts $file_handle "#define [::hsm::utils::get_driver_param_name $drv_string $arg] [common::get_property CONFIG.$arg $drv_handle]"
|
2014-06-24 16:45:01 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
set args $newargs
|
|
|
|
|
|
|
|
# Print all parameters for all peripherals
|
|
|
|
set device_id 0
|
|
|
|
foreach periph $periphs {
|
|
|
|
puts $file_handle ""
|
2015-04-10 10:59:51 +05:30
|
|
|
puts $file_handle "/* Definitions for peripheral [string toupper [common::get_property NAME $periph]] */"
|
2014-06-24 16:45:01 +05:30
|
|
|
foreach arg $args {
|
|
|
|
if {[string compare -nocase "DEVICE_ID" $arg] == 0} {
|
|
|
|
set value $device_id
|
|
|
|
incr device_id
|
|
|
|
} else {
|
2014-06-03 15:21:32 +05:30
|
|
|
set value [::hsm::utils::get_param_value $periph $arg]
|
2014-06-24 16:45:01 +05:30
|
|
|
}
|
|
|
|
if {[llength $value] == 0} {
|
|
|
|
set value 0
|
|
|
|
}
|
2014-06-03 15:21:32 +05:30
|
|
|
set value [::hsm::utils::format_addr_string $value $arg]
|
|
|
|
set arg_name [::hsm::utils::get_ip_param_name $periph $arg]
|
2014-06-24 16:45:01 +05:30
|
|
|
regsub "S_AXI_" $arg_name "" arg_name
|
|
|
|
if {[string compare -nocase "HW_VER" $arg] == 0} {
|
|
|
|
puts $file_handle "#define $arg_name \"$value\""
|
|
|
|
} else {
|
|
|
|
puts $file_handle "#define $arg_name $value"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
puts $file_handle ""
|
2015-04-10 10:59:51 +05:30
|
|
|
}
|
2014-06-24 16:45:01 +05:30
|
|
|
puts $file_handle "\n/******************************************************************/\n"
|
|
|
|
close $file_handle
|
|
|
|
}
|
|
|
|
|
|
|
|
proc xdefine_devcfg_config_file {drv_handle file_name drv_string args} {
|
2015-04-10 10:59:51 +05:30
|
|
|
set filename [file join "src" $file_name]
|
2014-06-24 16:45:01 +05:30
|
|
|
file delete $filename
|
|
|
|
set config_file [open $filename w]
|
2015-04-10 10:59:51 +05:30
|
|
|
::hsm::utils::write_c_header $config_file "Driver configuration"
|
2014-06-24 16:45:01 +05:30
|
|
|
puts $config_file "#include \"xparameters.h\""
|
|
|
|
puts $config_file "#include \"xdevcfg.h\""
|
|
|
|
puts $config_file "\n/*"
|
|
|
|
puts $config_file "* The configuration table for devices"
|
|
|
|
puts $config_file "*/\n"
|
|
|
|
puts $config_file [format "%s_Config %s_ConfigTable\[\] =" $drv_string $drv_string]
|
|
|
|
puts $config_file "\{"
|
2015-04-10 10:59:51 +05:30
|
|
|
set periphs [::hsm::utils::get_common_driver_ips $drv_handle]
|
2014-06-24 16:45:01 +05:30
|
|
|
set start_comma ""
|
|
|
|
foreach periph $periphs {
|
|
|
|
puts $config_file [format "%s\t\{" $start_comma]
|
|
|
|
set comma ""
|
|
|
|
foreach arg $args {
|
|
|
|
# Check if this is a driver parameter or a peripheral parameter
|
2015-04-10 10:59:51 +05:30
|
|
|
set value [common::get_property CONFIG.$arg $drv_handle]
|
2014-06-24 16:45:01 +05:30
|
|
|
if {[llength $value] == 0} {
|
2015-04-10 10:59:51 +05:30
|
|
|
set local_value [common::get_property CONFIG.$arg $periph]
|
2014-06-24 16:45:01 +05:30
|
|
|
# If a parameter isn't found locally (in the current
|
|
|
|
# peripheral), we will (for some obscure and ancient reason)
|
|
|
|
# look in peripherals connected via point to point links
|
2015-04-10 10:59:51 +05:30
|
|
|
if { [string compare -nocase $local_value ""] == 0} {
|
2014-06-03 15:21:32 +05:30
|
|
|
set p2p_name [::hsm::utils::get_p2p_name $periph $arg]
|
2014-06-24 16:45:01 +05:30
|
|
|
if { [string compare -nocase $p2p_name ""] == 0} {
|
2014-06-03 15:21:32 +05:30
|
|
|
set arg_name [::hsm::utils::get_ip_param_name $periph $arg]
|
2014-06-24 16:45:01 +05:30
|
|
|
regsub "S_AXI_" $arg_name "" arg_name
|
|
|
|
puts -nonewline $config_file [format "%s\t\t%s" $comma $arg_name]
|
|
|
|
} else {
|
|
|
|
regsub "S_AXI_" $p2p_name "" p2p_name
|
|
|
|
puts -nonewline $config_file [format "%s\t\t%s" $comma $p2p_name]
|
|
|
|
}
|
|
|
|
} else {
|
2014-06-03 15:21:32 +05:30
|
|
|
set arg_name [::hsm::utils::get_ip_param_name $periph $arg]
|
2014-06-24 16:45:01 +05:30
|
|
|
regsub "S_AXI_" $arg_name "" arg_name
|
|
|
|
puts -nonewline $config_file [format "%s\t\t%s" $comma $arg_name]
|
|
|
|
}
|
|
|
|
} else {
|
2014-06-03 15:21:32 +05:30
|
|
|
set arg_name [::hsm::utils::get_driver_param_name $drv_string $arg]
|
2014-06-24 16:45:01 +05:30
|
|
|
regsub "S_AXI_" $arg_name "" arg_name
|
|
|
|
puts -nonewline $config_file [format "%s\t\t%s" $comma $arg_name]
|
|
|
|
}
|
|
|
|
set comma ",\n"
|
|
|
|
}
|
|
|
|
puts -nonewline $config_file "\n\t\}"
|
|
|
|
set start_comma ",\n"
|
|
|
|
}
|
|
|
|
puts $config_file "\n\};"
|
|
|
|
|
|
|
|
puts $config_file "\n";
|
|
|
|
|
|
|
|
close $config_file
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
2015-04-10 10:59:51 +05:30
|
|
|
# xdefine_canonical_xpars - Used to print out canonical defines for a driver.
|
2014-06-24 16:45:01 +05:30
|
|
|
# Given a list of arguments, define each as a canonical constant name, using
|
|
|
|
# the driver name, in an include file.
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
proc xdefine_canonical_xpars_zynq {drv_handle file_name drv_string args} {
|
|
|
|
# Open include file
|
2014-06-03 15:21:32 +05:30
|
|
|
set file_handle [::hsm::utils::open_include_file $file_name]
|
2014-06-24 16:45:01 +05:30
|
|
|
|
|
|
|
# Get all the peripherals connected to this driver
|
2014-06-03 15:21:32 +05:30
|
|
|
set periphs [::hsm::utils::get_common_driver_ips $drv_handle]
|
2014-06-24 16:45:01 +05:30
|
|
|
|
|
|
|
# Get the names of all the peripherals connected to this driver
|
|
|
|
foreach periph $periphs {
|
2015-04-10 10:59:51 +05:30
|
|
|
set peripheral_name [string toupper [common::get_property NAME $periph]]
|
2014-06-24 16:45:01 +05:30
|
|
|
lappend peripherals $peripheral_name
|
|
|
|
}
|
|
|
|
|
|
|
|
# Get possible canonical names for all the peripherals connected to this
|
|
|
|
# driver
|
|
|
|
set device_id 0
|
|
|
|
foreach periph $periphs {
|
|
|
|
set canonical_name [string toupper [format "%s_%s" $drv_string $device_id]]
|
|
|
|
lappend canonicals $canonical_name
|
2015-04-10 10:59:51 +05:30
|
|
|
|
2014-06-24 16:45:01 +05:30
|
|
|
# Create a list of IDs of the peripherals whose hardware instance name
|
|
|
|
# doesn't match the canonical name. These IDs can be used later to
|
|
|
|
# generate canonical definitions
|
|
|
|
if { [lsearch $peripherals $canonical_name] < 0 } {
|
|
|
|
lappend indices $device_id
|
|
|
|
}
|
|
|
|
incr device_id
|
|
|
|
}
|
|
|
|
|
|
|
|
set i 0
|
|
|
|
foreach periph $periphs {
|
2015-04-10 10:59:51 +05:30
|
|
|
set periph_name [string toupper [common::get_property NAME $periph]]
|
2014-06-24 16:45:01 +05:30
|
|
|
|
|
|
|
# Generate canonical definitions only for the peripherals whose
|
|
|
|
# canonical name is not the same as hardware instance name
|
|
|
|
if { [lsearch $canonicals $periph_name] < 0 } {
|
|
|
|
puts $file_handle "/* Canonical definitions for peripheral $periph_name */"
|
|
|
|
set canonical_name [format "%s_%s" $drv_string [lindex $indices $i]]
|
|
|
|
|
|
|
|
foreach arg $args {
|
2014-06-03 15:21:32 +05:30
|
|
|
set lvalue [::hsm::utils::get_driver_param_name $canonical_name $arg]
|
2014-06-24 16:45:01 +05:30
|
|
|
regsub "S_AXI_" $lvalue "" lvalue
|
|
|
|
|
|
|
|
# The commented out rvalue is the name of the instance-specific constant
|
2014-06-03 15:21:32 +05:30
|
|
|
# set rvalue [::hsm::utils::get_ip_param_name $periph $arg]
|
2014-06-24 16:45:01 +05:30
|
|
|
# The rvalue set below is the actual value of the parameter
|
2014-06-03 15:21:32 +05:30
|
|
|
set rvalue [::hsm::utils::get_param_value $periph $arg]
|
2014-06-24 16:45:01 +05:30
|
|
|
if {[llength $rvalue] == 0} {
|
|
|
|
set rvalue 0
|
|
|
|
}
|
2014-06-03 15:21:32 +05:30
|
|
|
set rvalue [::hsm::utils::format_addr_string $rvalue $arg]
|
2015-04-10 10:59:51 +05:30
|
|
|
|
2014-06-24 16:45:01 +05:30
|
|
|
puts $file_handle "#define $lvalue $rvalue"
|
|
|
|
|
|
|
|
}
|
|
|
|
puts $file_handle ""
|
|
|
|
incr i
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
puts $file_handle "\n/******************************************************************/\n"
|
|
|
|
close $file_handle
|
|
|
|
}
|