Skip to content

Commit

Permalink
sweep: bazel build wns_report
Browse files Browse the repository at this point in the history
Signed-off-by: Øyvind Harboe <[email protected]>
  • Loading branch information
oharboe committed Oct 17, 2024
1 parent ae492b0 commit 0ca9111
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ jobs:
uses: actions/checkout@v4
- name: Smoketests
run: |
bazel build lb_32x128_shared_synth_floorplan
bazel build lb_32x128_shared_synth_floorplan wns_report
test-target-local-clean-setup:
name: Local flow - clean setup
Expand Down
59 changes: 45 additions & 14 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -145,30 +145,61 @@ orfs_flow(
verilog_files = LB_VERILOG_FILES,
)

# Use-case:
#
# bazel build --keep_going $(bazel query //:* | grep lb_32x128_density.*place\$)
DENSITY_SWEEP = [
0.70,
0.75,
0.80,
]
SWEEP = {
"1": {
"PLACE_DENSITY": "0.65",
},
"2": {
"PLACE_DENSITY": "0.70",
},
"3": {
"PLACE_DENSITY": "0.75",
},
"4": {
"PLACE_DENSITY": "0.80",
},
}

# buildifier: disable=duplicated-name
[
orfs_flow(
name = "lb_32x128",
abstract_stage = "place",
arguments = LB_ARGS | {
"PLACE_DENSITY": str(density),
},
abstract_stage = "cts",
arguments = LB_ARGS | SWEEP[variant],
# Share synthesis across all variants, the sweep
# differs from floorplan and onwards
previous_stage = {"floorplan": "lb_32x128_synth"},
stage_sources = LB_STAGE_SOURCES,
variant = "density_" + str(density),
variant = variant,
verilog_files = LB_VERILOG_FILES,
)
for density in DENSITY_SWEEP
for variant in SWEEP
]

[orfs_run(
name = "lb_32x128_" + variant + "_report",
src = ":lb_32x128_" + ("" if variant == "base" else variant + "_cts"),
outs = [
"lb_32x128_" + variant + ".yaml",
],
arguments = {
"OUTFILE": "$(location :lb_32x128_" + variant + ".yaml)",
},
script = ":report-wns.tcl",
) for variant in SWEEP]

genrule(
name = "wns_report",
srcs = ["wns-report.py"] +
[":lb_32x128_" + variant + ".yaml" for variant in SWEEP],
outs = ["lb_32x128_wns_report.md"],
cmd = (
"$(location :wns-report.py) > $@ " +
" ".join(["$(location :lb_32x128_" + variant + ".yaml)" for variant in SWEEP])
),
visibility = ["//visibility:public"],
)

orfs_flow(
name = "L1MetadataArray",
abstract_stage = "cts",
Expand Down
10 changes: 10 additions & 0 deletions report-wns.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
source $::env(SCRIPTS_DIR)/load.tcl
load_design 4_cts.odb 4_cts.sdc

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]

set fp [open $::env(OUTFILE) w]
puts $fp "slack: $slack"
close $fp
32 changes: 32 additions & 0 deletions wns-report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env python3
import os
import yaml
import sys
from tabulate import tabulate


def read_slack_from_yaml(file_path):
with open(file_path, "r") as file:
data = yaml.safe_load(file)
return data.get("slack", "N/A")


def main():
if len(sys.argv) < 2:
print("Usage: python script.py <file1.yaml> <file2.yaml> ...")
sys.exit(1)

files = sys.argv[1:]
table_data = []

for file in files:
slack = read_slack_from_yaml(file)
table_data.append([os.path.splitext(os.path.basename(file))[0], slack])

headers = ["Filename", "Slack"]
table = tabulate(table_data, headers, tablefmt="github")
print(table)


if __name__ == "__main__":
main()

0 comments on commit 0ca9111

Please sign in to comment.