Skip to content

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

Closed

Description

@zhangzheng-debug

Subject

[Flow] for any util, flow Makefile, or flow script issues.

Describe the bug

ABC_CLOCK_PERIOD_IN_PS (by default the first clk_period / -period value in SDC_FILE) is written to clock_period.txt and passed to Yosys as abc ... -D <value>, but ABC never receives it. As a result the synthesized netlist does not depend on the clock period, in both the abc and the abc_new branches of synth.tcl and on every platform. Changing only the SDC clock re-runs synthesis (because clock_period.txt changes) and produces a byte-identical 1_2_yosys.v.

Why -D is lost

  • synth_preamble.tcl builds abc -script $SCRIPTS_DIR/abc_speed.script (or abc_area.script) and appends -D $clock_period (synth_preamble.tcl L192-L228); synth.tcl runs it at L285.
  • Yosys uses -D only to replace the {D} placeholder in its built-in ABC scripts (or in an inline -script "+..." script). For -script <file> it only emits source <file> to ABC, and -D is dropped without a warning. help abc says so: "the string {D} in the default scripts above is replaced by this option". Source, in the tools/yosys commit ORFS uses: abc.cc L1056-L1067 (source <file>) and L1083-L1088 ({D} is substituted only in the generated script string). Yosys main (9d0c91b) is the same (L1063-L1074, L1088-L1093), so updating the submodule will not change this. A Yosys developer reached the same conclusion in ABC: read_lib args and placeholders YosysHQ/yosys#4343 (comment).
  • abc_speed.script and abc_area.script contain no {D}. Adding {D} to them would not help by itself, because ABC, not Yosys, reads the file.
  • With abc -nocleanup, the script that Yosys hands to ABC contains only read_blif, read_scl, read_constr, source .../abc_speed.script and write_blif. No delay target appears anywhere (see "Relevant log output").
  • The abc_new branch (SWAP_ARITH_OPERATORS=1 or SYNTH_WRAPPED_OPERATORS=1) also gets -D, but its ABC9 script has no {D} either. sky130hd/gcd, which takes this branch, gives the same netlist for ABC_CLOCK_PERIOD_IN_PS=1100 and 11000.

A second, independent problem: the unit (currently masked by the first)

abc -D is in picoseconds. Until #1546, nangate45, sky130hd, sky130hs and gf180 converted the SDC value (ns) with *1000 in their config.mk; #301 discussed exactly this (ps for asap7, ns elsewhere). #1546 (8ce4ee1) moved the extraction to one place and kept the asap7 form without *1000 (now variables.mk L217-L222). Since then these four platforms pass ns; for example nangate45/gcd passes -D 0.25. ihp-sg13g2 still converts in its own config.mk L69-L74. If -D reached ABC today, these platforms would request a target of a few picoseconds (0.25 ps for nangate45/gcd), which has the same effect as no target.

Documentation

variables.yaml L440-L445 and docs/user/FlowVariables.md describe the variable as "Clock period to be used by STA during synthesis". No STA uses it during synthesis; its only consumer is abc -D.

History

-D did reach ABC from b86c8c2 (2020-04-28), which called abc -D ... without -script so Yosys' built-in script was used, until b9c1485 (2021-01-08), which added -script <file> and kept -D. #23 (2021-05) reported the symptom (changing the clock period in constraint.sdc gave the same synthesized netlist) and was closed after an example of how to set the variable was given.

Expected Behavior

One of the following, depending on what the flow intends:

  • (A) The clock period reaches ABC as a delay target in picoseconds, as the variable name and the documentation suggest, so the netlist depends on it.
  • (B) If synthesis is meant to be clock-independent (timing left to repair_timing and the later stages), the flow should not suggest otherwise: no ignored -D argument, no "Setting clock period to ..." log line, no re-synthesis when only the clock changes, and documentation that says ABC_CLOCK_PERIOD_IN_PS does not affect ABC.

Environment

ORFS:     master c63a606f9ccede13df8c82bbe31a8f6c6d323f6b (2026-09-28). env.sh and every file
          under flow/ were checked against that commit (git blob ids).
Yosys:    0.68+post, prebuilt in an ORFS Docker image whose tools/yosys is a5af9d690a43,
          the same submodule commit as on master
ABC:      yosys-abc bundled with that Yosys
OpenROAD: prebuilt binary from the same image, not built from master's tools/OpenROAD
          (c487fc7086ed); "openroad -version" prints "unknown". "make synth" runs it only after
          1_2_yosys.v has been written (to produce 1_synth.odb / 1_synth.sdc).
OS:       Ubuntu 22.04.5 LTS, x86_64

./etc/Env.sh could not be run: there is no OpenROAD source tree in this setup.

To Reproduce

On master, only make variables (after source env.sh):

cd flow
make DESIGN_CONFIG=./designs/nangate45/gcd/config.mk WORK_HOME=/tmp/d500  ABC_AREA=0 ABC_CLOCK_PERIOD_IN_PS=500  synth
make DESIGN_CONFIG=./designs/nangate45/gcd/config.mk WORK_HOME=/tmp/d5000 ABC_AREA=0 ABC_CLOCK_PERIOD_IN_PS=5000 synth
grep -hE "^(Setting clock period|abc -script)" /tmp/d500/logs/nangate45/gcd/base/1_2_yosys.log /tmp/d5000/logs/nangate45/gcd/base/1_2_yosys.log
md5sum /tmp/d500/results/nangate45/gcd/base/1_2_yosys.v /tmp/d5000/results/nangate45/gcd/base/1_2_yosys.v

Observed: the logs show -D 500 and -D 5000, and the two netlists are byte-identical. The current master (a12d469, 2026-09-29) gives the same result.

The result is the same (two byte-identical netlists each time, same checkout) with:

  • the default area script (ABC_AREA=1, the gcd default), ABC_CLOCK_PERIOD_IN_PS=500 vs 5000;
  • the SDC clock changed instead of the variable (0.5 ns vs 5 ns; the logs then show -D 0.5 and -D 5);
  • asap7/gcd with SYNTH_USE_SYN=0 and the SDC clock changed (100 ps vs 1000 ps), where the unit is already correct;
  • sky130hd/gcd, which goes through the abc_new branch (ABC_CLOCK_PERIOD_IN_PS=1100 vs 11000).

For comparison, with the accompanying PR and ABC_USE_CLOCK_PERIOD=1, the same command with ABC_CLOCK_PERIOD_IN_PS=5000 gives a different, smaller netlist (chip area in synth_stat.txt 533.6 vs 603.8 um^2), so 5000 ps is a target that ABC acts on. 500 ps is tighter than gcd can reach and gives the same netlist as no target.

Relevant log output

# grep of the two 1_2_yosys.log files
# (paths shortened: <ORFS> = the checkout, <d500> / <d5000> = the two WORK_HOME directories)
Setting clock period to 500
abc -script <ORFS>/flow/scripts/abc_speed.script -liberty <ORFS>/flow/platforms/nangate45/lib/NangateOpenCellLibrary_typical.lib -dont_use TAPCELL_X1 -dont_use FILLCELL_X1 -dont_use AOI211_X1 -dont_use OAI211_X1 -constr <d500>/objects/nangate45/gcd/base/abc.constr -D 500
Setting clock period to 5000
abc -script <ORFS>/flow/scripts/abc_speed.script -liberty <ORFS>/flow/platforms/nangate45/lib/NangateOpenCellLibrary_typical.lib -dont_use TAPCELL_X1 -dont_use FILLCELL_X1 -dont_use AOI211_X1 -dont_use OAI211_X1 -constr <d5000>/objects/nangate45/gcd/base/abc.constr -D 5000

# md5sum of the two netlists
0aa0bd8a9471c5d5e6a14e3a023b6648  <d500>/results/nangate45/gcd/base/1_2_yosys.v
0aa0bd8a9471c5d5e6a14e3a023b6648  <d5000>/results/nangate45/gcd/base/1_2_yosys.v

# The script Yosys passes to ABC for the "abc" command above with -D 5000
# (same Yosys, gcd, run by hand with the logged arguments plus -nocleanup -showtmp;
#  "echo" lines removed, paths shortened, <tmp> = Yosys' temporary directories)
read_blif "<tmp>/input.blif";
read_scl "<tmp>/yosys-liberty-scl-cache/yosys_merged_f7929df1.scl" ;
read_constr -v "<d5000>/objects/nangate45/gcd/base/abc.constr";
source <ORFS>/flow/scripts/abc_speed.script;
write_blif <tmp>/output.blif;

Screenshots

No response

Additional Context

What happens if the target is made effective. This is a quick experiment, one run per design, so small differences may be noise. It was run on a slightly older checkout (same synthesis scripts, variables.mk, Makefile and tools/yosys as master; ihp-sg13g2/jpeg and asap7/mock-cpu have since had their default clocks tightened) with an earlier prototype of the fix. With ABC_USE_CLOCK_PERIOD=1, the accompanying PR gives netlists identical to the prototype's (ignoring paths in src attributes) on the 8 designs checked: nangate45/gcd (at 2.5 ns), nangate45/ibex, nangate45/jpeg, sky130hd/riscv32i, sky130hd/jpeg, sky130hs/ibex, gf180/aes and asap7/ethmac, which include all four designs in the table below.

  • Synthesis only, at the default clocks of 10 designs that use abc -script: 8 netlists changed, with chip area between -0.1% and -5.3%. nangate45/gcd (250 ps) and ihp-sg13g2/jpeg (then 8000 ps) did not change.
  • Through grt, at the default clocks (metrics after 5_1_grt):
design (clock) stdcell area power WNS (ns) TNS (ns)
nangate45/jpeg (1.0 ns) -5.1% -9.2% -0.119 -> -0.186 -46.5 -> -69.3
sky130hd/riscv32i (6.0 ns) +0.3% -0.9% -0.858 -> -0.873 -59.9 -> -111.0
gf180/aes (3.0 ns) +2.1% +1.9% -0.802 -> -0.807 -113.5 -> -118.0
nangate45/ibex (2.2 ns) -0.4% 0.0% -0.004 -> +0.001 -0.03 -> 0
  • With a clock 10x looser than the default (nangate45/gcd at 2.5 ns): -22.8% stdcell area, -19.1% power and -30.8% wirelength after grt, and timing still met.

So at the default clocks, delivering the target mostly trades timing for area, probably because ABC's delay model has no wires. LibreLane saw a similar mix after fixing the same mechanism (librelane/librelane#898). I am not claiming that the fix improves QoR. Whether to use the target, and how (for example with a derating factor below 1), is a decision for the maintainers.

Possible fixes

  • (A) Deliver the target. The accompanying PR does this behind a new switch, ABC_USE_CLOCK_PERIOD (default 0). When it is 1, synth_preamble.tcl passes the ABC script inline with {D} on the &nf, map, upsize and dnsize commands, so that Yosys itself substitutes -D, and a default taken from the SDC is converted to ps with the liberty time_unit. With the default of 0 the flow is unchanged. Turning it on by default would change CI QoR.
  • (B) Make the current behaviour explicit. Drop the ignored -D, remove clock_period.txt from the synthesis dependencies so that clock-only changes do not re-run synthesis, and correct the documentation, or deprecate the variable.

#4586 implements option B, following the review discussion there. (It first implemented option A as an opt-in switch.)

Related

Side note (source reading only, not tested). In the abc_new branch, synth.tcl runs scratchpad -set abc9.script .../abc_speed_gia_only.script, but abc_new overwrites abc9.script with its built-in script when no -script is passed (abc_new.cc L124-L127). The two scripts are identical today, so this has no visible effect.

Activity

  1. zhangzheng-debug commented on Sep 30, 2026

    @zhangzheng-debug
    ContributorAuthor

    Opened #4586: option A behind ABC_USE_CLOCK_PERIOD (default 0, so no QoR change).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions