GUI: replace sta::Delay with float for numeric_limits#10066
Conversation
Signed-off-by: luis201420 <luisemv@precisioninno.com>
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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.
| sta::Delay maximum = std::numeric_limits<float>::min(); | |
| sta::Delay maximum = -sta::INF; |
References
- 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(); |
There was a problem hiding this comment.
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).
| sta::Delay minimum = std::numeric_limits<float>::max(); | |
| sta::Delay minimum = sta::INF; |
References
- 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(); |
There was a problem hiding this comment.
|
clang-tidy review says "All clean, LGTM! 👍" |
Summary
Replacing
sta::Delaywithfloatfornumeric_limits, sincesta::Delayis not a primitive class, causes themin()andmax()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 classDelay.Type of Change
Impact
It enables the visualization of clock trees in the GUI.
Verification
./etc/Build.sh).