Skip to content

Commit ba373d6

Browse files
committed
fix timing issues on fmcomms2 and ad9081 vcu118
- implemented scripts/auto_timing_fix.tcl - improvements to projects/scripts/adi_project_xilinx.tcl - added ADI_MAX_THREADS so the trade-off between speed and RAM usage can be adjusted - added post place and route script flag - added documentation for other flags - fixed timing issues in fmcomms2 with 2025.1 toolchain without hdl changes - project presented hold timing violations on vivado 2025.1 - "phys_opt_design -hold_fix" resolved it for most variations but not for all of them - changed implementation strategy to spread placement on board to make hold timing easier to resolve - now all projects finish successfully after the auto fix script runs - no HDL changes were made - fixed timing for ad9081 on vcu118 - presented setup timing violations - use of "spread high" strategy solved issues without need of ATF Signed-off-by: Pedro Mendonca <Pedro.Mendonca@analog.com>
1 parent 60ac978 commit ba373d6

File tree

8 files changed

+165
-26
lines changed

8 files changed

+165
-26
lines changed

projects/ad9081_fmca_ebz/vcu118/system_project.tcl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
source ../../../scripts/adi_env.tcl
77
source $ad_hdl_dir/projects/scripts/adi_project_xilinx.tcl
88
source $ad_hdl_dir/projects/scripts/adi_board.tcl
9+
set ADI_POST_ROUTE_SCRIPT [file normalize $ad_hdl_dir/scripts/auto_timing_fix.tcl]
910

1011
# get_env_param retrieves parameter value from the environment if exists,
1112
# other case use the default value
@@ -95,4 +96,6 @@ if {$ADI_USE_OOC_SYNTHESIS == 1} {
9596
set_property used_in_synthesis false [get_files timing_constr.xdc]
9697
}
9798

99+
set_property strategy Congestion_SpreadLogic_high [get_runs impl_1]
100+
98101
adi_project_run ad9081_fmca_ebz_vcu118

projects/fmcomms2/kcu105/system_project.tcl

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,20 @@
66
source ../../../scripts/adi_env.tcl
77
source $ad_hdl_dir/projects/scripts/adi_project_xilinx.tcl
88
source $ad_hdl_dir/projects/scripts/adi_board.tcl
9+
set ADI_POST_ROUTE_SCRIPT [file normalize $ad_hdl_dir/scripts/auto_timing_fix.tcl]
10+
set BOARD_NAME kcu105
911

10-
adi_project fmcomms2_kcu105
11-
adi_project_files fmcomms2_kcu105 [list \
12+
adi_project fmcomms2_${BOARD_NAME}
13+
adi_project_files fmcomms2_${BOARD_NAME} [list \
1214
"system_top.v" \
1315
"system_constr.xdc"\
1416
"$ad_hdl_dir/library/common/ad_iobuf.v" \
15-
"$ad_hdl_dir/projects/common/kcu105/kcu105_system_constr.xdc" \
16-
"$ad_hdl_dir/projects/common/kcu105/kcu105_system_lutram_constr.xdc" ]
17+
"$ad_hdl_dir/projects/common/${BOARD_NAME}/${BOARD_NAME}_system_constr.xdc" \
18+
"$ad_hdl_dir/projects/common/${BOARD_NAME}/${BOARD_NAME}_system_lutram_constr.xdc" ]
1719

18-
## To improve timing in DDR4 MIG
19-
set_property strategy Performance_RefinePlacement [get_runs impl_1]
20-
set_property STEPS.PHYS_OPT_DESIGN.ARGS.DIRECTIVE ExploreWithAggressiveHoldFix [get_runs impl_1]
20+
## fmcomms2 design is presenting hold time violations on some paths
21+
## set the strategy to spread logic and help with hold time fixes
22+
set_property strategy Congestion_SpreadLogic_high [get_runs impl_1]
2123

22-
adi_project_run fmcomms2_kcu105
24+
adi_project_run fmcomms2_${BOARD_NAME}
2325
source $ad_hdl_dir/library/axi_ad9361/axi_ad9361_delay.tcl

projects/fmcomms2/zc702/system_project.tcl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,20 @@
66
source ../../../scripts/adi_env.tcl
77
source $ad_hdl_dir/projects/scripts/adi_project_xilinx.tcl
88
source $ad_hdl_dir/projects/scripts/adi_board.tcl
9+
set ADI_POST_ROUTE_SCRIPT [file normalize $ad_hdl_dir/scripts/auto_timing_fix.tcl]
10+
set BOARD_NAME zc702
911

10-
adi_project fmcomms2_zc702
11-
adi_project_files fmcomms2_zc702 [list \
12+
adi_project fmcomms2_${BOARD_NAME}
13+
adi_project_files fmcomms2_${BOARD_NAME} [list \
1214
"system_top.v" \
1315
"system_constr.xdc" \
1416
"$ad_hdl_dir/library/common/ad_iobuf.v" \
15-
"$ad_hdl_dir/projects/common/zc702/zc702_system_constr.xdc" ]
17+
"$ad_hdl_dir/projects/common/${BOARD_NAME}/${BOARD_NAME}_system_constr.xdc" ]
1618

17-
set_property strategy Performance_Explore [get_runs impl_1]
19+
## fmcomms2 design is presenting hold time violations on some paths
20+
## set the strategy to spread logic and help with hold time fixes
21+
set_property strategy Congestion_SpreadLogic_high [get_runs impl_1]
1822

19-
adi_project_run fmcomms2_zc702
23+
adi_project_run fmcomms2_${BOARD_NAME}
2024
source $ad_hdl_dir/library/axi_ad9361/axi_ad9361_delay.tcl
2125

projects/fmcomms2/zc706/system_project.tcl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,20 @@
66
source ../../../scripts/adi_env.tcl
77
source $ad_hdl_dir/projects/scripts/adi_project_xilinx.tcl
88
source $ad_hdl_dir/projects/scripts/adi_board.tcl
9+
set ADI_POST_ROUTE_SCRIPT [file normalize $ad_hdl_dir/scripts/auto_timing_fix.tcl]
10+
set BOARD_NAME zc706
911

10-
adi_project fmcomms2_zc706
11-
adi_project_files fmcomms2_zc706 [list \
12+
adi_project fmcomms2_${BOARD_NAME}
13+
adi_project_files fmcomms2_${BOARD_NAME} [list \
1214
"system_top.v" \
1315
"system_constr.xdc"\
1416
"$ad_hdl_dir/library/common/ad_iobuf.v" \
15-
"$ad_hdl_dir/projects/common/zc706/zc706_system_constr.xdc" ]
17+
"$ad_hdl_dir/projects/common/${BOARD_NAME}/${BOARD_NAME}_system_constr.xdc" ]
1618

17-
adi_project_run fmcomms2_zc706
19+
## fmcomms2 design is presenting hold time violations on some paths
20+
## set the strategy to spread logic and help with hold time fixes
21+
set_property strategy Congestion_SpreadLogic_high [get_runs impl_1]
22+
23+
adi_project_run fmcomms2_${BOARD_NAME}
1824
source $ad_hdl_dir/library/axi_ad9361/axi_ad9361_delay.tcl
1925

projects/fmcomms2/zcu102/system_project.tcl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,20 @@
66
source ../../../scripts/adi_env.tcl
77
source $ad_hdl_dir/projects/scripts/adi_project_xilinx.tcl
88
source $ad_hdl_dir/projects/scripts/adi_board.tcl
9+
set ADI_POST_ROUTE_SCRIPT [file normalize $ad_hdl_dir/scripts/auto_timing_fix.tcl]
10+
set BOARD_NAME zcu102
911

10-
adi_project fmcomms2_zcu102
11-
adi_project_files fmcomms2_zcu102 [list \
12+
adi_project fmcomms2_${BOARD_NAME}
13+
adi_project_files fmcomms2_${BOARD_NAME} [list \
1214
"system_top.v" \
1315
"system_constr.xdc"\
1416
"$ad_hdl_dir/library/common/ad_iobuf.v" \
15-
"$ad_hdl_dir/projects/common/zcu102/zcu102_system_constr.xdc" ]
17+
"$ad_hdl_dir/projects/common/${BOARD_NAME}/${BOARD_NAME}_system_constr.xdc" ]
1618

17-
adi_project_run fmcomms2_zcu102
19+
## fmcomms2 design is presenting hold time violations on some paths
20+
## set the strategy to spread logic and help with hold time fixes
21+
set_property strategy Congestion_SpreadLogic_high [get_runs impl_1]
22+
23+
adi_project_run fmcomms2_${BOARD_NAME}
1824
source $ad_hdl_dir/library/axi_ad9361/axi_ad9361_delay.tcl
1925

projects/fmcomms2/zed/system_project.tcl

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,19 @@
66
source ../../../scripts/adi_env.tcl
77
source $ad_hdl_dir/projects/scripts/adi_project_xilinx.tcl
88
source $ad_hdl_dir/projects/scripts/adi_board.tcl
9+
set ADI_POST_ROUTE_SCRIPT [file normalize $ad_hdl_dir/scripts/auto_timing_fix.tcl]
10+
set BOARD_NAME zed
911

10-
adi_project fmcomms2_zed
11-
adi_project_files fmcomms2_zed [list \
12+
adi_project fmcomms2_${BOARD_NAME}
13+
adi_project_files fmcomms2_${BOARD_NAME} [list \
1214
"system_top.v" \
1315
"system_constr.xdc"\
1416
"$ad_hdl_dir/library/common/ad_iobuf.v" \
15-
"$ad_hdl_dir/projects/common/zed/zed_system_constr.xdc" ]
17+
"$ad_hdl_dir/projects/common/${BOARD_NAME}/${BOARD_NAME}_system_constr.xdc" ]
1618

17-
adi_project_run fmcomms2_zed
18-
source $ad_hdl_dir/library/axi_ad9361/axi_ad9361_delay.tcl
19+
## fmcomms2 design is presenting hold time violations on some paths
20+
## set the strategy to spread logic and help with hold time fixes
21+
set_property strategy Congestion_SpreadLogic_high [get_runs impl_1]
1922

23+
adi_project_run fmcomms2_${BOARD_NAME}
24+
source $ad_hdl_dir/library/axi_ad9361/axi_ad9361_delay.tcl

projects/scripts/adi_project_xilinx.tcl

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ proc adi_project_create {project_name mode parameter_list device {board "not-app
324324
# \param[project_files] - list of project files
325325
#
326326
proc adi_project_files {project_name project_files} {
327+
global ADI_POST_ROUTE_SCRIPT
327328

328329
foreach pfile $project_files {
329330
if {[string range $pfile [expr 1 + [string last . $pfile]] end] == "xdc"} {
@@ -335,6 +336,10 @@ proc adi_project_files {project_name project_files} {
335336
}
336337
}
337338

339+
if {[info exists ADI_POST_ROUTE_SCRIPT]} {
340+
add_files -fileset utils_1 -norecurse ${ADI_POST_ROUTE_SCRIPT}
341+
}
342+
338343
# NOTE: top file name is always system_top
339344
set_property top system_top [current_fileset]
340345
}
@@ -343,6 +348,31 @@ proc adi_project_files {project_name project_files} {
343348
#
344349
# \param[project_name] - name of the project
345350
#
351+
# Additional configuration flags are:
352+
# - ADI_EXTRACT_PORTS - If set, extracts port properties from a predefined list
353+
# of IPs into 'ports_properties.txt'.
354+
# - ADI_GENERATE_BIN - If set, generates a binary bitstream file (.bin)
355+
# in addition to the .xsa hardware platform.
356+
# - ADI_GENERATE_UTILIZATION - If set, generates CSV and log files detailing
357+
# resource utilization for the design and specific IPs.
358+
# - ADI_GENERATE_XPA - If set, runs a Xilinx Power Analysis (XPA) and generates
359+
# a summary report.
360+
# - ADI_MAX_OOC_JOBS - Specifies the number of parallel jobs to use for
361+
# Out-of-Context (OOC) synthesis.
362+
# - ADI_MAX_THREADS - Specifies the maximum number of threads for Vivado
363+
# operations. Default value is 8.
364+
# - ADI_NO_BITSTREAM_COMPRESSION - If set, disables compression of the final
365+
# bitstream file.
366+
# - ADI_POST_ROUTE_SCRIPT - Specifies the path to a Tcl script to be executed
367+
# after the routing design step.
368+
# - ADI_POWER_OPTIMIZATION - If set to 1, enables power optimization during the
369+
# implementation run.
370+
# - ADI_PROJECT_DIR - Specifies a base directory for output files such as logs
371+
# and reports.
372+
# - ADI_SKIP_SYNTHESIS - If set, the entire procedure will exit before starting
373+
# synthesis.
374+
# - ADI_USE_OOC_SYNTHESIS - If set to 1, launches synthesis for OOC IP modules
375+
# in parallel.
346376
proc adi_project_run {project_name} {
347377

348378
global ad_project_dir
@@ -351,6 +381,12 @@ proc adi_project_run {project_name} {
351381
global ADI_USE_OOC_SYNTHESIS
352382
global ADI_MAX_OOC_JOBS
353383
global ADI_GENERATE_BIN
384+
global ADI_POST_ROUTE_SCRIPT
385+
386+
if {[info exists ::env(ADI_MAX_THREADS)]} {
387+
set_param general.maxThreads ${::env(ADI_MAX_THREADS)}
388+
puts "INFO: maxThreads set to ${::env(ADI_MAX_THREADS)}"
389+
}
354390

355391
if {![info exists ::env(ADI_PROJECT_DIR)]} {
356392
set actual_project_name $project_name
@@ -384,6 +420,10 @@ proc adi_project_run {project_name} {
384420

385421
set_param board.repoPaths [get_property LOCAL_ROOT_DIR [xhub::get_xstores xilinx_board_store]]
386422

423+
if {[info exists ADI_POST_ROUTE_SCRIPT]} {
424+
set_property STEPS.ROUTE_DESIGN.TCL.POST [ get_files ${ADI_POST_ROUTE_SCRIPT} -of [get_fileset utils_1] ] [get_runs impl_1]
425+
}
426+
387427
launch_runs impl_1 -to_step write_bitstream
388428
wait_on_run impl_1
389429
open_run impl_1

scripts/auto_timing_fix.tcl

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# This script attempts to automatically fix timing violations after routing
2+
# using phys_opt_design. It will make multiple attempts up to a maximum number
3+
# of tries, or until no violations remain. It can be configured via the
4+
# ADI_AUTOFIX_WNS_THRESHOLD and ADI_AUTOFIX_MAX_ATTEMPTS environment variables.
5+
#
6+
# ADI_AUTOFIX_WNS_THRESHOLD limits the worst negative slack (WNS) that will be
7+
# automatically fixed. If the WNS is worse than this threshold, no automatic fix
8+
# will be attempted.
9+
#
10+
puts "INFO: starting auto timing fix (ATF)..."
11+
set attempt 0
12+
13+
# Set default values if not provided
14+
if {![info exists ADI_AUTOFIX_WNS_THRESHOLD]} {
15+
set ADI_AUTOFIX_WNS_THRESHOLD -1.0
16+
puts "INFO: ATF: ADI_AUTOFIX_WNS_THRESHOLD not set, using default of $ADI_AUTOFIX_WNS_THRESHOLD"
17+
}
18+
if {![info exists ADI_AUTOFIX_MAX_ATTEMPTS]} {
19+
set ADI_AUTOFIX_MAX_ATTEMPTS 5
20+
puts "INFO: ATF: ADI_AUTOFIX_MAX_ATTEMPTS not set, using default of $ADI_AUTOFIX_MAX_ATTEMPTS"
21+
}
22+
23+
while {$attempt < $ADI_AUTOFIX_MAX_ATTEMPTS} {
24+
# Get the single worst timing path object in the design
25+
set worst_path [get_timing_paths -nworst 1 -max_paths 1 -delay_type min_max]
26+
if {[llength $worst_path] == 0} { break } ; # No paths found
27+
set wns [get_property SLACK $worst_path]
28+
if {${wns} >= 0.0} { break } ; # No violations remain
29+
set delay_type [get_property DELAY_TYPE $worst_path] ;# Returns "max" for Setup, "min" for Hold
30+
# Check if autofix should attempt based on WNS threshold
31+
if {$wns > $ADI_AUTOFIX_WNS_THRESHOLD} {
32+
incr attempt
33+
puts "INFO: ATF: WNS = ${wns} ns of type $delay_type. Attempting automatic fix (${attempt} of ${ADI_AUTOFIX_MAX_ATTEMPTS})."
34+
report_timing_summary -delay_type min_max -max_paths 5 -nworst 1 -file "AutoTimingFix_${attempt}_before_timing_summary.txt"
35+
} else {
36+
break ; # Abort automatic fix due to WNS threshold
37+
}
38+
# Attempt fix via phys_opt_design
39+
write_checkpoint -force "AutoTimingFix_${attempt}_before_system_top_placed.dcp"
40+
if {$delay_type eq "min"} {
41+
phys_opt_design -hold_fix
42+
} elseif {$delay_type eq "max"} {
43+
phys_opt_design
44+
} else {
45+
puts "ERROR: ATF: Unknown path type '${delay_type}'. Aborting automatic fix."
46+
break
47+
}
48+
}
49+
50+
write_checkpoint -force "AutoTimingFix_${attempt}_final_system_top_placed.dcp"
51+
report_timing_summary -delay_type min_max -max_paths 5 -nworst 1 -file "AutoTimingFix_${attempt}_final_timing_summary.txt"
52+
53+
# Print a final report
54+
if {[llength $worst_path] == 0} {
55+
# Loop broke early due to no paths found
56+
puts "ERROR: ATF: No constrained timing paths found. Exiting."
57+
} elseif {${attempt} == 0 && ${wns} >= 0.0} {
58+
# Loop broke early due to no violations on first check
59+
puts "INFO: ATF: No timing violations detected on first check. No action required."
60+
} else {
61+
# Loop broke after at least one attempt
62+
set worst_path [get_timing_paths -nworst 1 -max_paths 1 -delay_type min_max]
63+
set final_wns [get_property SLACK $worst_path]
64+
if {$final_wns >= 0} {
65+
puts "INFO: ATF: auto timing fix SUCCESS after ${attempt} attempts - final WNS is ${final_wns} ns."
66+
} elseif {$final_wns <= $ADI_AUTOFIX_WNS_THRESHOLD} {
67+
puts "WARNING: ATF: WNS (${wns} ns) excedes threshold (${ADI_AUTOFIX_WNS_THRESHOLD} ns). Automatic fix aborted."
68+
} else {
69+
puts "WARNING: ATF: auto timing fix FAILURE after ${attempt} attempts - final WNS is ${final_wns} ns."
70+
}
71+
}
72+
73+
puts "INFO: auto timing fix (ATF) finished."

0 commit comments

Comments
 (0)