diff --git a/BUILD.bazel b/BUILD.bazel index a9796cf..6958993 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -462,10 +462,10 @@ BOOMTILE_SOURCES = { name = "BoomTile_" + variant + "_report", src = ":BoomTile_" + ("" if variant == "base" else variant + "_") + SWEEP_JSON["stage"], outs = [ - "BoomTile_" + variant + ".yaml", + "BoomTile_" + variant + ".txt", ], + extra_args = "> $WORK_HOME/BoomTile_" + variant + ".txt", arguments = { - "OUTFILE": "$(location :BoomTile_" + variant + ".yaml)", "ODB_FILE": "$(location :BoomTile_" + variant + "_odb)", }, data = [":BoomTile_" + variant + "_odb"], @@ -484,7 +484,7 @@ genrule( srcs = [ "wns_report.py", "sweep.json", - ] + [":BoomTile_" + variant + ".yaml" for variant in WNS_REPORT_SWEEP] + + ] + [":BoomTile_" + variant + ".txt" for variant in WNS_REPORT_SWEEP] + [":BoomTile_" + variant + "_logs" for variant in WNS_REPORT_SWEEP], outs = ["BoomTile_wns_report.md"], cmd = ( diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..e4a1d6b --- /dev/null +++ b/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +norecursedirs = bazel-bin/ bazel-megaboom/ bazel-out/ bazel-testlogs/ build/ + diff --git a/report-wns.tcl b/report-wns.tcl index 8a0872b..f896420 100644 --- a/report-wns.tcl +++ b/report-wns.tcl @@ -1,35 +1,12 @@ # Test this on some simple design in ORFS: -# -# ODB_FILE=results/asap7/base/2_floorplan.odb OUTFILE=blah.txt make run RUN_SCRIPT=~/megaboom/report-wns.tcl +# 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] -report_clock_skew >reports.txt -report_tns >>reports.txt -set fp [open reports.txt r] -set crpr "" -set skew "" -set tns "" -while {[gets $fp line] != -1} { - if {[regexp {([0-9.]+)\s+CRPR} $line match crpr_value]} { - set crpr $crpr_value - } - if {[regexp {([0-9.]+)\s+setup\s+skew} $line match skew_value]} { - set skew $skew_value - } - if {[regexp {tns (.*)} $line match tns_value]} { - set tns $tns_value - } -} -close $fp - -set fp [open $::env(OUTFILE) w] -puts $fp "slack: $slack" -puts $fp "crpr: $crpr" -puts $fp "skew: $skew" -puts $fp "tns: $tns" -close $fp - +puts "slack: $slack" +report_tns +report_cell_usage diff --git a/wns_report.py b/wns_report.py index 1a6b773..cc841d1 100755 --- a/wns_report.py +++ b/wns_report.py @@ -1,7 +1,6 @@ #!/usr/bin/env python3 import os -import yaml -import json +import re import pathlib import sys from tabulate import tabulate @@ -11,6 +10,60 @@ def transpose_table(table_data): return list(map(list, zip(*table_data))) +# slack: 0.039060 +# Clock core_clock +# 0.00 source latency ctrl.state.out[0]$_DFF_P_/CK ^ +# 0.00 target latency ctrl.state.out[0]$_DFF_P_/CK ^ +# 0.00 CRPR +# -------------- +# 0.00 setup skew + + +# tns 0.00 +# Cell type report: Count Area +# Tap cell 48 12.77 +# Buffer 14 19.95 +# Inverter 85 51.34 +# Sequential cell 35 158.27 +# Multi-Input combinational cell 369 420.55 +# Total 551 662.87 +def parse_stats(report): + """Create a dictionary with the values above""" + stats = {} + report_start = False + for line in report.split("\n"): + if "slack" in line: + stats["slack"] = float(line.split()[1]) + if "setup skew" in line: + stats["skew"] = line.split()[0] + # First line is "Cell type report", last line is "Total", + # fish out the values in between + if "Cell type report" in line: + report_start = True + continue + if report_start: + # fish out using regex first number column and use the label as key + # and the first number as the value. + # + # use regex, because split() would get confused by space + # in the label + # use regex, but don't get confused by one or more spaces in the label + # Sequentialcell 35 158.27 + # Tap cell 48 12.77 + # Multi-Input combinational cell 369 420.55 + # some labels have spaces, some don't + m = re.match(r"\s*(\D+)(\d+)\s+(\d+\.\d+)", line) + if m: + stats[m.group(1).strip()] = int(m.group(2)) + if "Total" in line: + report_start = False + continue + + print(str(stats)) + + return stats + + # Extract Elapsed Time line from log file # Elapsed time: 0:04.26[h:]min:sec. CPU time: user 4.08 sys 0.17 (99%). \ # Peak memory: 671508KB. @@ -86,11 +139,13 @@ def main(): table_data = None for variant in sweep: - slack_file = os.path.join( - os.path.dirname(sweep_file), "BoomTile_" + variant + ".yaml" - ) - with open(slack_file, "r") as file: - stats = yaml.safe_load(file) + with open( + os.path.join(os.path.dirname(sweep_file), "BoomTile_" + variant + ".txt"), + "r", + ) as file: + report = file.read() + stats = parse_stats(report) + print(str(stats)) names = sorted(stats.keys()) if table_data is None: table_data = [ diff --git a/wns_report_test.py b/wns_report_test.py new file mode 100755 index 0000000..cc06433 --- /dev/null +++ b/wns_report_test.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 +import wns_report + + +def test_parse_stats(): + report = """ + slack: 0.039060 + Clock core_clock + 0.00 source latency ctrl.state.out[0]$_DFF_P_/CK ^ + 0.00 target latency ctrl.state.out[0]$_DFF_P_/CK ^ + 0.00 CRPR + -------------- + 0.00 setup skew + + tns 0.00 + Cell type report: Count Area + Tap cell 48 12.77 + Buffer 14 19.95 + Inverter 85 51.34 + Sequential cell 35 158.27 + Multi-Input combinational cell 369 420.55 + Total 551 662.87 + """ + expected_stats = { + "slack": 0.03906, + "skew": "0.00", + "Tap cell": 48, + "Inverter": 85, + "Buffer": 14, + "Sequential cell": 35, + "Multi-Input combinational cell": 369, + "Total": 551, + } + + assert wns_report.parse_stats(report) == expected_stats