Skip to content

synth: drop the ABC delay target that never reached ABC - #4586

Merged
maliberty merged 2 commits into
The-OpenROAD-Project:masterfrom
zhangzheng-debug:abc-clock-target-optin
Oct 3, 2026
Merged

maliberty merged 2 commits into
The-OpenROAD-Project:masterfrom
zhangzheng-debug:abc-clock-target-optin

Conversation

@zhangzheng-debug

@zhangzheng-debug zhangzheng-debug commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #4585

synth_preamble.tcl passed ABC_CLOCK_PERIOD_IN_PS to Yosys as abc -script <file> ... -D <period>, but Yosys uses -D only to fill in {D} in the script it writes for ABC; for a script file it writes source <file> and drops -D. So the clock period has not reached ABC since b9c1485, and synthesis has been clock-independent all along (details and a reproduction in #4585).

Following the discussion below, this PR makes that explicit (option B in #4585) instead of adding a switch. It removes:

  • the -D argument and the "Extracting clock period" / "Setting clock period" log lines in synth_preamble.tcl;
  • clock_period.txt: its make rule, the do-sdc-clock-period target, its entry in YOSYS_DEPENDENCIES and its line in clean_synth, so an SDC change no longer re-runs Yosys;
  • the extraction of the period from the SDC in variables.mk and in the ihp-sg13g2 config.mk;
  • the ABC_CLOCK_PERIOD_IN_PS settings of the three gf12 bp_* designs.

ABC_CLOCK_PERIOD_IN_PS is removed (second commit, as requested in review): from variables.yaml, with variables.json and FlowVariables.md regenerated, and from flow/util/genMassive.py, whose sweep knob wrote it into the generated config files.

Tested locally

make synth on a12d469 with this commit applied (the ten files it touches are the same on the current master), with the same Yosys (0.68+, tools/yosys a5af9d690a43) and OpenROAD binaries as in #4585:

  • 15 configurations across all 7 public platforms, each compared with master: nangate45/gcd (area script, speed script, and speed script with ABC_CLOCK_PERIOD_IN_PS=5000), sky130hd/gcd (abc_new), sky130hs/gcd, asap7/gcd (SYNTH_USE_SYN 1 and 0), ihp-sg13g2/gcd (SYNTH_USE_SYN=1, and SYNTH_USE_SYN=0 SWAP_ARITH_OPERATORS=0), gt2n/gcd, gf180/aes, sky130hd/riscv32i, nangate45/ibex, nangate45/ibex with SYNTH_HIERARCHICAL=1, and asap7/riscv32i (hierarchical, abc_new). The netlist and every other file under results/, objects/ and reports/ are identical once checkout paths are normalized, except that clock_period.txt is no longer written. The logs differ only in the removed clock-period lines and make rule, the -D <period> on the abc / abc_new command, run times and paths.
  • nangate45/gcd with its own copy of the SDC: after changing only the clock period (0.25 to 0.4 ns), or only adding a comment, this branch re-runs just the copy to 1_2_yosys.sdc and synth_odb, and ends with the same 1_2_yosys.v, 1_synth.odb and 1_synth.sdc as master, which re-runs both Yosys steps. With SYNTH_USE_SYN=1, 1_synth.odb depends on the SDC directly, so any SDC edit still re-runs synth_syn, as on master.
  • A work directory synthesized with master is up to date for this branch (make synth has nothing to do).
  • tclfmt --in-place ., yamlfix, generate-variables-docs.py and yaml_to_json.py make no change, and tclint . is clean (versions from requirements_lock.txt).

Not tested: private platforms (including the gf12 designs whose config changes), the Bazel flow, macOS.

bazel-orfs

bazel-orfs runs make do-sdc-clock-period in its synth rule and has analysis tests that expect clock_period.txt as a synthesis input. Both need to go before, or together with, the ORFS bump that includes this change. I'm happy to help with that.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the ABC_USE_CLOCK_PERIOD configuration variable to enable using ABC_CLOCK_PERIOD_IN_PS as the delay target for ABC technology mapping, with corresponding updates to documentation, variables, and synthesis scripts. The review feedback identifies two critical issues: a fragile script-splitting logic in synth_preamble.tcl that can fail if comments contain semicolons, and a potential hang in variables.mk if LIB_FILES is empty, causing gzip to wait indefinitely on standard input.

Comment thread flow/scripts/synth_preamble.tcl Outdated
Comment on lines +222 to +231
foreach cmd [split [read $fp] "\n;"] {
set cmd [string trim $cmd]
if { $cmd == "" || [string index $cmd 0] == "#" } {
continue
}
if { [regexp {^(&nf|map|upsize|dnsize)(\s|$)} $cmd] } {
append cmd " {D}"
}
lappend abc_commands $cmd
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Splitting the ABC script file content using both newlines and semicolons (\n;) is fragile. If a comment line in the ABC script contains a semicolon (e.g., # some comment; map is here), split will break it into multiple parts. The part after the semicolon will not start with # and will be treated as a valid command, leading to syntax errors or unexpected behavior during synthesis. It is safer to first split by newlines to process line-by-line, and then split non-comment lines by semicolons.

  foreach line [split [read $fp] "\n"] {
    set line [string trim $line]
    if { $line == "" || [string index $line 0] == "#" } {
      continue
    }
    foreach cmd [split $line ";"] {
      set cmd [string trim $cmd]
      if { $cmd == "" } {
        continue
      }
      if { [regexp {^(&nf|map|upsize|dnsize)(\s|$)} $cmd] } {
        append cmd " {D}"
      }
      lappend abc_commands $cmd
    }
  }

Comment thread flow/scripts/variables.mk Outdated
Comment on lines +221 to +232
ifeq ($(ABC_USE_CLOCK_PERIOD),1)
# The SDC period is in the library time unit, ABC wants ps: scale it
# by the time_unit of the first liberty file, e.g. "1ns" -> 1000.
export ABC_CLOCK_PERIOD_IN_PS := $(shell gzip -dcf $(firstword $(LIB_FILES)) 2>/dev/null | \
awk -v p=$(ABC_CLOCK_PERIOD_IN_PS) '/^[ \t]*time_unit[ \t]*:/ { \
if (p != "" && match($$0, /[0-9.]+[ \t]*[pnu]s/)) { \
u = substr($$0, RSTART, RLENGTH); \
print p * u * (u ~ /ps/ ? 1 : u ~ /ns/ ? 1000 : 1000000) \
} \
exit \
}')
endif

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

If LIB_FILES is empty or undefined, $(firstword $(LIB_FILES)) evaluates to an empty string. This causes gzip -dcf to run without any file arguments, making it wait indefinitely for input on stdin. This will hang the make process. Wrapping this block with a check to ensure LIB_FILES is not empty prevents this hang.

      ifeq ($(ABC_USE_CLOCK_PERIOD),1)
         ifneq ($(strip $(LIB_FILES)),)
            # The SDC period is in the library time unit, ABC wants ps: scale it
            # by the time_unit of the first liberty file, e.g. "1ns" -> 1000.
            export ABC_CLOCK_PERIOD_IN_PS := $(shell gzip -dcf $(firstword $(LIB_FILES)) 2>/dev/null | \
               awk -v p=$(ABC_CLOCK_PERIOD_IN_PS) '/^[ \t]*time_unit[ \t]*:/ { \
                  if (p != "" && match($$0, /[0-9.]+[ \t]*[pnu]s/)) { \
                     u = substr($$0, RSTART, RLENGTH); \
                     print p * u * (u ~ /ps/ ? 1 : u ~ /ns/ ? 1000 : 1000000) \
                  } \
                  exit \
               }')
         endif
      endif

Comment thread flow/scripts/variables.mk Outdated
ifeq ($(origin ABC_CLOCK_PERIOD_IN_PS), undefined)
ifneq ($(wildcard $(SDC_FILE)),)
export ABC_CLOCK_PERIOD_IN_PS := $(shell sed -nE "s/^set\s+clk_period\s+(\S+).*|.*-period\s+(\S+).*/\1\2/p" $(SDC_FILE) | head -1 | awk '{print $$1}')
ifeq ($(ABC_USE_CLOCK_PERIOD),1)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😱 How are we going to write tests for this? It is also very hard to read.

I think this should be moved out into a Python script with unit-tests.

Also 'awk' is not a tool that's necessarily installed.

I think we should switch to extracting the best guess using a heuristic, like we do today, and an error if we're wrong. We can check when we write out the .odb at which point we can have opensta read in the .sdc file and we can know for sure and match it against the guess. Upon seeing this error, the user can explicitly pass in the correct period. I believe the python heuristic script will figure out the clock period, so this error + setting period explicitly is an escape hatch.

Comment thread flow/scripts/variables.yaml Outdated
`SWAP_ARITH_OPERATORS` (abc_new) or `SYNTH_USE_SYN`.
stages:
- synth
default: 0

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why should this be opt-in? Why a new variable?

If we're optimizing for speed, then why isn't this compulsory? what's the downside?

If this isn't enabled by default, then no CI tests will run on it and it is just unused cruft in the repository...

Is this an escape hatch? Why should it be a variable? Why isn't patching ORFS a sufficient escape hatch? If this is a behavior that should be on by default for all users, unless it is broken, then the variable should be removed and we should just fix the bugs and not have a feature toggle.

@oharboe

oharboe commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the careful diagnosis in #4585 — the reproduction and the switch-off equivalence testing across all platforms are excellent.

Before this PR can move forward I think it needs a direction decision from the maintainers, and it's the kind of call a feature toggle shouldn't make on their behalf.

Where we are today: synthesis is effectively clock-agnostic in both engines

  • Yosys flow: as you showed, -D has not reached ABC since ~b9c1485f9 (2021). Every design's CI QoR baseline was tuned without a delay target.
  • OpenROAD SYN (SYNTH_USE_SYN=1): in synth_syn.tcl, mapping (synthesize) runs before read_sdc, and synthesize has no timing arguments. The subsequent repair_design -pre_placement fixes slew/cap/fanout, not the clock period. So the in-house engine is clock-agnostic by design.
  • After synthesis: timing is owned by repair_timing, which reads the real clock from 1_synth.sdc; area recovery on positive slack is RECOVER_POWER.

What your data says about making the Yosys path clock-aware

WNS/TNS at a fixed clock is misleading here: CI designs are deliberately set just past closure, so WNS is tiny and slightly negative. The metric that matters is minimum achievable clock period. Estimating it from your 5_1_grt table as clock − WNS:

design switch off switch on
nangate45/jpeg 1.119 ns 1.186 ns (~6% slower)
sky130hd/riscv32i 6.858 ns 6.873 ns
gf180/aes 3.802 ns 3.807 ns
nangate45/ibex 2.204 ns 2.199 ns

One clear regression, noise elsewhere, in exchange for 0–5% area/power at default clocks. That's plausible given ABC's delay model has no wires: it spends slack that placement later needs. The big area win in your data (−22.8%) was at a clock 10× looser than default, which isn't where CI designs live.

A data point from a large design

On XiangShan's Frontend block (asap7, ~1.2M cells; synthesis-stage timing only, place-stage comparison not done yet), the biggest ABC timing cost wasn't the missing clock period but buffer -c. It builds buffer chains, not trees — a broadcast net's far loads sit up to 18 buffers deep, costing 470–690 ps on the worst reg2reg paths of a ~1,265 ps period. Rebuilding those as balanced trees after synthesis cut reg2reg endpoints over 1,000 ps from 16,382 to 2,443; dropping buffer -c from the speed script and building all trees afterwards cut them to 566. Meanwhile ABC's mapping is clearly worth keeping: speed vs. area script (both without a target) took one block from 2,020 to 1,624 ps, since logic depth is chosen in mapping and the resizer doesn't restructure.

Handing buffering entirely to OpenROAD isn't free today, though: on that netlist repair_design -pre_placement after remove_buffers crashes in Resizer::insertBufferBeforeLoads (not yet reduced/reported), the old REMOVE_ABC_BUFFERS path left ~46,000 slew violators after one pass, and repair_timing -setup on the synthesis netlist moved WNS only from −1,374 to −1,238 ps in 50 minutes.

The direction this suggests: ABC maps, OpenROAD owns sizing and buffering. Note this PR adds {D} to &nf, map, upsize and dnsize but not buffer, so it doesn't touch the biggest lever either way.

The two options

  • (A) Clock-aware synthesis. Deliver the target by default in the Yosys flow and rebase QoR. This makes Yosys and OpenROAD SYN diverge in philosophy (unless SYN gains a delay target too), and requires fixing the ns/ps units and making the SDC-scraping heuristic robust — I'd suggest a Python script with unit tests, verified against OpenSTA in synth_odb.tcl (error on mismatch), rather than more awk in variables.mk. The target should probably go on mapping (&nf) only.
  • (B) Clock-agnostic synthesis; timing awareness pushed after synthesis. Remove the ignored -D, the "Setting clock period" log line and synthesis's dependency on clock_period.txt. This matches what OpenROAD SYN already does and what CI has measured for years, stops a clock change from forcing a pointless re-synthesis, and makes the unit and heuristic problems disappear.

My reading of the data is (B), but I'm not a maintainer. Either way I'd argue against a default-off toggle: nothing in CI exercises it, so it becomes cruft. Your corrected description of ABC_CLOCK_PERIOD_IN_PS looks worth landing regardless.

@maliberty — which direction do you want for synthesis: clock-aware (A), or clock-agnostic with timing pushed after synthesis (B)? The contributor has done the groundwork to make either straightforward, and it would be a shame to leave this in limbo.

@openroad-ci

openroad-ci commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

🔍 QoR check

Metrics reflect the PR merge build — i.e. what will land on the target branch.

Commit d3c8f4f · Jenkins build #3 · Baseline: build · View build on dashboard

62 design(s) checked — 0 with regression(s), 0 without a comparable baseline.

Yosys uses abc -D only to fill in {D} in the script it writes for ABC;
for "abc -script <file>" it writes "source <file>" instead, so the clock
period has not reached ABC since b9c1485 and synthesis is already
clock-agnostic. Remove the -D argument, the "Setting clock period" log
line, clock_period.txt and its make rule (no longer a Yosys dependency)
and the SDC period extraction in variables.mk and ihp-sg13g2. Mark
ABC_CLOCK_PERIOD_IN_PS deprecated and drop its gf12 bp_* settings.
Netlists are unchanged; a clock-only SDC change no longer re-runs Yosys.

Signed-off-by: Zheng Zhang <zz13240206005@gmail.com>
@zhangzheng-debug

Copy link
Copy Markdown
Contributor Author

Thanks @oharboe, this is very helpful.

Agreed that a default-off toggle shouldn't land. I made it opt-in only so that CI QoR wouldn't change without a maintainer decision, not to keep it as a long-term escape hatch.

Reading the same data, I'd also go with (B). I'm preparing it for this PR: drop the ignored -D and the "Setting clock period" log line, remove clock_period.txt and its use as a Yosys dependency, remove the SDC period extraction (including ihp-sg13g2's own conversion), and mark ABC_CLOCK_PERIOD_IN_PS as deprecated (or remove it, if you prefer). I'm checking that the synthesized netlists stay identical to master across the platforms and will post the results here.

@maliberty, if you'd rather have (A), let me know and I'll rework the PR along the lines oharboe suggested instead.

@zhangzheng-debug zhangzheng-debug changed the title synth: add opt-in ABC_USE_CLOCK_PERIOD to give ABC a delay target synth: drop the ABC delay target that never reached ABC Sep 30, 2026
@zhangzheng-debug

Copy link
Copy Markdown
Contributor Author

I've force-pushed (B) to this branch and rewritten the description. If (A) is preferred, I'll rework it along the lines oharboe outlined.

In short (details in the description):

  • Netlists are unchanged: 15 configurations across all 7 public platforms, including abc_new, SYNTH_USE_SYN=1 and SYNTH_HIERARCHICAL=1, give the same outputs as master apart from checkout paths, except that clock_period.txt is no longer written.
  • In the Yosys flow, a clock-only SDC edit no longer re-runs Yosys, and the resulting 1_synth.sdc and 1_synth.odb match master's full re-run.
  • The two awk calls in variables.mk and the ihp-sg13g2 config go away with the SDC extraction.
  • bazel-orfs calls make do-sdc-clock-period, which this removes, so it needs to drop that step before or together with the ORFS bump that includes this. Happy to help with that.
  • ABC_CLOCK_PERIOD_IN_PS is kept as deprecated; I can delete it instead, as Remove REMOVE_ABC_BUFFERS support #4580 does for REMOVE_ABC_BUFFERS.

On buffer: ABC's buffer has no delay target, only gain and slew targets and a fanout limit, and Yosys' own script doesn't give it {D} either. So buffering is a separate question from this PR.

@maliberty

Copy link
Copy Markdown
Member

I noticed the same a few weeks ago. I tried playing with a fix but it didn't really help QoR. Brief examination suggested that inaccuracy in abc's timing leaves it 'hitting' the target frequency but actually not really after PnR. The loss of further optimization was sometimes a net negative though in some cases it worked out and you got an area savings.

If you want to hunt for a consistently better formulation I would be open to it. Otherwise we can just drop the inert switch.

@oharboe

oharboe commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

@maliberty is timing aware synthesis a job for OpenROAD stages and not yosys+abc, or synthesis?

@zhangzheng-debug

Copy link
Copy Markdown
Contributor Author

Thanks @maliberty, that matches what I saw (numbers in #4585): with the target delivered the netlists change, but QoR after global routing is mixed at the default clocks, and the clear area win only shows up at a much looser clock. I don't have a formulation that is consistently better, so I'm not pursuing one here.

This PR now just drops the inert switch: the ignored -D, the "Setting clock period" log line, clock_period.txt as a Yosys dependency, and the SDC period extraction, with ABC_CLOCK_PERIOD_IN_PS kept as a deprecated, unused variable. Synthesized netlists are unchanged on the 15 configurations I ran, and CI passes. The one follow-up is bazel-orfs, which calls make do-sdc-clock-period (see the description).

Comment thread flow/scripts/variables.yaml Outdated
description: >
Clock period to be used by STA during synthesis. Default value read from
`constraint.sdc`.
Not used: Yosys and ABC do not use a clock period. Timing is handled by

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete it

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

specifying it in config.mk has no effect before and after this PR, so no need to have it in documentation or have it as deprecated.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 48cd025: removed from variables.yaml (variables.json and FlowVariables.md regenerated), and dropped the genMassive.py sweep knob that wrote it.

@oharboe

oharboe commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

Well spotted! 😌

The variable has had no effect on synthesis, before and after the
previous commit, so drop it rather than keeping it as deprecated:
remove it from variables.yaml (and the generated variables.json and
FlowVariables.md) and remove the genMassive.py sweep knob that wrote
it into the generated config.mk files.

Signed-off-by: Zheng Zhang <zz13240206005@gmail.com>
@oharboe

oharboe commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator

@maliberty TL;DR: this also removes a hidden dependency in AUTO_MEMORIES. Its yosys extract pass sources synth_preamble.tcl, so it reads clock_period.txt without declaring it, even though it never runs ABC. Flows work because make synth builds the file first. Explicit targets like make .../memories_inferred.json fail. This PR deletes the read, so that dependency goes away.

No coordination needed: this and the AUTO_MEMORIES PRs can merge in either order. It's just a nice simplification.

Please approve a CI run.

@maliberty
maliberty enabled auto-merge October 3, 2026 16:07
@maliberty
maliberty merged commit 43b747f into The-OpenROAD-Project:master Oct 3, 2026
13 checks passed
oharboe added a commit to oharboe/OpenROAD-flow-scripts that referenced this pull request Oct 3, 2026
Stragglers from The-OpenROAD-Project#4586, which removed the variable from variables.yaml
and the gf12 bp_* designs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
github-actions Bot pushed a commit to oharboe/OpenROAD-flow-scripts that referenced this pull request Oct 3, 2026
The-OpenROAD-Project#4586 removed ABC_CLOCK_PERIOD_IN_PS from variables.yaml and the gf12
bp_* settings of it, but nangate45/picorv32 and nangate45/tpu still set
it. make ignores the leftover; a flow that checks config.mk against
variables.yaml refuses it as unknown. No effect on results: the
variable had not reached ABC before The-OpenROAD-Project#4586.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ABC_CLOCK_PERIOD_IN_PS has no effect: "abc -D" is ignored when "-script <file>" is used

4 participants