Skip to content

Commit

Permalink
timing: Add safe zero check function for delay_t
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanG077 committed Sep 18, 2024
1 parent 3aedaf1 commit 922b7d3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions common/kernel/nextpnr_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ struct PortRef
IdString port;
};

// Zero checking which works regardless if delay_t is floating or integer
inline bool is_zero_delay(delay_t delay)
{
if constexpr (std::is_floating_point<delay_t>::value) {
return std::fpclassify(delay) == FP_ZERO;
} else {
return delay == 0;
}
}

// minimum and maximum delay
struct DelayPair
{
Expand Down
4 changes: 2 additions & 2 deletions common/kernel/timing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ CriticalPath TimingAnalyser::build_critical_path_report(domain_id_t domain_pair,

if (related_clock) {
delay_t clock_delay = clock_delays.at(clock_pair);
if (clock_delay != 0) {
if (!is_zero_delay(clock_delay)) {
CriticalPath::Segment seg_c2c;
seg_c2c.type = CriticalPath::Segment::Type::CLK_TO_CLK;
seg_c2c.delay = DelayPair(clock_delay);
Expand All @@ -1005,7 +1005,7 @@ CriticalPath TimingAnalyser::build_critical_path_report(domain_id_t domain_pair,

delay_t clock_skew = clock_delay_launch - clock_delay_capture;

if (clock_skew != 0) {
if (!is_zero_delay(clock_skew)) {
CriticalPath::Segment seg_skew;
seg_skew.type = CriticalPath::Segment::Type::CLK_SKEW;
seg_skew.delay = DelayPair(clock_skew);
Expand Down

0 comments on commit 922b7d3

Please sign in to comment.