From f6fbadbd3c5ae219dbcd9bde41385cecc59daa3c Mon Sep 17 00:00:00 2001 From: Kareem Farid Date: Wed, 22 Jan 2025 14:28:52 +0200 Subject: [PATCH] feat: post-drt antenna repair (#573) ## Steps * `OpenROAD.DetailedRouting` * Added `DRT_SAVE_SNAPSHOTS` which enables saving snapshots of the layout each detalied routing iteration. * Added `DRT_ANTENNA_REPAIR_ITERS`, which if greater than zero, enables antenna fixing after detailed routing * Added `DRT_ANTENNA_MARGIN` which is similar to `GRT_ANTENNA_MARGIN` but for the aforementioned antenna repair iterations --------- Signed-off-by: Kareem Farid Co-authored-by: Mohamed Gaber --- Changelog.md | 4 ++ openlane/scripts/openroad/common/io.tcl | 2 +- openlane/scripts/openroad/drt.tcl | 50 +++++++++++++++++++++---- openlane/steps/openroad.py | 13 +++++++ openlane/steps/step.py | 9 +++-- pyproject.toml | 2 +- test/designs | 2 +- 7 files changed, 68 insertions(+), 14 deletions(-) diff --git a/Changelog.md b/Changelog.md index a81ae960..8a1dab18 100644 --- a/Changelog.md +++ b/Changelog.md @@ -55,6 +55,10 @@ * Added `DRT_SAVE_SNAPSHOTS` which enables saving snapshots of the layout each detalied routing iteration. * Added `DRT_SAVE_DRC_REPORT_ITERS` + * Added `DRT_ANTENNA_REPAIR_ITERS`, which if greater than zero, enables + antenna fixing after detailed routing + * Added `DRT_ANTENNA_MARGIN` which is similar to `GRT_ANTENNA_MARGIN` but for + the aforementioned antenna repair iterations * `OpenROAD.GlobalPlacement` diff --git a/openlane/scripts/openroad/common/io.tcl b/openlane/scripts/openroad/common/io.tcl index 6f37c5ea..f6e31cd9 100644 --- a/openlane/scripts/openroad/common/io.tcl +++ b/openlane/scripts/openroad/common/io.tcl @@ -614,5 +614,5 @@ proc append_if_not_flag {list_arg glob_variable_name flag} { # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. proc log_cmd {cmd args} { puts "+ $cmd [join $args " "]" - $cmd {*}$args + return [$cmd {*}$args] } diff --git a/openlane/scripts/openroad/drt.tcl b/openlane/scripts/openroad/drt.tcl index 61b9c8d8..e25988f8 100755 --- a/openlane/scripts/openroad/drt.tcl +++ b/openlane/scripts/openroad/drt.tcl @@ -11,6 +11,22 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +proc drt_run {i args} { + set directory "drt-run-${i}" + file mkdir "$::env(STEP_DIR)/$directory" + set output_drc "-output_drc $::env(STEP_DIR)/$directory/$::env(DESIGN_NAME).drc" + log_cmd detailed_route {*}$args {*}$output_drc + if { $::env(DRT_SAVE_SNAPSHOTS) } { + foreach snapshot [glob -nocomplain drt_iter*.odb] { + file rename -force $snapshot $directory/[file tail $snapshot] + } + } + foreach drc_file [glob -nocomplain $::env(STEP_DIR)/$directory/*.drc] { + file copy -force $drc_file $::env(STEP_DIR)/[file tail $drc_file] + } + write_db $::env(STEP_DIR)/$directory/$::env(DESIGN_NAME).odb +} + source $::env(SCRIPTS_DIR)/openroad/common/io.tcl read_current_odb @@ -36,13 +52,31 @@ if { $::env(DRT_SAVE_SNAPSHOTS) } { if { [info exists ::env(DRT_SAVE_DRC_REPORT_ITERS)] } { set drc_report_iter_step_arg "-drc_report_iter_step $::env(DRT_SAVE_DRC_REPORT_ITERS)" } -log_cmd detailed_route\ - -bottom_routing_layer $min_layer\ - -top_routing_layer $max_layer\ - -output_drc $::env(STEP_DIR)/$::env(DESIGN_NAME).drc\ - -droute_end_iter $::env(DRT_OPT_ITERS)\ - -or_seed 42\ - -verbose 1\ - {*}$drc_report_iter_step_arg +set i 0 + +set drt_args [list] +lappend drt_args -bottom_routing_layer $min_layer +lappend drt_args -top_routing_layer $max_layer +lappend drt_args -droute_end_iter $::env(DRT_OPT_ITERS) +lappend drt_args -or_seed 42 +lappend drt_args -verbose 1 +lappend drt_args {*}$drc_report_iter_step_arg +drt_run $i {*}$drt_args + +incr i + +set diode_cell [lindex [split $::env(DIODE_CELL) "/"] 0] + +while {$i <= $::env(DRT_ANTENNA_REPAIR_ITERS) && [log_cmd check_antennas]} { + puts "\[INFO\] Running antenna repair iteration $i…" + set diodes_inserted [log_cmd repair_antennas $diode_cell -ratio_margin $::env(DRT_ANTENNA_MARGIN)] + if {$diodes_inserted} { + drt_run $i {*}$drt_args + } else { + puts "\[INFO\] No diodes inserted. Ending antenna repair iterations." + break + } + incr i +} write_views diff --git a/openlane/steps/openroad.py b/openlane/steps/openroad.py index 900f526f..f5e1ec73 100644 --- a/openlane/steps/openroad.py +++ b/openlane/steps/openroad.py @@ -1651,6 +1651,19 @@ class DetailedRouting(OpenROADStep): "This is an experimental variable. Saves an odb snapshot of the layout each routing iteration. This generates multiple odb files increasing disk usage.", default=False, ), + Variable( + "DRT_ANTENNA_REPAIR_ITERS", + int, + "The maximum number of iterations to run antenna repair. Set to a positive integer to attempt to repair antennas and then re-run DRT as appropriate.", + default=0, + ), + Variable( + "DRT_ANTENNA_MARGIN", + int, + "The margin to over fix antenna violations.", + default=10, + units="%", + ), Variable( "DRT_SAVE_DRC_REPORT_ITERS", Optional[int], diff --git a/openlane/steps/step.py b/openlane/steps/step.py index 03f247a1..acde7cee 100644 --- a/openlane/steps/step.py +++ b/openlane/steps/step.py @@ -1315,9 +1315,12 @@ def run_subprocess( link_start = f"[link=file://{os.path.abspath(log_path)}]" link_end = "[/link]" - verbose( - f"Logging subprocess to [repr.filename]{link_start}'{os.path.relpath(log_path)}'{link_end}[/repr.filename]…" - ) + msg = f"Logging subprocess to [repr.filename]{link_start}'{os.path.relpath(log_path)}'{link_end}[/repr.filename]…" + if logging.options.get_condensed_mode(): + info(msg) + else: + verbose(msg) + process = _popen_callable( cmd_str, encoding="utf8", diff --git a/pyproject.toml b/pyproject.toml index 14bb3688..48640091 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "openlane" -version = "3.0.0.dev9" +version = "3.0.0.dev10" description = "An infrastructure for implementing chip design flows" authors = ["Efabless Corporation and Contributors "] readme = "Readme.md" diff --git a/test/designs b/test/designs index 119d5cc0..59bfd4ac 160000 --- a/test/designs +++ b/test/designs @@ -1 +1 @@ -Subproject commit 119d5cc03c62eab906b984c09931433c15743e66 +Subproject commit 59bfd4ac55ef15bf7d5e6c61f2102e046f2f89cc