From bb36b3cb31920f09fe43fd83ecdcd7153a9be0e2 Mon Sep 17 00:00:00 2001 From: James Cherry Date: Thu, 13 Jan 2022 19:33:26 -0700 Subject: [PATCH] ScaleFactor enum counts Signed-off-by: James Cherry --- include/sta/Liberty.hh | 10 ++-- liberty/Liberty.cc | 10 ++-- liberty/LibertyReader.cc | 102 ++++++++++++++++++++------------------- search/Search.cc | 30 ++++++------ 4 files changed, 79 insertions(+), 73 deletions(-) diff --git a/include/sta/Liberty.hh b/include/sta/Liberty.hh index 889ad3c4..3a52c663 100644 --- a/include/sta/Liberty.hh +++ b/include/sta/Liberty.hh @@ -79,9 +79,11 @@ enum class ClockGateType { none, latch_posedge, latch_negedge, other }; enum class DelayModelType { cmos_linear, cmos_pwl, cmos2, table, polynomial, dcm }; -enum class ScaleFactorPvt { process, volt, temp, count, unknown }; +enum class ScaleFactorPvt { process, volt, temp, unknown }; +constexpr int scale_factor_pvt_count = int(ScaleFactorPvt::unknown) + 1; -enum class TableTemplateType { delay, power, output_current, ocv, count }; +enum class TableTemplateType { delay, power, output_current, ocv }; +constexpr int table_template_type_count = int(TableTemplateType::ocv) + 1; void initLiberty(); @@ -300,7 +302,7 @@ protected: Units *units_; DelayModelType delay_model_type_; BusDclMap bus_dcls_; - TableTemplateMap template_maps_[int(TableTemplateType::count)]; + TableTemplateMap template_maps_[table_template_type_count]; float nominal_process_; float nominal_voltage_; float nominal_temperature_; @@ -912,7 +914,7 @@ public: protected: const char *name_; - float scales_[scale_factor_type_count][int(ScaleFactorPvt::count)][RiseFall::index_count]; + float scales_[scale_factor_type_count][scale_factor_pvt_count][RiseFall::index_count]; private: DISALLOW_COPY_AND_ASSIGN(ScaleFactors); diff --git a/liberty/Liberty.cc b/liberty/Liberty.cc index ace8e974..e1d85b3e 100644 --- a/liberty/Liberty.cc +++ b/liberty/Liberty.cc @@ -88,7 +88,7 @@ LibertyLibrary::LibertyLibrary(const char *name, buffers_(nullptr) { // Scalar templates are builtin. - for (int i = 0; i != int(TableTemplateType::count); i++) { + for (int i = 0; i != table_template_type_count; i++) { TableTemplateType type = static_cast(i); TableTemplate *scalar_template = new TableTemplate("scalar", nullptr, nullptr, nullptr); @@ -107,7 +107,7 @@ LibertyLibrary::LibertyLibrary(const char *name, LibertyLibrary::~LibertyLibrary() { bus_dcls_.deleteContents(); - for (int i = 0; i < int(TableTemplateType::count); i++) + for (int i = 0; i < table_template_type_count; i++) template_maps_[i].deleteContents(); scale_factors_map_.deleteContents(); delete scale_factors_; @@ -2719,7 +2719,7 @@ ScaleFactors::ScaleFactors(const char *name) : name_(stringCopy(name)) { for (int type = 0; type < scale_factor_type_count; type++) { - for (int pvt = 0; pvt < int(ScaleFactorPvt::count); pvt++) { + for (int pvt = 0; pvt < scale_factor_pvt_count; pvt++) { for (auto tr_index : RiseFall::rangeIndex()) { scales_[type][pvt][tr_index] = 0.0; } @@ -2776,7 +2776,7 @@ void ScaleFactors::print() { printf("%10s", " "); - for (int pvt_index = 0; pvt_index < int(ScaleFactorPvt::count); pvt_index++) { + for (int pvt_index = 0; pvt_index < scale_factor_pvt_count; pvt_index++) { ScaleFactorPvt pvt = (ScaleFactorPvt) pvt_index; printf("%10s", scaleFactorPvtName(pvt)); } @@ -2784,7 +2784,7 @@ ScaleFactors::print() for (int type_index = 0; type_index < scale_factor_type_count; type_index++) { ScaleFactorType type = (ScaleFactorType) type_index; printf("%10s ", scaleFactorTypeName(type)); - for (int pvt_index = 0; pvt_index < int(ScaleFactorPvt::count); pvt_index++) { + for (int pvt_index = 0; pvt_index < scale_factor_pvt_count; pvt_index++) { if (scaleFactorTypeRiseFallSuffix(type) || scaleFactorTypeRiseFallPrefix(type) || scaleFactorTypeLowHighSuffix(type)) { diff --git a/liberty/LibertyReader.cc b/liberty/LibertyReader.cc index 35648b6b..94f1ccf6 100644 --- a/liberty/LibertyReader.cc +++ b/liberty/LibertyReader.cc @@ -464,7 +464,7 @@ LibertyReader::defineScalingFactorVisitors() for (int type_index = 0; type_index < scale_factor_type_count; type_index++) { ScaleFactorType type = static_cast(type_index); const char *type_name = scaleFactorTypeName(type); - for (int pvt_index = 0; pvt_index < int(ScaleFactorPvt::count); pvt_index++) { + for (int pvt_index = 0; pvt_index < scale_factor_pvt_count; pvt_index++) { ScaleFactorPvt pvt = static_cast(pvt_index); const char *pvt_name = scaleFactorPvtName(pvt); if (scaleFactorTypeRiseFallSuffix(type)) { @@ -718,57 +718,59 @@ LibertyReader::parseUnits(LibertyAttr *attr, Unit *unit) { const char *unit_str = getAttrString(attr); - unsigned unit_str_length = strlen(unit_str); + if (unit_str) { + unsigned unit_str_length = strlen(unit_str); - // Unit format is . - // Find the multiplier digits. - char *mult_str = makeTmpString(unit_str_length); - const char *s = unit_str; - char *m = mult_str; - for (; *s; s++) { - char ch = *s; - if (isdigit(ch)) - *m++ = ch; - else - break; + // Unit format is . + // Find the multiplier digits. + char *mult_str = makeTmpString(unit_str_length); + const char *s = unit_str; + char *m = mult_str; + for (; *s; s++) { + char ch = *s; + if (isdigit(ch)) + *m++ = ch; + else + break; + } + *m = '\0'; + + float mult = 1.0F; + if (*mult_str != '\0') { + if (stringEq(mult_str, "1")) + mult = 1.0F; + else if (stringEq(mult_str, "10")) + mult = 10.0F; + else if (stringEq(mult_str, "100")) + mult = 100.0F; + else + libWarn(38, attr, "unknown unit multiplier %s.", mult_str); + } + + float scale_mult = 1.0F; + if (*s && stringEqual(s + 1, unit_suffix)) { + char scale_char = tolower(*s); + if (scale_char == 'k') + scale_mult = 1E+3F; + else if (scale_char == 'm') + scale_mult = 1E-3F; + else if (scale_char == 'u') + scale_mult = 1E-6F; + else if (scale_char == 'n') + scale_mult = 1E-9F; + else if (scale_char == 'p') + scale_mult = 1E-12F; + else if (scale_char == 'f') + scale_mult = 1E-15F; + else + libWarn(39, attr, "unknown unit scale %c.", scale_char); + } + else if (!stringEqual(s, unit_suffix)) + libWarn(40, attr, "unknown unit suffix %s.", s + 1); + + scale_var = scale_mult * mult; + unit->setScale(scale_var); } - *m = '\0'; - - float mult = 1.0F; - if (*mult_str != '\0') { - if (stringEq(mult_str, "1")) - mult = 1.0F; - else if (stringEq(mult_str, "10")) - mult = 10.0F; - else if (stringEq(mult_str, "100")) - mult = 100.0F; - else - libWarn(38, attr, "unknown unit multiplier %s.", mult_str); - } - - float scale_mult = 1.0F; - if (*s && stringEqual(s + 1, unit_suffix)) { - char scale_char = tolower(*s); - if (scale_char == 'k') - scale_mult = 1E+3F; - else if (scale_char == 'm') - scale_mult = 1E-3F; - else if (scale_char == 'u') - scale_mult = 1E-6F; - else if (scale_char == 'n') - scale_mult = 1E-9F; - else if (scale_char == 'p') - scale_mult = 1E-12F; - else if (scale_char == 'f') - scale_mult = 1E-15F; - else - libWarn(39, attr, "unknown unit scale %c.", scale_char); - } - else if (!stringEqual(s, unit_suffix)) - libWarn(40, attr, "unknown unit suffix %s.", s + 1); - - scale_var = scale_mult * mult; - unit->setScale(scale_var); } void diff --git a/search/Search.cc b/search/Search.cc index bc33ce33..e1148303 100644 --- a/search/Search.cc +++ b/search/Search.cc @@ -613,20 +613,22 @@ void Search::seedFilterStarts() { ExceptionPt *first_pt = filter_->firstPt(); - PinSet first_pins; - first_pt->allPins(network_, &first_pins); - for (Pin *pin : first_pins) { - if (network_->isHierarchical(pin)) { - SeedFaninsThruHierPin visitor(graph_, this); - visitDrvrLoadsThruHierPin(pin, network_, &visitor); - } - else { - Vertex *vertex, *bidirect_drvr_vertex; - graph_->pinVertices(pin, vertex, bidirect_drvr_vertex); - if (vertex) - seedArrival(vertex); - if (bidirect_drvr_vertex) - seedArrival(bidirect_drvr_vertex); + if (first_pt) { + PinSet first_pins; + first_pt->allPins(network_, &first_pins); + for (Pin *pin : first_pins) { + if (network_->isHierarchical(pin)) { + SeedFaninsThruHierPin visitor(graph_, this); + visitDrvrLoadsThruHierPin(pin, network_, &visitor); + } + else { + Vertex *vertex, *bidirect_drvr_vertex; + graph_->pinVertices(pin, vertex, bidirect_drvr_vertex); + if (vertex) + seedArrival(vertex); + if (bidirect_drvr_vertex) + seedArrival(bidirect_drvr_vertex); + } } } }