Skip to content

Commit 63e4278

Browse files
djepson1achaudhari
authored andcommitted
tools: Add option for using HDL blocks during TCL BD development
1 parent 4bc2c6f commit 63e4278

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
lines changed

usrp3/tools/make/viv_ip_builder.mak

+2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ BUILD_VIVADO_BD = \
7878
# $4 = BDTCL_SRC_DIR (Absolute path to the top level ip src dir)
7979
# $5 = BDTCL_BUILD_DIR (Absolute path to the top level ip build dir)
8080
# $6 = BD_IP_REPOS (space-separated list of absolute paths to IP repos)
81+
# $7 = BD_HDL_SRCS (space-separated list of absolute paths to HDL sources)
8182
# Prereqs:
8283
# - TOOLS_DIR must be defined globally
8384
# -------------------------------------------------------------------
@@ -89,6 +90,7 @@ BUILD_VIVADO_BDTCL = \
8990
export BD_FILE=$(call RESOLVE_PATH,$(5)/$(1)/$(1).tcl); \
9091
export PART_NAME=`python $(TOOLS_DIR)/scripts/viv_gen_part_id.py $(2)/$(3)`; \
9192
export BD_IP_REPOS=$(call RESOLVE_PATH,$(6)); \
93+
export BD_HDL_SRCS=$(call RESOLVE_PATHS,$(7)); \
9294
echo "BUILDER: Staging BD Tcl in build directory..."; \
9395
rm $(5)/$(1)/* -rf; \
9496
$(TOOLS_DIR)/scripts/shared-ip-loc-manage.sh --path=$(5)/$(1) reserve; \

usrp3/tools/scripts/viv_generate_bd.tcl

+27-6
Original file line numberDiff line numberDiff line change
@@ -14,34 +14,55 @@ if {[info exists env(BD_IP_REPOS)]} {
1414
} else {
1515
set ip_repos {}
1616
}
17+
if {[info exists env(BD_HDL_SRCS)]} {
18+
set hdl_sources $::env(BD_HDL_SRCS);# Any supporting HDL files
19+
} else {
20+
set hdl_sources {}
21+
}
1722

1823
# Delete any previous output cookie file
1924
file delete -force "$bd_file.out"
2025
# ---------------------------------------
2126
# Vivado Commands
2227
# ---------------------------------------
28+
create_project -part $part_name -in_memory
29+
# In non-project mode, the hierarchy must be updated for the HDL source files to be
30+
# correctly applied to the BD. See AR:
31+
# https://www.xilinx.com/support/answers/63488.html
32+
set_property source_mgmt_mode All [current_project]
33+
set_property ip_repo_paths "{$ip_repos}" [current_project]
34+
update_ip_catalog
35+
# Add supplementary HDL sources, if they exist.
36+
foreach src_file $hdl_sources {
37+
set hdl_ext [file extension $src_file ]
38+
if [expr [lsearch {.vhd .vhdl} $hdl_ext] >= 0] {
39+
puts "BUILDER: Adding VHDL : $src_file"
40+
read_vhdl -library work $src_file
41+
} elseif [expr [lsearch {.v .vh} $hdl_ext] >= 0] {
42+
puts "BUILDER: Adding Verilog : $src_file"
43+
read_verilog $src_file
44+
} else {
45+
puts "BUILDER: \[WARNING\] File ignored!!!: $src_file"
46+
}
47+
}
48+
# Open .tcl or .bd design directly.
2349
if [expr [lsearch {.tcl} $src_ext] >= 0] {
2450
puts "BUILDER: Generating Block Diagram from script: $bd_file"
25-
create_project -part $part_name -in_memory
26-
set_property ip_repo_paths "{$ip_repos}" [current_project]
27-
update_ip_catalog
2851
create_bd_design -dir . $bd_name
2952
source $bd_file
3053
report_ip_status
3154
puts "BUILDER: Report_ip_status done"
3255
set bd_file $bd_name.bd
3356
} else {
3457
puts "BUILDER: Adding Block Diagram: $bd_file"
35-
create_project -part $part_name -in_memory
36-
set_property ip_repo_paths "{$ip_repos}" [current_project]
37-
update_ip_catalog
3858
add_files -norecurse $bd_file
3959
puts "BUILDER: Generating BD Target first pass..."
4060
generate_target all [get_files $bd_file] -force
4161
report_ip_status
4262
puts "BUILDER: Report_ip_status done"
4363
open_bd_design $bd_file
4464
}
65+
# Generate outputs.
4566
puts "BUILDER: Generating BD Target..."
4667
generate_target all [get_files $bd_file]
4768
puts "BUILDER: Generate all done"

usrp3/tools/scripts/viv_ip_utils.tcl

+7
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ if { [string compare $cmd "create"] == 0 } {
7575
set src_rootname [file rootname [file tail $src_file]]
7676
set src_ext [file extension $src_file ]
7777
set ip_repos [lindex $argv 3]
78+
set hdl_sources "[file dirname $src_file]/hdl_sources.tcl"
7879
if [expr [lsearch {.tcl} $src_ext] >= 0] {
7980
# Create a temporary project to work on.
8081
set tmp_bddir "${sys_tmpdir}/.viv_${src_rootname}"
@@ -84,6 +85,12 @@ if { [string compare $cmd "create"] == 0 } {
8485
create_project tmp_bd $tmp_bddir -part $part_name -force
8586
set_property ip_repo_paths "{$ip_repos}" [current_project]
8687
update_ip_catalog
88+
# Add any supporting HDL first
89+
if {[file exists $hdl_sources] == 1} {
90+
source $hdl_sources
91+
} else {
92+
puts "hdl_sources.tcl not found in IP directory. Skipping HDL import for BD design"
93+
}
8794
# Recreate BD design from source file (.tcl)
8895
source $src_file
8996
regenerate_bd_layout

0 commit comments

Comments
 (0)