Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/gui/src/staGuiInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ int ClockTree::getMaxLeaves(bool visibility = false) const

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.

if (!visibility or isVisible()) {
for (const auto& [driver, arrival] : drivers_) {
minimum = std::min(minimum, arrival);
Expand All @@ -700,7 +700,7 @@ sta::Delay ClockTree::getMinimumArrival(bool visibility = false) const

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.

if (!visibility or isVisible()) {
for (const auto& [driver, arrival] : drivers_) {
maximum = std::max(maximum, arrival);
Expand All @@ -722,7 +722,7 @@ sta::Delay ClockTree::getMaximumArrival(bool visibility = false) const

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.

if (!visibility or isVisible()) {
if (parent_ != nullptr) {
for (const auto& [driver, arrival] : drivers_) {
Expand Down
Loading