-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make sweep in megaboom reusable Signed-off-by: Øyvind Harboe <[email protected]>
- Loading branch information
Showing
7 changed files
with
479 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Test this on some simple design in ORFS: | ||
# make floorplan | ||
# ODB_FILE=results/nangate45/gcd/base/2_floorplan.odb make run RUN_SCRIPT=~/megaboom/report-wns.tcl | ||
source $::env(SCRIPTS_DIR)/open.tcl | ||
|
||
set paths [find_timing_paths -path_group reg2reg -sort_by_slack -group_count 1] | ||
set path [lindex $paths 0] | ||
set slack [get_property $path slack] | ||
|
||
puts "slack: $slack" | ||
report_tns | ||
report_cell_usage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
"""Sweep OpenROAD stages""" | ||
|
||
load("@bazel-orfs//:openroad.bzl", "orfs_flow", "orfs_run", "set") | ||
load(":write_binary.bzl", "write_binary") | ||
|
||
all_stages = [ | ||
"floorplan", | ||
"place", | ||
"cts", | ||
"grt", | ||
"route", | ||
"final", | ||
] | ||
|
||
def sweep( | ||
name, | ||
variables, | ||
sweep, | ||
verilog_files, | ||
stage_sources, | ||
other_variants = {}, | ||
stage = "floorplan", | ||
macros = []): | ||
"""Run a sweep of OpenROAD stages | ||
Args: | ||
name: Verilog module name | ||
variables: dictionary of the base variables for the flow | ||
sweep: The dictionary describing the variables to sweep | ||
other_variants: Dictionary with other variants to generate, but not as part of the sweep | ||
stage: The stage to do the sweep on | ||
macros: name of modules to use as macros | ||
verilog_files: The Verilog files to build | ||
stage_sources: dictionary with list of sources to use for the stage | ||
""" | ||
sweep_json = { | ||
"name": name, | ||
"base": variables, | ||
"sweep": sweep, | ||
"stage": stage, | ||
"stages": all_stages[0:all_stages.index(stage) + 1], | ||
} | ||
write_binary( | ||
name = name + "_sweep.json", | ||
data = str(sweep_json), | ||
) | ||
|
||
all_variants = sweep | other_variants | ||
|
||
for variant in all_variants: | ||
orfs_flow( | ||
name = name, | ||
arguments = variables | all_variants[variant].get("variables", {}), | ||
macros = [ | ||
m | ||
for m in macros | ||
if m not in all_variants[variant].get("dissolve", []) | ||
] + all_variants[variant].get("macros", []), | ||
previous_stage = all_variants[variant].get("previous_stage", {}), | ||
renamed_inputs = all_variants[variant].get("renamed_inputs", {}), | ||
stage_arguments = all_variants[variant].get("stage_arguments", {}), | ||
stage_sources = { | ||
stage: set(stage_sources.get(stage, []) + all_variants[variant].get("stage_sources", {}).get(stage, [])) | ||
for stage in set(stage_sources.keys() + all_variants[variant].get("stage_sources", {}).keys()) | ||
}, | ||
variant = variant, | ||
verilog_files = verilog_files, | ||
) | ||
|
||
native.filegroup( | ||
name = name + "_" + variant + "_odb", | ||
srcs = [":" + name + "_" + ("" if variant == "base" else variant + "_") + sweep_json["stage"]], | ||
output_group = ("5_1_grt" if sweep_json["stage"] == "grt" else str(sweep_json["stages"].index(sweep_json["stage"]) + 2) + "_" + sweep_json["stage"]) + | ||
".odb", | ||
visibility = [":__subpackages__"], | ||
) | ||
|
||
orfs_run( | ||
name = name + "_" + variant + "_report", | ||
src = ":" + name + "_" + ("" if variant == "base" else variant + "_") + sweep_json["stage"], | ||
outs = [ | ||
name + "_" + variant + ".txt", | ||
], | ||
arguments = { | ||
"ODB_FILE": "$(location :" + name + "_" + variant + "_odb)", | ||
}, | ||
data = [":" + name + "_" + variant + "_odb"], | ||
extra_args = "> $WORK_HOME/" + name + "_" + variant + ".txt", | ||
script = Label(":sweep-wns.tcl"), | ||
) | ||
|
||
native.filegroup( | ||
name = name + "_" + variant + "_logs", | ||
srcs = [":" + name + "_" + ("" if variant == "base" else variant + "_") + stage for stage in sweep_json["stages"]], | ||
output_group = "logs", | ||
visibility = [":__subpackages__"], | ||
) | ||
|
||
# This can be built in parallel, but grt needs to be build in serial, or | ||
# we will run out of memory | ||
native.filegroup( | ||
name = name + "_sweep_parallel", | ||
srcs = [name + "_" + ("" if variant == "base" else variant + "_") + "cts" for variant in sweep], | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
native.genrule( | ||
name = name + "_wns_report", | ||
srcs = [ | ||
"wns_report.py", | ||
name + "_sweep.json", | ||
] + [":" + name + "_" + variant + ".txt" for variant in sweep] + | ||
[":" + name + "_" + variant + "_logs" for variant in sweep], | ||
outs = [name + "_wns_report.md"], | ||
cmd = ( | ||
"$(location :wns_report.py) > $@" + | ||
" $(location :" + name + "_sweep.json)" | ||
), | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
native.filegroup( | ||
name = name + "_repair_logs", | ||
srcs = [ | ||
":" + name + "_" + ("" if variant == "base" else variant + "_") + stage | ||
for stage in sweep_json["stages"] | ||
for variant in sweep | ||
], | ||
output_group = "logs", | ||
) | ||
|
||
native.genrule( | ||
name = name + "_plot_repair", | ||
srcs = [ | ||
"plot-retiming.py", | ||
name + "_repair_logs", | ||
], | ||
outs = [name + "_retiming.pdf"], | ||
cmd = "$(location plot-retiming.py) $(location " + name + "_retiming.pdf) $(locations " + name + "_repair_logs)", | ||
visibility = ["//visibility:public"], | ||
) |
Oops, something went wrong.