Skip to content

GUI: replace sta::Delay with float for numeric_limits#10066

Merged
maliberty merged 1 commit into
The-OpenROAD-Project:masterfrom
luis201420:cts_fix_clock_viewer
Apr 7, 2026
Merged

GUI: replace sta::Delay with float for numeric_limits#10066
maliberty merged 1 commit into
The-OpenROAD-Project:masterfrom
luis201420:cts_fix_clock_viewer

Conversation

@luis201420

Copy link
Copy Markdown
Contributor

Summary

Replacing sta::Delay with float for numeric_limits, since sta::Delay is not a primitive class, causes the min() and max() functions ​​to both return 0. This solves the current problem of the master regarding the visualization of the clock trees.
I think the bug is integrated into the tool after updating sta, since there are modifications in class Delay.

Type of Change

  • Bug fix

Impact

It enables the visualization of clock trees in the GUI.

Verification

  • I have verified that the local build succeeds (./etc/Build.sh).
  • I have run the relevant tests and they pass.
  • My code follows the repository's formatting guidelines.
  • I have signed my commits (DCO).

Signed-off-by: luis201420 <luisemv@precisioninno.com>

@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 initialization of delay and arrival variables in src/gui/src/staGuiInterface.cpp by replacing sta::Delay limits with float limits. The review feedback correctly identifies a logic error in the maximum arrival calculation where std::numeric_limits::min() was used instead of a truly negative value, and suggests using the project-specific sta::INF constant for better consistency and correctness across all modified functions.

sta::Delay ClockTree::getMaximumArrival(bool visibility = false) const
{
sta::Delay maximum = std::numeric_limits<sta::Delay>::min();
sta::Delay maximum = std::numeric_limits<float>::min();

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

Using std::numeric_limits::min() here is a logic error. In C++, std::numeric_limits::min() for floating-point types returns the smallest positive normalized value (approximately 1.17e-38), not the most negative value.

If all arrival times are 0.0, std::max(maximum, arrival) will compare 1.17e-38 with 0.0 and keep 1.17e-38, leading to an incorrect result. To initialize a maximum search, you should use a value that is guaranteed to be less than or equal to any possible value, such as -sta::INF or std::numeric_limits::lowest(). Given the existing code style, -sta::INF is the preferred choice.

Suggested change
sta::Delay maximum = std::numeric_limits<float>::min();
sta::Delay maximum = -sta::INF;
References
  1. Define tunable parameters as named constants instead of using hardcoded magic numbers.

sta::Delay ClockTree::getMinimumArrival(bool visibility = false) const
{
sta::Delay minimum = std::numeric_limits<sta::Delay>::max();
sta::Delay minimum = std::numeric_limits<float>::max();

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.

medium

Instead of using std::numeric_limits::max(), it is more idiomatic in this codebase to use sta::INF. This constant is already used for similar purposes elsewhere in this file (e.g., lines 1027 and 1204).

Suggested change
sta::Delay minimum = std::numeric_limits<float>::max();
sta::Delay minimum = sta::INF;
References
  1. Define tunable parameters as named constants instead of using hardcoded magic numbers.

sta::Delay ClockTree::getMinimumDriverDelay(bool visibility = false) const
{
sta::Delay minimum = std::numeric_limits<sta::Delay>::max();
sta::Delay minimum = std::numeric_limits<float>::max();

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.

medium

Use sta::INF for consistency with other parts of the timing interface implementation.

Suggested change
sta::Delay minimum = std::numeric_limits<float>::max();
sta::Delay minimum = sta::INF;
References
  1. Define tunable parameters as named constants instead of using hardcoded magic numbers.

@github-actions

github-actions Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

@maliberty maliberty left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@maliberty maliberty enabled auto-merge April 7, 2026 03:35
@maliberty maliberty merged commit 29d97c4 into The-OpenROAD-Project:master Apr 7, 2026
14 of 15 checks passed
@luis201420 luis201420 deleted the cts_fix_clock_viewer branch April 7, 2026 04:12
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