Skip to content

Write 3_place.sdc and 6_final.sdc from their stage scripts - #4353

Merged
eder-matheus merged 1 commit into
The-OpenROAD-Project:masterfrom
oharboe:place-final-self-write-sdc
Jul 16, 2026
Merged

eder-matheus merged 1 commit into
The-OpenROAD-Project:masterfrom
oharboe:place-final-self-write-sdc

Conversation

@oharboe

@oharboe oharboe commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

place and final were the only stages whose SDC was produced by a Makefile do-copy of a prior stage's file (3_place.sdc ← 2_floorplan.sdc, 6_final.sdc ← 5_route.sdc) instead of being written by the stage script itself. Every other stage self-writes its SDC via orfs_write_sdc (synth, floorplan, cts, grt), and the single-process flow.tcl already wrote 3_place.sdc / 6_final.sdc directly.

This retires the copy-forward special case so SDC production is uniform and co-located with the .odb write — mirroring how synth writes 1_synth.sdc alongside 1_synth.odb.

Changes

  • detail_place.tcl writes 3_place.sdc after 3_5_place_dp.odb.
  • final_report.tcl writes 6_final.sdc after 6_final.odb (after the orfs_* procs come into scope via final_connect.tcl).
  • Makefile: drop the two do-copy … .sdc recipes; tie each aggregate .sdc to the step that now writes it with a recipe-less order rule (3_place.sdc: 3_5_place_dp.odb, 6_final.sdc: 6_report.log) — the same shape as the existing 1_synth.sdc: 1_synth.odb rule.
  • flow.tcl: move the single-process 6_final.sdc write to just after the 6_final.odb write, so both flows write it from identical design state (preserving the final-stage byte-equivalence invariant documented in designs/asap7/gcd/BUILD).

Rationale / no behavior change

Timing constraints don't change during placement or finishing, so the serialized SDC is unchanged. On nangate45/gcd, the new 3_place.sdc and 6_final.sdc are byte-identical (constraints) to the files the do-copy previously produced.

Validation

  • Per-stage flow on nangate45/gcd: 3_place.sdc and 6_final.sdc are produced by their stage scripts (exit 0), and downstream stages that consume them (cts reads 3_place.sdc) succeed.
  • Both new SDCs diff clean (constraints) against the prior copy sources.

Note: the gcd_single_flow_{place,final}_test byte-equivalence checks in designs/asap7/gcd are not expected to pass until the pending OpenROAD STA/DRT equivalence fixes land; they should not gate review of this change.

@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 updates the build flow to write SDC constraints directly during the detailed placement and final report steps, rather than copying them from previous steps. Feedback on the Makefile changes highlights that the new recipe-less rules for 3_place.sdc and 6_final.sdc may fail to regenerate these files if they are deleted while their prerequisites are up-to-date. It is recommended to add recipes to handle these cases and ensure build robustness.

Comment thread flow/Makefile Resolved
Comment thread flow/Makefile Resolved
place and final were the only stages whose SDC was produced by a
Makefile do-copy of a prior stage's file (3_place.sdc <- 2_floorplan.sdc,
6_final.sdc <- 5_route.sdc) rather than written by the stage script
itself. Every other stage self-writes its SDC via orfs_write_sdc
(synth, floorplan, cts, grt), and the single-process flow.tcl already
wrote 3_place.sdc / 6_final.sdc directly. Retire the copy-forward
special case so SDC production is uniform and co-located with the .odb
write, mirroring how synth writes 1_synth.sdc alongside 1_synth.odb.

- detail_place.tcl writes 3_place.sdc after 3_5_place_dp.odb
- final_report.tcl writes 6_final.sdc after 6_final.odb (after the
  orfs_* procs are in scope, i.e. after final_connect.tcl)
- Makefile: drop the two do-copy .sdc recipes; tie each aggregate .sdc
  to the step that now writes it via a recipe-less order rule
  (3_place.sdc: 3_5_place_dp.odb ; 6_final.sdc: 6_report.log), the same
  shape as the existing 1_synth.sdc: 1_synth.odb rule
- flow.tcl: move the single-process 6_final.sdc write to just after the
  6_final.odb write so both flows write it from identical design state,
  preserving the final-stage byte-equivalence invariant

Constraints do not change during placement or finishing, so the
serialized SDC is unchanged: on nangate45/gcd the new 3_place.sdc and
6_final.sdc are byte-identical (constraints) to the files the do-copy
previously produced.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
oharboe added a commit to oharboe/OpenROAD-flow-scripts that referenced this pull request Jul 14, 2026
The recipe-less .sdc order rules relied on the .sdc being produced as a
side-effect of building the prerequisite .odb/.log. If the .sdc alone is
deleted while the prerequisite is up-to-date, GNU Make runs no recipe
and leaves it missing, so downstream steps (e.g. CTS reading 3_place.sdc)
fail. Add a recovery recipe that removes and rebuilds the prerequisite
when the target is absent, forcing the side-effect .sdc to regenerate.

Addresses gemini-code-assist review feedback on The-OpenROAD-Project#4353.

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
@oharboe

oharboe commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator Author

/gemini review

@oharboe
oharboe force-pushed the place-final-self-write-sdc branch 2 times, most recently from 47c6275 to 3173fd8 Compare July 14, 2026 11:33

@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 updates the flow to write SDC constraints directly during the detail placement and final report steps, rather than copying them from previous steps. It also introduces Makefile rules to regenerate these SDC files if they are deleted while their corresponding target files are up-to-date. The feedback suggests replacing raw $(MAKE) calls in these new Makefile rules with $(UNSET_AND_MAKE) to ensure proper environment cleanup and argument forwarding.

I am having trouble creating individual review comments. Click here to see my feedback.

flow/Makefile (484-485)

medium

Using raw $(MAKE) directly bypasses the UNSET_VARS environment cleanup and command-line argument escaping/forwarding logic defined in UNSET_AND_MAKE and SUB_MAKE. This can lead to subtle bugs or environment contamination, especially in hierarchical or containerized/sandboxed flows. Please use $(UNSET_AND_MAKE) instead.

$(RESULTS_DIR)/3_place.sdc: $(RESULTS_DIR)/3_5_place_dp.odb
	@if [ ! -f $@ ]; then rm -f $<; $(UNSET_AND_MAKE) $<; fi

flow/Makefile (628-629)

medium

Using raw $(MAKE) directly bypasses the UNSET_VARS environment cleanup and command-line argument escaping/forwarding logic defined in UNSET_AND_MAKE and SUB_MAKE. This can lead to subtle bugs or environment contamination, especially in hierarchical or containerized/sandboxed flows. Please use $(UNSET_AND_MAKE) instead.

$(RESULTS_DIR)/6_final.sdc: $(LOG_DIR)/6_report.log
	@if [ ! -f $@ ]; then rm -f $<; $(UNSET_AND_MAKE) $<; fi

@oharboe
oharboe requested a review from maliberty July 14, 2026 11:37
@oharboe

oharboe commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator Author

@gemini-code-assist Thanks — but we're intentionally leaving the recipe-less 3_place.sdc: 3_5_place_dp.odb and 6_final.sdc: 6_report.log rules as-is. They match the existing 1_synth.sdc: 1_synth.odb rule already in this Makefile, where the .sdc is likewise a side-effect of the step that writes the .odb. Adding a @if [ ! -f $@ ]; then rm -f $<; $(MAKE) $<; fi recovery recipe to these two and not to the synth rule would be incongruent, and the recursive-make hop adds cognitive load for a case that doesn't arise in the flow (the clean targets remove each stage's .odb/.sdc group together).

There's no such thing as a perfectly-correct Makefile. Bazel covers every base — missing-output recovery included — but that completeness comes at a real cognitive cost. Make doesn't cover every base, and we accept that: the payoff is that a reader can follow it. Congruence with the surrounding rules and lower cognitive load win here over guarding a pathological hand-deletion.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

That is a fair point, and I agree with your assessment. Prioritizing the readability and consistency of the Makefile over adding complex recovery logic for edge cases is a sound engineering decision, especially when the current flow already handles these dependencies effectively through its clean targets. Maintaining a clean, predictable Makefile structure is often more valuable for long-term maintainability than achieving absolute, bulletproof recovery for every possible manual intervention.

@oharboe

oharboe commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator Author

@maliberty Gemini didn't like its own suggestions (it failed above to apply them as comments on a second pass). Funny.

Gemini(any LLM) is prone to fuzzing: pass in a modified PR and you get a different result, hence you can't get all review comments on first try, you have to hope that it converges...

@oharboe

oharboe commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator Author

/gemini review

@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 updates the flow to write SDC files directly during the detailed placement and final report steps instead of copying them from previous steps in the Makefile. Specifically, 3_place.sdc is now written by detail_place.tcl and 6_final.sdc is written by final_report.tcl. The Makefile has been updated to reflect these new dependencies and targets, and flow.tcl was adjusted to write 6_final.sdc at the correct step. I have no feedback to provide as there are no review comments.

@oharboe

oharboe commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator Author

@maliberty It is perhaps possible to configure Gemini with some instructions to converge on PR reviews by modifying instructions, rather than use a modified PR as a fuzzed input to the review process, thus converging faster(and perhaps missing out on some review feedback). Less maddening though. 😅

@oharboe

oharboe commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator Author

@maliberty I think this is a failure on master, not this PR.

@oharboe

oharboe commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator Author

@maliberty pr-merge green, ready for review. Never mind pr-head.

@maliberty
maliberty requested review from eder-matheus and removed request for maliberty July 15, 2026 22:36
@oharboe

oharboe commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator Author

@eder-matheus Ping? pr-merge is green.

@eder-matheus
eder-matheus merged commit efb9eed into The-OpenROAD-Project:master Jul 16, 2026
7 of 8 checks passed
@oharboe

oharboe commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator Author

🥳

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.

2 participants