Skip to content

Commit 05761af

Browse files
oharboeclaude
andcommitted
util: synthesis-only metadata support
genMetrics.py: fall back to 1_synth.sdc for clock extraction when 2_floorplan.sdc is absent (synthesis-only trees, e.g. FLOW_VARIANT=syn); guard the 5_1_grt.log/6_finish.rpt extractions so stages that never ran do not pollute metadata with ERR values; treat empty netlist files like missing ones when hashing (Bazel placeholder files hash like a make run that never wrote the file). genRuleFile.py: add synth instance count (padding) and synth setup WS/TNS (period padding) so rules-syn.json QoR gates cover the metrics synth_syn.tcl reports. Note base-variant update_rules runs will now pick these up too. utils.mk: metadata-synth convenience target (synth + metadata-generate + metadata-check) for make-side smoke runs of the syn variant. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
1 parent 993421d commit 05761af

3 files changed

Lines changed: 52 additions & 15 deletions

File tree

‎flow/util/genMetrics.py‎

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,12 @@ def git_head_commit(git_exe, folder):
192192

193193

194194
def file_sha1(path):
195-
"""SHA-1 of `path`, or "N/A" if absent. Read in chunks so large
195+
"""SHA-1 of `path`, or "N/A" if absent or empty. Empty counts as
196+
absent so Bazel's touched placeholder files (e.g. the canonicalize
197+
RTLIL under SYNTH_USE_SYN or SYNTH_NETLIST_FILES) hash the same as
198+
a make run that never wrote the file. Read in chunks so large
196199
netlists don't blow the heap."""
197-
if not os.path.isfile(path):
200+
if not os.path.isfile(path) or os.path.getsize(path) == 0:
198201
return "N/A"
199202
hasher = hashlib.sha1()
200203
with open(path, "rb") as f:
@@ -258,7 +261,13 @@ def extract_metrics(
258261

259262
# Clocks
260263
# =========================================================================
261-
clk_list = read_sdc(resultPath + "/2_floorplan.sdc")
264+
# Prefer the floorplan SDC; on a synthesis-only tree (e.g. the "syn"
265+
# flow variant stops after 1_synth) fall back to the canonicalized
266+
# synthesis SDC, which carries the same create_clock lines.
267+
sdc_file = resultPath + "/2_floorplan.sdc"
268+
if not os.path.isfile(sdc_file):
269+
sdc_file = resultPath + "/1_synth.sdc"
270+
clk_list = read_sdc(sdc_file)
262271
metrics_dict["constraints__clocks__count"] = len(clk_list)
263272
metrics_dict["constraints__clocks__details"] = clk_list
264273

@@ -277,22 +286,26 @@ def extract_metrics(
277286
# Global Route
278287
# =========================================================================
279288
merge_jsons(logPath, metrics_dict, "5_*.json")
280-
extractTagFromFile(
281-
"globalroute__timing__clock__slack",
282-
metrics_dict,
283-
"^\\[INFO FLW-....\\] Clock .* slack (\\S+)",
284-
logPath + "/5_1_grt.log",
285-
)
289+
# Guarded so a synthesis-only tree doesn't pollute the metadata with
290+
# "ERR" values for stages that never ran.
291+
if os.path.isfile(logPath + "/5_1_grt.log"):
292+
extractTagFromFile(
293+
"globalroute__timing__clock__slack",
294+
metrics_dict,
295+
"^\\[INFO FLW-....\\] Clock .* slack (\\S+)",
296+
logPath + "/5_1_grt.log",
297+
)
286298

287299
# Finish
288300
# =========================================================================
289301
merge_jsons(logPath, metrics_dict, "6_*.json")
290-
extractTagFromFile(
291-
"finish__timing__wns_percent_delay",
292-
metrics_dict,
293-
baseRegEx.format("finish slack div critical path delay", "(\\S+)"),
294-
rptPath + "/6_finish.rpt",
295-
)
302+
if os.path.isfile(rptPath + "/6_finish.rpt"):
303+
extractTagFromFile(
304+
"finish__timing__wns_percent_delay",
305+
metrics_dict,
306+
baseRegEx.format("finish slack div critical path delay", "(\\S+)"),
307+
rptPath + "/6_finish.rpt",
308+
)
296309

297310
extractGnuTime("finish", metrics_dict, logPath + "/6_report.log")
298311

‎flow/util/genRuleFile.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,24 @@ def gen_rule_file(
9595
"round_value": False,
9696
"compare": "<=",
9797
},
98+
"synth__design__instance__count__stdcell": {
99+
"mode": "padding",
100+
"padding": 15,
101+
"round_value": True,
102+
"compare": "<=",
103+
},
104+
"synth__timing__setup__ws": {
105+
"mode": "period_padding",
106+
"padding": 5,
107+
"round_value": False,
108+
"compare": ">=",
109+
},
110+
"synth__timing__setup__tns": {
111+
"mode": "period_padding",
112+
"padding": 20,
113+
"round_value": False,
114+
"compare": ">=",
115+
},
98116
# clock
99117
"constraints__clocks__count": {
100118
"mode": "direct",

‎flow/util/utils.mk‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
.PHONY: metadata
44
metadata: finish metadata-generate metadata-check
55

6+
# Synthesis-only metadata: generate and check QoR after just the synth
7+
# stage, without running the full flow. Used with FLOW_VARIANT=syn to
8+
# gate OpenROAD-SYN synthesis results against rules-syn.json.
9+
.PHONY: metadata-synth
10+
metadata-synth: synth metadata-generate metadata-check
11+
612
.PHONY: metadata-generate
713
metadata-generate:
814
mkdir -p $(REPORTS_DIR)

0 commit comments

Comments
 (0)