From 0b267628a0153198038a10f54abd761af6fbf1a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Harboe?= Date: Thu, 17 Oct 2024 08:56:00 +0200 Subject: [PATCH] sweep: bazel build wns_report MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Øyvind Harboe --- .github/workflows/ci.yml | 2 +- BUILD | 59 ++++++++++++++++++++++++++++++---------- report-wns.tcl | 10 +++++++ wns-report.py | 44 ++++++++++++++++++++++++++++++ 4 files changed, 100 insertions(+), 15 deletions(-) create mode 100644 report-wns.tcl create mode 100755 wns-report.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 000a329..c41d84e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/BUILD b/BUILD index 3110e0f..43ade57 100644 --- a/BUILD +++ b/BUILD @@ -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", diff --git a/report-wns.tcl b/report-wns.tcl new file mode 100644 index 0000000..979613c --- /dev/null +++ b/report-wns.tcl @@ -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 diff --git a/wns-report.py b/wns-report.py new file mode 100755 index 0000000..e3a81c0 --- /dev/null +++ b/wns-report.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 +import os +import yaml +import sys + +try: + from tabulate import tabulate +except ImportError: + + def tabulate(table_data, headers, tablefmt): + # Simple mock implementation of tabulate + output = [] + output.append(" | ".join(headers)) + output.append("-" * len(output[0])) + for row in table_data: + output.append(" | ".join(map(str, row))) + return "\n".join(output) + + +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 ...") + 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()