Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: openroad hierarchical macro placer #537

Draft
wants to merge 15 commits into
base: dev
Choose a base branch
from
2 changes: 1 addition & 1 deletion openlane/config/preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def evaluate(expression: str, symbols: Mapping[str, Any]) -> Decimal:
eval_stack.pop()
eval_stack.pop()

result = Decimal(0.0)
result = Decimal("0")
if token.value == "**":
result = number1**number2
elif token.value == "*":
Expand Down
10 changes: 6 additions & 4 deletions openlane/flows/classic.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,19 @@ class Classic(SequentialFlow):
OpenROAD.Floorplan,
Odb.CheckMacroAntennaProperties,
Odb.SetPowerConnections,
OpenROAD.GlobalPlacementSkipIO,
OpenROAD.IOPlacement,
OpenROAD.UnplaceAll,
Odb.CustomIOPlacement,
Odb.ApplyDEFTemplate,
Odb.ManualMacroPlacement,
OpenROAD.HierarchicalMacroPlacer,
OpenROAD.CutRows,
OpenROAD.TapEndcapInsertion,
Odb.AddPDNObstructions,
OpenROAD.GeneratePDN,
Odb.RemovePDNObstructions,
Odb.AddRoutingObstructions,
OpenROAD.GlobalPlacementSkipIO,
OpenROAD.IOPlacement,
Odb.CustomIOPlacement,
Odb.ApplyDEFTemplate,
OpenROAD.GlobalPlacement,
Odb.WriteVerilogHeader,
Checker.PowerGridViolations,
Expand Down
10 changes: 5 additions & 5 deletions openlane/flows/sequential.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,6 @@ def resolve_step(matchable: Optional[str], multiple_ok: bool = False):

if to_resolved and to_resolved == step.id:
executing = False
if len(deferred_errors) != 0:
raise FlowError(
"One or more deferred errors were encountered:\n"
+ "\n".join(deferred_errors)
)

assert self.run_dir is not None
debug(f"Run concluded ▶ '{self.run_dir}'")
Expand All @@ -347,5 +342,10 @@ def resolve_step(matchable: Optional[str], multiple_ok: bool = False):
current_state.save_snapshot(final_views_path)
except Exception as e:
raise FlowException(f"Failed to save final views: {e}")
if len(deferred_errors) != 0:
raise FlowError(
"One or more deferred errors were encountered:\n"
+ "\n".join(deferred_errors)
)
success("Flow complete.")
return (current_state, step_list)
87 changes: 48 additions & 39 deletions openlane/flows/synth_explore.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,53 +79,62 @@ def run(

options.set_condensed_mode(True)

for strategy in [
"AREA 0",
"AREA 1",
"AREA 2",
"AREA 3",
"DELAY 0",
"DELAY 1",
"DELAY 2",
"DELAY 3",
"DELAY 4",
]:
config = self.config.copy(SYNTH_STRATEGY=strategy)

synth_step = Yosys.Synthesis(
config,
id=f"synthesis-{strategy}",
state_in=initial_state,
)
synth_future = self.start_step_async(synth_step)
step_list.append(synth_step)

sdc_step = OpenROAD.CheckSDCFiles(
config,
id=f"sdc-{strategy}",
state_in=synth_future,
)
sdc_future = self.start_step_async(sdc_step)
step_list.append(sdc_step)
for nf in [True, False]:
for strategy in [
"AREA 0",
"AREA 1",
"AREA 2",
"AREA 3",
"DELAY 0",
"DELAY 1",
"DELAY 2",
"DELAY 3",
"DELAY 4",
]:
config = self.config.copy(
SYNTH_ABC_AREA_USE_NF=nf,
SYNTH_STRATEGY=strategy,
)

sta_step = OpenROAD.STAPrePNR(
config,
state_in=sdc_future,
id=f"sta-{strategy}",
)
synth_step = Yosys.Synthesis(
config,
id=f"synthesis-{strategy}"
+ ("-nf" if config["SYNTH_ABC_AREA_USE_NF"] else ""),
state_in=initial_state,
)
synth_future = self.start_step_async(synth_step)
step_list.append(synth_step)

sdc_step = OpenROAD.CheckSDCFiles(
config,
id=f"sdc-{strategy}"
+ ("-nf" if config["SYNTH_ABC_AREA_USE_NF"] else ""),
state_in=synth_future,
)
sdc_future = self.start_step_async(sdc_step)
step_list.append(sdc_step)

sta_step = OpenROAD.STAPrePNR(
config,
state_in=sdc_future,
id=f"sta-{strategy}"
+ ("-nf" if config["SYNTH_ABC_AREA_USE_NF"] else ""),
)

step_list.append(sta_step)
sta_future = self.start_step_async(sta_step)
step_list.append(sta_step)
sta_future = self.start_step_async(sta_step)

synth_futures.append((config, sta_future))
synth_futures.append((config, sta_future))

results: Dict[str, Optional[Tuple[Decimal, Decimal, Decimal, Decimal]]] = {}
for config, future in synth_futures:
strategy = config["SYNTH_STRATEGY"]
results[strategy] = None
header = config["SYNTH_STRATEGY"] + (
"-nf" if config["SYNTH_ABC_AREA_USE_NF"] else ""
)
results[header] = None
try:
state = future.result()
results[strategy] = (
results[header] = (
state.metrics["design__instance__count"],
state.metrics["design__instance__area"],
state.metrics["timing__setup__ws"],
Expand Down
2 changes: 1 addition & 1 deletion openlane/scripts/openroad/common/dpl.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ source $::env(SCRIPTS_DIR)/openroad/common/dpl_cell_pad.tcl

remove_fillers

detailed_placement\
log_cmd detailed_placement\
-max_displacement [subst { $::env(PL_MAX_DISPLACEMENT_X) $::env(PL_MAX_DISPLACEMENT_Y) }]

if { [info exists ::env(PL_OPTIMIZE_MIRRORING)] && $::env(PL_OPTIMIZE_MIRRORING) } {
Expand Down
6 changes: 3 additions & 3 deletions openlane/scripts/openroad/common/grt.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ lappend arg_list -verbose
if { $::env(GRT_ALLOW_CONGESTION) == 1 } {
lappend arg_list -allow_congestion
}
puts $arg_list
global_route {*}$arg_list

write_guide $::env(STEP_DIR)/after_grt.guide
log_cmd global_route {*}$arg_list

write_guide $::env(STEP_DIR)/after_grt.guide
64 changes: 64 additions & 0 deletions openlane/scripts/openroad/common/io.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -474,3 +474,67 @@ if { [namespace exists utl] } {
puts "%OL_METRIC $metric $value"
}
}

proc exit_unless_gui {{status 0}} {
if { ![info exists ::env(_OPENROAD_GUI)] || !$::env(_OPENROAD_GUI) } {
exit $status
}
}


# Code below adapted from OpenROAD Flow Scripts under the following license:
#
# BSD 3-Clause License
#
# Copyright (c) 2018-2023, The Regents of the University of California
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:

# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# * Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
proc log_cmd {cmd args} {
puts "+ $cmd [join $args " "]"
$cmd {*}$args
}

proc find_unfixed_macros {} {
set macros [list]

foreach inst [$::block getInsts] {
set inst_master [$inst getMaster]

# BLOCK means MACRO cells
if { ![string match [$inst_master getType] "BLOCK"] } {
continue
}

if { [$inst isFixed] } {
continue
}

lappend macros $inst
}
return $macros
}

4 changes: 2 additions & 2 deletions openlane/scripts/openroad/common/set_global_connections.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ proc set_global_connections {} {

if { $power_pin == "" || $ground_pin == "" } {
puts "PDN_MACRO_CONNECTIONS missing power and ground pin names"
exit -1
exit_unless_gui 1
}

set matched 0
Expand All @@ -57,7 +57,7 @@ proc set_global_connections {} {
}
if { $matched != 1 } {
puts "\[ERROR\] No match found for regular expression '$instance_name' defined in PDN_MACRO_CONNECTIONS."
exit 1
exit_unless_gui 1
}

add_global_connection \
Expand Down
2 changes: 1 addition & 1 deletion openlane/scripts/openroad/common/set_power_nets.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if { [info exists ::env(VDD_NETS)] || [info exists ::env(GND_NETS)] } {
# current assumption: they cannot have a common ground
if { ! [info exists ::env(VDD_NETS)] || ! [info exists ::env(GND_NETS)] } {
puts stderr "\[ERROR\] VDD_NETS and GND_NETS must *both* either be defined or undefined"
exit -1
exit_unless_gui 1
}
set ::env(VDD_NET) [lindex $::env(VDD_NETS) 0]
set ::env(GND_NET) [lindex $::env(GND_NETS) 0]
Expand Down
4 changes: 2 additions & 2 deletions openlane/scripts/openroad/cts.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if { [info exists ::env(CTS_MAX_CAP)] } {
if { [info exists ::env(CTS_MAX_SLEW)] } {
lappend cts_characterization_args -max_slew [expr {$::env(CTS_MAX_SLEW) * 1e-9}]; # ns -> S
}
configure_cts_characterization {*}$cts_characterization_args
log_cmd configure_cts_characterization {*}$cts_characterization_args

puts "\[INFO\] Performing clock tree synthesis…"
puts "\[INFO\] Looking for the following net(s): $::env(CLOCK_NET)"
Expand All @@ -55,7 +55,7 @@ if { $::env(CTS_DISABLE_POST_PROCESSING) } {
lappend arg_list -post_cts_disable
}

clock_tree_synthesis {*}$arg_list
log_cmd clock_tree_synthesis {*}$arg_list

set_propagated_clock [all_clocks]

Expand Down
21 changes: 20 additions & 1 deletion openlane/scripts/openroad/cut_rows.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,30 @@
source $::env(SCRIPTS_DIR)/openroad/common/io.tcl
read_current_odb

cut_rows\
log_cmd cut_rows\
-endcap_master $::env(ENDCAP_CELL)\
-halo_width_x $::env(FP_MACRO_HORIZONTAL_HALO)\
-halo_width_y $::env(FP_MACRO_VERTICAL_HALO)

# Prune really short rows (<25 sites) so the PDN doesn't scream and complain
## Replace with https://github.com/The-OpenROAD-Project/OpenROAD/issues/5648 when this is available
foreach lib $::libs {
set current_sites [$lib getSites]
foreach site $current_sites {
set name [$site getName]
set ::sites($name) $site
}
}

set ::default_site $::sites($::env(PLACE_SITE))
foreach row [$::block getRows] {
set bbox [$row getBBox]
set site_count [expr ([$bbox xMax] - [$bbox xMin]) / [$::default_site getWidth]]
if { $site_count < 25 } {
odb::dbRow_destroy $row
}
}

write_views

report_design_area_metrics
4 changes: 2 additions & 2 deletions openlane/scripts/openroad/drt.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ if { [info exists ::env(DRT_MAX_LAYER)] } {
set max_layer $::env(DRT_MAX_LAYER)
}

detailed_route\
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

write_views
write_views
6 changes: 3 additions & 3 deletions openlane/scripts/openroad/floorplan.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ puts "\[INFO\] Using $::env(FP_SIZING) sizing for the floorplan."
if {$::env(FP_SIZING) == "absolute"} {
if { [llength $::env(DIE_AREA)] != 4 } {
puts stderr "Invalid die area string '$::env(DIE_AREA)'."
exit -1
exit_unless_gui 1
}
if { ! [info exists ::env(CORE_AREA)] } {
set die_ll_x [lindex $::env(DIE_AREA) 0]
Expand All @@ -70,7 +70,7 @@ if {$::env(FP_SIZING) == "absolute"} {
} else {
if { [llength $::env(CORE_AREA)] != 4 } {
puts stderr "Invalid core area string '$::env(CORE_AREA)'."
exit -1
exit_unless_gui 1
}
puts "\[INFO\] Using the set CORE_AREA; ignoring core margin parameters"
}
Expand All @@ -94,7 +94,7 @@ if { [info exists ::env(FP_OBSTRUCTIONS)] } {
}
}

initialize_floorplan {*}$arg_list
log_cmd initialize_floorplan {*}$arg_list

insert_tiecells $::env(SYNTH_TIELO_CELL) -prefix "TIE_ZERO_"
insert_tiecells $::env(SYNTH_TIEHI_CELL) -prefix "TIE_ONE_"
Expand Down
Loading
Loading