From 99412a503e2123d49cd551c88f0ad7380a4ea1fc Mon Sep 17 00:00:00 2001 From: AndreiGrozav Date: Thu, 14 Mar 2019 15:50:21 +0200 Subject: [PATCH] library/scripts/*xilinx*: Auto-generate bd.tcl Having a bd.tcl script in every IP is redundant. adi_ip.tcl: - add adi_init_bd_tcl - creates a blanch bd.tcl and a parameters temporary_case_dependencies.mk when compiling an IP. Its main purpose is to generate the bd.tcl, which will be included in the IP's file-set. - adi_auto_fill_bd_tcl will populate the empty bd.tcl based on the top IP parameters and the presence of these parameters in auto_set_param_list and auto_set_param_list_overwritable lists. This task can not be performed by the first described procedure since the file-set is not yet defined. adi_xilinx_device_info_enc.tcl: Split auto_set_param_list_overwritable from auto_set_param_list. As the name states, some of the parameters are overwritable, this will help when generating the bd.tcl script. library.mk: Include the temporary_case_dependencies.mk if it exists in the IP root folder. The mentioned *.mk file contains non generic dependencies for makefiles like targets to clean. --- library/scripts/adi_ip.tcl | 104 ++++++++++++++++++ .../scripts/adi_xilinx_device_info_enc.tcl | 10 +- library/scripts/library.mk | 7 +- 3 files changed, 116 insertions(+), 5 deletions(-) diff --git a/library/scripts/adi_ip.tcl b/library/scripts/adi_ip.tcl index d5dd719ae..d1bd1afab 100644 --- a/library/scripts/adi_ip.tcl +++ b/library/scripts/adi_ip.tcl @@ -310,9 +310,108 @@ proc adi_ip_properties {ip_name} { ipx::save_core } +# ############################################################################## +# create/overwrite temporary files containing particular build case dependencies +# DO NOT USE FOR: +# - axi_dmac +# - jesd204 +# - axi_clkgen +proc adi_init_bd_tcl {} { + + if { [file exists bd] } { + file delete -force bd + } + file mkdir bd + set bd_tcl [open "bd/bd.tcl" w] + puts $bd_tcl "" + close $bd_tcl + + set local_mk [open "temporary_case_dependencies.mk" w] + seek $local_mk 0 start + puts $local_mk "CLEAN_TARGET += bd" + puts $local_mk "CLEAN_TARGET += temporary_case_dependencies.mk" + close $local_mk +} + +proc adi_auto_fill_bd_tcl {} { + + global auto_set_param_list + global auto_set_param_list_overwritable + set cc [ipx::current_core] + + set bd_tcl [open "bd/bd.tcl" r+ ] + + puts $bd_tcl "# SCRIPT AUTO-GENERATED AT BUILD, DO NOT MODIFY!" + puts $bd_tcl "proc init {cellpath otherInfo} {" + puts $bd_tcl " set ip \[get_bd_cells \$cellpath\]" + puts $bd_tcl "" + set auto_set_param "" + foreach i $auto_set_param_list { + if { [ipx::get_user_parameters $i -of_objects $cc -quiet] ne "" } { + append auto_set_param " $i \\\n" + } + } + if { $auto_set_param ne "" } { + puts $bd_tcl " bd::mark_propagate_only \$ip \" \\" + regsub "${i} \\\\" $auto_set_param "$i\"" auto_set_param + puts $bd_tcl $auto_set_param + } + + set auto_set_overwritable_param "" + foreach i $auto_set_param_list_overwritable { + if { [ipx::get_user_parameters $i -of_objects $cc -quiet] ne "" } { + append auto_set_overwritable_param " $i \\\n" + } + } + if { $auto_set_overwritable_param ne "" } { + puts $bd_tcl " bd::mark_propagate_override \$ip \" \\" + regsub "${i} \\\\" $auto_set_overwritable_param "$i\"" auto_set_overwritable_param + puts $bd_tcl $auto_set_overwritable_param + } + puts $bd_tcl " adi_auto_assign_device_spec \$cellpath" + puts $bd_tcl "}" + puts $bd_tcl "" + puts $bd_tcl "# auto set parameters defined in auto_set_param_list (adi_xilinx_device_info_enc.tcl)" + puts $bd_tcl "proc adi_auto_assign_device_spec {cellpath} {" + puts $bd_tcl "" + puts $bd_tcl " set ip \[get_bd_cells \$cellpath\]" + puts $bd_tcl " set ip_param_list \[list_property \$ip\]" + puts $bd_tcl " set ip_path \[bd::get_vlnv_dir \[get_property VLNV \$ip\]\]" + puts $bd_tcl "" + puts $bd_tcl " set parent_dir \"../\"" + puts $bd_tcl " for {set x 1} {\$x<=4} {incr x} {" + puts $bd_tcl " set linkname \${ip_path}\${parent_dir}scripts/adi_xilinx_device_info_enc.tcl" + puts $bd_tcl " if { \[file exists \$linkname\] } {" + puts $bd_tcl " source \${ip_path}\${parent_dir}/scripts/adi_xilinx_device_info_enc.tcl" + puts $bd_tcl " break" + puts $bd_tcl " }" + puts $bd_tcl " append parent_dir \"../\"" + puts $bd_tcl " }" + puts $bd_tcl "" + puts $bd_tcl " # Find predefindes auto assignable parameters" + puts $bd_tcl " foreach i \$auto_set_param_list {" + puts $bd_tcl " if { \[lsearch \$ip_param_list \"CONFIG.\$i\"\] > 0 } {" + puts $bd_tcl " set val \[adi_device_spec \$cellpath \$i\]" + puts $bd_tcl " set_property CONFIG.\$i \$val \$ip" + puts $bd_tcl " }" + puts $bd_tcl " }" + puts $bd_tcl "" + puts $bd_tcl " # Find predefindes auto assignable/overwritable parameters" + puts $bd_tcl " foreach i \$auto_set_param_list_overwritable {" + puts $bd_tcl " if { \[lsearch \$ip_param_list \"CONFIG.\$i\"\] > 0 } {" + puts $bd_tcl " set val \[adi_device_spec \$cellpath \$i\]" + puts $bd_tcl " set_property CONFIG.\$i \$val \$ip" + puts $bd_tcl " }" + puts $bd_tcl " }" + puts $bd_tcl "}" + puts $bd_tcl "" + close $bd_tcl +} + proc adi_add_auto_fpga_spec_params {} { global auto_set_param_list + global auto_set_param_list_overwritable set cc [ipx::current_core] foreach i $auto_set_param_list { @@ -320,6 +419,11 @@ proc adi_add_auto_fpga_spec_params {} { adi_add_device_spec_param $i } } + foreach i $auto_set_param_list_overwritable { + if { [ipx::get_user_parameters $i -of_objects $cc -quiet] ne ""} { + adi_add_device_spec_param $i + } + } } proc adi_add_device_spec_param {ip_param} { diff --git a/library/scripts/adi_xilinx_device_info_enc.tcl b/library/scripts/adi_xilinx_device_info_enc.tcl index 8115a39b7..0e75b3055 100644 --- a/library/scripts/adi_xilinx_device_info_enc.tcl +++ b/library/scripts/adi_xilinx_device_info_enc.tcl @@ -36,6 +36,7 @@ # adi_xilinx_device_info_enc.tcl variable auto_set_param_list +variable auto_set_param_list_overwritable variable fpga_series_list variable fpga_family_list variable speed_grade_list @@ -44,14 +45,15 @@ variable xcvr_type_list variable fpga_voltage_list # Parameter list for automatic assignament -set auto_set_param_list { - FPGA_VOLTAGE \ - XCVR_TYPE \ +set auto_set_param_list { \ DEV_PACKAGE \ SPEED_GRADE \ FPGA_FAMILY \ - FPGA_TECHNOLOGY} + FPGA_TECHNOLOGY } +set auto_set_param_list_overwritable { \ + FPGA_VOLTAGE \ + XCVR_TYPE } # List for automatically assigned parameter values and encoded values # The list name must be the parameter name (lowercase), appending "_list" to it diff --git a/library/scripts/library.mk b/library/scripts/library.mk index e0a4b2701..978642f52 100644 --- a/library/scripts/library.mk +++ b/library/scripts/library.mk @@ -7,9 +7,14 @@ HDL_LIBRARY_PATH := $(subst scripts/library.mk,,$(lastword $(MAKEFILE_LIST))) include $(HDL_LIBRARY_PATH)../quiet.mk +CASE_INCLUDE := $(wildcard temporary_case_dependencies.mk) +ifneq ($(CASE_INCLUDE),) + include temporary_case_dependencies.mk +endif + VIVADO := vivado -mode batch -source -CLEAN_TARGET := *.cache +CLEAN_TARGET += *.cache CLEAN_TARGET += *.data CLEAN_TARGET += *.xpr CLEAN_TARGET += *.log