From e7baf16407fbe5b4b43b8e6c5cb2c30ec25823f9 Mon Sep 17 00:00:00 2001 From: James Cherry Date: Wed, 10 May 2023 09:03:17 -0700 Subject: [PATCH] ccs bounds check Signed-off-by: James Cherry --- include/sta/TableModel.hh | 3 +++ liberty/TableModel.cc | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/sta/TableModel.hh b/include/sta/TableModel.hh index 9e4abffe..a713bfe4 100644 --- a/include/sta/TableModel.hh +++ b/include/sta/TableModel.hh @@ -462,6 +462,7 @@ public: const char *variableString() const; const Unit *unit(const Units *units); size_t size() const { return values_->size(); } + bool inBounds(float value) const; float axisValue(size_t index) const { return (*values_)[index]; } // Find the index for value such that axis[index] <= value < axis[index+1]. size_t findAxisIndex(float value) const; @@ -505,6 +506,8 @@ public: Table1 *ref_times); ~OutputWaveforms(); const RiseFall *rf() const { return rf_; } + bool inBounds(float in_slew, + float load_cap) const; Table1 voltageWaveform(float in_slew, float load_cap); float voltageTime(float in_slew, diff --git a/liberty/TableModel.cc b/liberty/TableModel.cc index 0fe68ee8..48db282a 100644 --- a/liberty/TableModel.cc +++ b/liberty/TableModel.cc @@ -1437,6 +1437,15 @@ TableAxis::~TableAxis() delete values_; } +bool +TableAxis::inBounds(float value) const +{ + size_t size = values_->size(); + return size > 1 + && value >= (*values_)[0] + && value <= (*values_)[size - 1]; +} + // Bisection search. size_t TableAxis::findAxisIndex(float value) const @@ -1613,6 +1622,14 @@ OutputWaveforms::checkAxes(TableTemplate *tbl_template) && axis3->variable() == TableAxisVariable::time); } +bool +OutputWaveforms::inBounds(float in_slew, + float load_cap) const +{ + return slew_axis_->inBounds(in_slew) + && cap_axis_->inBounds(load_cap); +} + const Table1 * OutputWaveforms::currentWaveform(float slew, float cap)