Skip to content

Commit b49da82

Browse files
committed
gpl: clamp virtual_cts_max_skew_fraction to [0,1]
Signed-off-by: Eder Monteiro <emrmonteiro@precisioninno.com>
1 parent 4a8979a commit b49da82

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/gpl/src/replace.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,19 @@ bool Replace::initNesterovPlace(const PlaceOptions& options,
321321
}
322322

323323
if (!cb_ && options.virtualCtsMode) {
324+
float skew_fraction = options.virtualCtsMaxSkewFraction;
325+
// Clamp to a sane range; a negative value yields negative insertion
326+
// delays and values above the clock period make no physical sense.
327+
if (skew_fraction < 0.0f || skew_fraction > 1.0f) {
328+
log_->warn(GPL,
329+
165,
330+
"virtual_cts_max_skew_fraction {} out of range [0, 1]; "
331+
"clamping.",
332+
skew_fraction);
333+
skew_fraction = std::clamp(skew_fraction, 0.0f, 1.0f);
334+
}
324335
cb_ = std::make_shared<ClockBase>(sta_, db_, log_);
325-
cb_->setMaxSkewFraction(options.virtualCtsMaxSkewFraction);
336+
cb_->setMaxSkewFraction(skew_fraction);
326337
}
327338

328339
if (!np_) {

0 commit comments

Comments
 (0)