Skip to content

get_timing_edges: return a flat edge list for -of_objects - #459

Open
NopeCharon wants to merge 1 commit into
The-OpenROAD-Project:masterfrom
NopeCharon:get-timing-edges-of-objects
Open

NopeCharon wants to merge 1 commit into
The-OpenROAD-Project:masterfrom
NopeCharon:get-timing-edges-of-objects

Conversation

@NopeCharon

Copy link
Copy Markdown

Fixes #456.

get_timing_edges -of_objects built its result with lappend edges [instance_edges $inst], which adds each instance's whole edge list as one element. The command returned one nested list per instance, so the result couldn't be passed to get_property, set_disable_timing or -filter, and llength counted one edge per instance. The lib cell branch nested arc sets in the same way. Both branches now build flat lists with concat, like the other object-list helpers in tcl/CmdArgs.tcl.

The check that rejects -from/-to with -of_objects tested -from twice, so -to was silently ignored. It now tests -to too, as the command help describes.

Tests:

  • The graph goldens (and search_fanin_fanout.ok, which counts and1's edges) recorded one edge for every cell. They now show the real counts: 2 for two-input gates and 5 for DFF_X1. These count lines are the only golden changes.
  • The new graph_timing_edges_of_objects test reads from_pin, to_pin and sense from each returned edge, uses -filter, runs set_disable_timing/unset_disable_timing on the result, and checks that -of_objects with -to raises error 540. On current master it fails at the first get_property.

ctest -L tcl: everything passes once the goldens are updated, and the 13 graph and fanin/fanout tests pass after the update.

get_timing_arcs_objects collected each instance's edges with
"lappend edges [instance_edges $inst]", which appends the whole list as a
single element. get_timing_edges -of_objects therefore returned one
nested list per instance, so the result could not be passed to
get_property, set_disable_timing or -filter, and llength reported one
edge per instance. The lib cell branch nested the timing arc sets the
same way. Use concat to build flat lists, as the other object list
helpers do.

The check that rejects -from/-to with -of_objects tested -from twice,
so -to was silently ignored. Test -to as well.

The graph test goldens recorded the wrong counts (one edge for every
cell); update them to the real counts. Add
graph_timing_edges_of_objects to check that the edges can be used with
get_property, -filter and set_disable_timing, and that -to is rejected
with -of_objects.

Fixes The-OpenROAD-Project#456

Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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

Copy link
Copy Markdown

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 fixes a bug in get_timing_edges_cmd where -from was checked twice instead of checking both -from and -to when -of_objects is specified. It also flattens the returned lists of edges and arc sets in get_timing_arcs_objects by using concat instead of lappend, with corresponding updates to the test cases and a new test suite. The review feedback recommends replacing the concat operations inside loops with lappend using the expansion operator {*} to avoid O(N^2) complexity and improve performance on large designs.

Comment thread tcl/Sta.tcl
set edges {}
foreach inst $insts {
lappend edges [instance_edges $inst]
set edges [concat $edges [instance_edges $inst]]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Using concat in a loop to append elements to a list has $O(N^2)$ time complexity in Tcl because it creates a new list and copies all elements on each iteration. Since Tcl 8.5, you can use the expansion operator {*} with lappend to append elements in-place with $O(1)$ amortized complexity, which is significantly faster for large designs.

      lappend edges {*}[instance_edges $inst]

Comment thread tcl/Sta.tcl
set arc_sets {}
foreach libcell $libcells {
lappend arc_sets [$libcell timing_arc_sets]
set arc_sets [concat $arc_sets [$libcell timing_arc_sets]]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Similarly, using concat in a loop to append elements to arc_sets has $O(N^2)$ complexity. Using lappend with the expansion operator {*} is much more efficient.

      lappend arc_sets {*}[$libcell timing_arc_sets]

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.

get_timing_edges -of_objects returns nested lists and ignores -to

2 participants