62
62
#include < cmath>
63
63
#include < fstream>
64
64
#include < iostream>
65
+ #include < limits>
65
66
#include < map>
66
67
#include < memory>
67
68
#include < regex>
@@ -107,11 +108,21 @@ struct DelayTriple {
107
108
, maximum(maximum_sec) {}
108
109
109
110
// / @brief The minimum delay along a timing edge.
110
- double minimum;
111
+ double minimum = std::numeric_limits< double >::quiet_NaN() ;
111
112
// / @brief The typical delay along a timing edge.
112
- double typical;
113
+ double typical = std::numeric_limits< double >::quiet_NaN() ;
113
114
// / @brief The maximum delay along a timing edge.
114
- double maximum;
115
+ double maximum = std::numeric_limits<double >::quiet_NaN();
116
+
117
+ /* *
118
+ * @brief Returns true if the minimum, typical, and maximum delay values have
119
+ * been assigned a number.
120
+ *
121
+ * These values are defaulted to NaN, so this checks if the values have changed.
122
+ */
123
+ inline bool has_value () const {
124
+ return !std::isnan (minimum) && !std::isnan (typical) && !std::isnan (maximum);
125
+ }
115
126
116
127
/* *
117
128
* @brief Convert the triple into a string. This string will be of the form:
@@ -123,6 +134,9 @@ struct DelayTriple {
123
134
* print method converts the output into picoseconds.
124
135
*/
125
136
inline std::string str () const {
137
+ VTR_ASSERT_MSG (has_value (),
138
+ " Cannot create a non-initialized delay triple string" );
139
+
126
140
// Convert the delays to picoseconds for printing.
127
141
double minimum_ps = minimum * 1e12 ;
128
142
double typical_ps = typical * 1e12 ;
@@ -479,22 +493,13 @@ class LatchInst : public Instance {
479
493
}
480
494
481
495
public:
482
- // When a delay is unspecified in the constructor of this class, need to set
483
- // the delay to a value we can check for so we can ignore it when printing
484
- // the SDF file. For now, we set the triple to be all NaNs which can be
485
- // checked for when printing.
486
- // TODO: Should -1 be used instead? Is it possible for delay to be negative?
487
- static constexpr DelayTriple undefined_delay = DelayTriple(std::numeric_limits<double >::quiet_NaN(),
488
- std::numeric_limits<double >::quiet_NaN(),
489
- std::numeric_limits<double >::quiet_NaN());
490
-
491
496
LatchInst (std::string inst_name, // /<Name of this instance
492
497
std::map<std::string, std::string> port_conns, // /<Instance's port-to-net connections
493
498
Type type, // /<Type of this latch
494
499
vtr::LogicValue init_value, // /<Initial value of the latch
495
- DelayTriple tcq = undefined_delay, // /<Clock-to-Q delay
496
- DelayTriple tsu = undefined_delay, // /<Setup time
497
- DelayTriple thld = undefined_delay) // /<Hold time
500
+ DelayTriple tcq = DelayTriple(), // /<Clock-to-Q delay
501
+ DelayTriple tsu = DelayTriple(), // /<Setup time
502
+ DelayTriple thld = DelayTriple()) // /<Hold time
498
503
: instance_name_(inst_name)
499
504
, port_connections_(port_conns)
500
505
, type_(type)
@@ -570,7 +575,7 @@ class LatchInst : public Instance {
570
575
os << indent (depth + 1 ) << " (INSTANCE " << escape_sdf_identifier (instance_name_) << " )\n " ;
571
576
572
577
// Clock to Q
573
- if (! std::isnan ( tcq_delay_triple_.maximum )) {
578
+ if (tcq_delay_triple_.has_value ( )) {
574
579
os << indent (depth + 1 ) << " (DELAY\n " ;
575
580
os << indent (depth + 2 ) << " (ABSOLUTE\n " ;
576
581
os << indent (depth + 3 ) << " (IOPATH "
@@ -580,12 +585,12 @@ class LatchInst : public Instance {
580
585
}
581
586
582
587
// Setup/Hold
583
- if (! std::isnan ( tsu_delay_triple_.maximum ) || ! std::isnan ( thld_delay_triple_.maximum )) {
588
+ if (tsu_delay_triple_.has_value ( ) || thld_delay_triple_.has_value ( )) {
584
589
os << indent (depth + 1 ) << " (TIMINGCHECK\n " ;
585
- if (! std::isnan ( tsu_delay_triple_.maximum )) {
590
+ if (tsu_delay_triple_.has_value ( )) {
586
591
os << indent (depth + 2 ) << " (SETUP D (posedge clock) " << tsu_delay_triple_.str () << " )\n " ;
587
592
}
588
- if (! std::isnan ( thld_delay_triple_.maximum )) {
593
+ if (thld_delay_triple_.has_value ( )) {
589
594
os << indent (depth + 2 ) << " (HOLD D (posedge clock) " << thld_delay_triple_.str () << " )\n " ;
590
595
}
591
596
}
@@ -2346,8 +2351,8 @@ DelayTriple get_pin_tco_delay_triple(const t_pb_graph_pin& pin) {
2346
2351
DelayTriple delay_triple;
2347
2352
delay_triple.minimum = pin.tco_min ;
2348
2353
delay_triple.maximum = pin.tco_max ;
2349
- // TODO: VPR does not have typical values for delays (as far as I can tell),
2350
- // is it reasonable to take the average of min and max?
2354
+ // Since Tatum does not provide typical delays, set it to be the average
2355
+ // of min and max.
2351
2356
delay_triple.typical = (pin.tco_min + pin.tco_max ) / 2.0 ;
2352
2357
return delay_triple;
2353
2358
}
@@ -2361,8 +2366,8 @@ DelayTriple get_edge_delay_triple(tatum::EdgeId edge_id,
2361
2366
DelayTriple delay_triple;
2362
2367
delay_triple.minimum = min_edge_delay;
2363
2368
delay_triple.maximum = max_edge_delay;
2364
- // TODO: VPR does not have typical values for delays (as far as I can tell),
2365
- // is it reasonable to take the average of min and max?
2369
+ // Since Tatum does not provide typical delays, set it to be the average
2370
+ // of min and max.
2366
2371
delay_triple.typical = (min_edge_delay + max_edge_delay) / 2.0 ;
2367
2372
return delay_triple;
2368
2373
}
0 commit comments