Repository navigation
Conversation
There was a problem hiding this comment.
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.
| 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 | ||
| } |
There was a problem hiding this comment.
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
}
}
| 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 |
There was a problem hiding this comment.
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
| 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) |
There was a problem hiding this comment.
😱 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.
| `SWAP_ARITH_OPERATORS` (abc_new) or `SYNTH_USE_SYN`. | ||
| stages: | ||
| - synth | ||
| default: 0 |
There was a problem hiding this comment.
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.
|
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
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
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 Handing buffering entirely to OpenROAD isn't free today, though: on that netlist The direction this suggests: ABC maps, OpenROAD owns sizing and buffering. Note this PR adds The two options
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 @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. |
🔍 QoR checkMetrics reflect the PR merge build — i.e. what will land on the target branch. Commit 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>
|
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 @maliberty, if you'd rather have (A), let me know and I'll rework the PR along the lines oharboe suggested instead. |
4577332 to
b9ce1ad
Compare
|
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):
On |
|
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. |
|
@maliberty is timing aware synthesis a job for OpenROAD stages and not yosys+abc, or synthesis? |
|
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 |
| 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Done in 48cd025: removed from variables.yaml (variables.json and FlowVariables.md regenerated), and dropped the genMassive.py sweep knob that wrote it.
|
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>
|
@maliberty TL;DR: this also removes a hidden dependency in AUTO_MEMORIES. Its yosys extract pass sources 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. |
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>
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>
Fixes #4585
synth_preamble.tclpassedABC_CLOCK_PERIOD_IN_PSto Yosys asabc -script <file> ... -D <period>, but Yosys uses-Donly to fill in{D}in the script it writes for ABC; for a script file it writessource <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:
-Dargument and the "Extracting clock period" / "Setting clock period" log lines insynth_preamble.tcl;clock_period.txt: its make rule, thedo-sdc-clock-periodtarget, its entry inYOSYS_DEPENDENCIESand its line inclean_synth, so an SDC change no longer re-runs Yosys;variables.mkand in the ihp-sg13g2config.mk;ABC_CLOCK_PERIOD_IN_PSsettings of the three gf12bp_*designs.ABC_CLOCK_PERIOD_IN_PSis removed (second commit, as requested in review): fromvariables.yaml, withvariables.jsonandFlowVariables.mdregenerated, and fromflow/util/genMassive.py, whose sweep knob wrote it into the generated config files.Tested locally
make synthon a12d469 with this commit applied (the ten files it touches are the same on the current master), with the same Yosys (0.68+,tools/yosysa5af9d690a43) and OpenROAD binaries as in #4585:ABC_CLOCK_PERIOD_IN_PS=5000), sky130hd/gcd (abc_new), sky130hs/gcd, asap7/gcd (SYNTH_USE_SYN1 and 0), ihp-sg13g2/gcd (SYNTH_USE_SYN=1, andSYNTH_USE_SYN=0 SWAP_ARITH_OPERATORS=0), gt2n/gcd, gf180/aes, sky130hd/riscv32i, nangate45/ibex, nangate45/ibex withSYNTH_HIERARCHICAL=1, and asap7/riscv32i (hierarchical,abc_new). The netlist and every other file underresults/,objects/andreports/are identical once checkout paths are normalized, except thatclock_period.txtis no longer written. The logs differ only in the removed clock-period lines and make rule, the-D <period>on theabc/abc_newcommand, run times and paths.1_2_yosys.sdcandsynth_odb, and ends with the same1_2_yosys.v,1_synth.odband1_synth.sdcas master, which re-runs both Yosys steps. WithSYNTH_USE_SYN=1,1_synth.odbdepends on the SDC directly, so any SDC edit still re-runssynth_syn, as on master.make synthhas nothing to do).tclfmt --in-place .,yamlfix,generate-variables-docs.pyandyaml_to_json.pymake no change, andtclint .is clean (versions fromrequirements_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-periodin its synth rule and has analysis tests that expectclock_period.txtas 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.