From ed7d2dcc36e8d418ff428a7a68eaa88c3ac62147 Mon Sep 17 00:00:00 2001 From: James Cherry Date: Tue, 19 Jan 2021 15:40:09 -0700 Subject: [PATCH] default_operating_condition allow forward ref --- liberty/LibertyReader.cc | 25 ++++++++++++++++--------- liberty/LibertyReaderPvt.hh | 1 + 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/liberty/LibertyReader.cc b/liberty/LibertyReader.cc index b571e702..1ac77ae3 100644 --- a/liberty/LibertyReader.cc +++ b/liberty/LibertyReader.cc @@ -129,7 +129,8 @@ LibertyReader::readLibertyFile(const char *filename, ocv_derate_ = nullptr; pg_port_ = nullptr; have_resistance_unit_ = false; - + default_operating_condition_ = nullptr; + for (auto rf_index : RiseFall::rangeIndex()) { have_input_threshold_[rf_index] = false; have_output_threshold_[rf_index] = false; @@ -611,6 +612,17 @@ LibertyReader::endLibraryAttrs(LibertyGroup *group) stringDelete(default_wireload_selection_); } + if (default_operating_condition_) { + OperatingConditions *op_cond = + library_->findOperatingConditions(default_operating_condition_); + if (op_cond) + library_->setDefaultOperatingConditions(op_cond); + else + libWarn(60, group, "default_operating_condition %s not found.", + default_operating_condition_); + stringDelete(default_operating_condition_); + } + bool missing_threshold = false; for (auto tr : RiseFall::range()) { int tr_index = tr->index(); @@ -1096,14 +1108,9 @@ void LibertyReader::visitDefaultOperatingConditions(LibertyAttr *attr) { if (library_) { - const char *op_cond_name = getAttrString(attr); - OperatingConditions *op_cond = - library_->findOperatingConditions(op_cond_name); - if (op_cond) - library_->setDefaultOperatingConditions(op_cond); - else - libWarn(60, attr, "default_operating_condition %s not found.", - op_cond_name); + const char *value = getAttrString(attr); + if (value) + default_operating_condition_ = stringCopy(value); } } diff --git a/liberty/LibertyReaderPvt.hh b/liberty/LibertyReaderPvt.hh index a585dc7f..b18a3863 100644 --- a/liberty/LibertyReaderPvt.hh +++ b/liberty/LibertyReaderPvt.hh @@ -580,6 +580,7 @@ protected: float energy_scale_; float distance_scale_; bool have_resistance_unit_; + const char *default_operating_condition_; static constexpr char escape_ = '\\'; private: