liberty attributes after cells resolves #400

Signed-off-by: James Cherry <cherry@parallaxsw.com>
This commit is contained in:
James Cherry 2026-03-08 10:21:55 -07:00
parent 3b61817f90
commit 274637ce46
2 changed files with 57 additions and 56 deletions

View File

@ -78,8 +78,7 @@ LibertyReader::LibertyReader(const char *filename,
debug_(network->debug()), debug_(network->debug()),
network_(network), network_(network),
builder_(debug_, report_), builder_(debug_, report_),
library_(nullptr), library_(nullptr)
first_cell_(true)
{ {
defineVisitors(); defineVisitors();
} }
@ -148,13 +147,13 @@ LibertyReader::beginLibrary(const LibertyGroup *library_group,
} }
void void
LibertyReader::endLibrary(const LibertyGroup *group, LibertyReader::endLibrary(const LibertyGroup *library_group,
LibertyGroup *) LibertyGroup *)
{ {
// If a library hasno cells endCell is not called. // If a library has no cells endCell is not called.
if (first_cell_) readLibraryAttributes(library_group);
readLibraryAttributes(group); checkThresholds(library_group);
delete group; delete library_group;
} }
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
@ -167,12 +166,7 @@ LibertyReader::endCell(const LibertyGroup *cell_group,
// Normally they are all defined by the first cell, but there // Normally they are all defined by the first cell, but there
// are libraries that define table templates and bus tyupes // are libraries that define table templates and bus tyupes
// between cells. // between cells.
if (first_cell_) readLibraryAttributes(library_group);
readLibraryAttributes(library_group);
else {
readTableTemplates(library_group);
readBusTypes(nullptr, library_group);
}
const char *name = cell_group->firstName(); const char *name = cell_group->firstName();
if (name) { if (name) {
@ -182,8 +176,10 @@ LibertyReader::endCell(const LibertyGroup *cell_group,
} }
else else
libWarn(1193, cell_group, "cell missing name."); libWarn(1193, cell_group, "cell missing name.");
// Delete the cell group and preceding library attributes
// and groups so they are not revisited and reduce memory peak.
library_group->clear(); library_group->clear();
first_cell_ = false;
} }
void void
@ -527,21 +523,25 @@ LibertyReader::readThresholds(const LibertyGroup *library_group)
std::string suffix = rf->to_string(); std::string suffix = rf->to_string();
readLibAttrFloat(library_group, ("input_threshold_pct_" + suffix).c_str(), readLibAttrFloat(library_group, ("input_threshold_pct_" + suffix).c_str(),
&LibertyLibrary::setInputThreshold, rf, 0.01F); &LibertyLibrary::setInputThreshold, rf, 0.01F);
if (library_->inputThreshold(rf) == 0.0)
libWarn(1145, library_group, "input_threshold_pct_%s not found.", rf->name());
readLibAttrFloat(library_group, ("output_threshold_pct_" + suffix).c_str(), readLibAttrFloat(library_group, ("output_threshold_pct_" + suffix).c_str(),
&LibertyLibrary::setOutputThreshold, rf, 0.01F); &LibertyLibrary::setOutputThreshold, rf, 0.01F);
if (library_->outputThreshold(rf) == 0.0)
libWarn(1146, library_group, "output_threshold_pct_%s not found.", rf->name());
readLibAttrFloat(library_group, ("slew_lower_threshold_pct_" + suffix).c_str(), readLibAttrFloat(library_group, ("slew_lower_threshold_pct_" + suffix).c_str(),
&LibertyLibrary::setSlewLowerThreshold, rf, 0.01F); &LibertyLibrary::setSlewLowerThreshold, rf, 0.01F);
if (library_->slewLowerThreshold(rf) == 0.0)
libWarn(1147, library_group, "slew_lower_threshold_pct_%s not found.", rf->name());
readLibAttrFloat(library_group, ("slew_upper_threshold_pct_" + suffix).c_str(), readLibAttrFloat(library_group, ("slew_upper_threshold_pct_" + suffix).c_str(),
&LibertyLibrary::setSlewUpperThreshold, rf, 0.01F); &LibertyLibrary::setSlewUpperThreshold, rf, 0.01F);
}
}
void
LibertyReader::checkThresholds(const LibertyGroup *library_group) const
{
for (const RiseFall *rf : RiseFall::range()) {
if (library_->inputThreshold(rf) == 0.0)
libWarn(1145, library_group, "input_threshold_pct_%s not found.", rf->name());
if (library_->outputThreshold(rf) == 0.0)
libWarn(1146, library_group, "output_threshold_pct_%s not found.", rf->name());
if (library_->slewLowerThreshold(rf) == 0.0)
libWarn(1147, library_group, "slew_lower_threshold_pct_%s not found.", rf->name());
if (library_->slewUpperThreshold(rf) == 0.0) if (library_->slewUpperThreshold(rf) == 0.0)
libWarn(1148, library_group, "slew_upper_threshold_pct_%s not found.", rf->name()); libWarn(1148, library_group, "slew_upper_threshold_pct_%s not found.", rf->name());
} }
@ -3458,37 +3458,37 @@ LibertyReader::variableValue(const char *var,
void void
LibertyReader::libWarn(int id, LibertyReader::libWarn(int id,
const LibertyGroup *obj, const LibertyGroup *group,
const char *fmt, const char *fmt,
...) ...) const
{ {
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
report_->vfileWarn(id, filename_, obj->line(), fmt, args); report_->vfileWarn(id, filename_, group->line(), fmt, args);
va_end(args); va_end(args);
} }
void void
LibertyReader::libWarn(int id, LibertyReader::libWarn(int id,
const LibertySimpleAttr *obj, const LibertySimpleAttr *attr,
const char *fmt, const char *fmt,
...) ...) const
{ {
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
report_->vfileWarn(id, filename_, obj->line(), fmt, args); report_->vfileWarn(id, filename_, attr->line(), fmt, args);
va_end(args); va_end(args);
} }
void void
LibertyReader::libWarn(int id, LibertyReader::libWarn(int id,
const LibertyComplexAttr *obj, const LibertyComplexAttr *attr,
const char *fmt, const char *fmt,
...) ...) const
{ {
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
report_->vfileWarn(id, filename_, obj->line(), fmt, args); report_->vfileWarn(id, filename_, attr->line(), fmt, args);
va_end(args); va_end(args);
} }
@ -3496,7 +3496,7 @@ void
LibertyReader::libWarn(int id, LibertyReader::libWarn(int id,
int line, int line,
const char *fmt, const char *fmt,
...) ...) const
{ {
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
@ -3506,37 +3506,37 @@ LibertyReader::libWarn(int id,
void void
LibertyReader::libError(int id, LibertyReader::libError(int id,
const LibertyGroup *obj, const LibertyGroup *group,
const char *fmt, const char *fmt,
...) ...) const
{ {
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
report_->vfileError(id, filename_, obj->line(), fmt, args); report_->vfileError(id, filename_, group->line(), fmt, args);
va_end(args); va_end(args);
} }
void void
LibertyReader::libError(int id, LibertyReader::libError(int id,
const LibertySimpleAttr *obj, const LibertySimpleAttr *attr,
const char *fmt, const char *fmt,
...) ...) const
{ {
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
report_->vfileError(id, filename_, obj->line(), fmt, args); report_->vfileError(id, filename_, attr->line(), fmt, args);
va_end(args); va_end(args);
} }
void void
LibertyReader::libError(int id, LibertyReader::libError(int id,
const LibertyComplexAttr *obj, const LibertyComplexAttr *attr,
const char *fmt, const char *fmt,
...) ...) const
{ {
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
report_->vfileError(id, filename_, obj->line(), fmt, args); report_->vfileError(id, filename_, attr->line(), fmt, args);
va_end(args); va_end(args);
} }

View File

@ -24,6 +24,7 @@
#pragma once #pragma once
#include <cstdarg>
#include <functional> #include <functional>
#include <memory> #include <memory>
#include <array> #include <array>
@ -132,6 +133,7 @@ protected:
const char *group_name, const char *group_name,
TableTemplateType type); TableTemplateType type);
void readThresholds(const LibertyGroup *library_group); void readThresholds(const LibertyGroup *library_group);
void checkThresholds(const LibertyGroup *library_group) const;
TableAxisPtr makeTableTemplateAxis(const LibertyGroup *template_group, TableAxisPtr makeTableTemplateAxis(const LibertyGroup *template_group,
int axis_index); int axis_index);
void readVoltateMaps(const LibertyGroup *library_group); void readVoltateMaps(const LibertyGroup *library_group);
@ -445,36 +447,36 @@ protected:
const LibertyCell *cell, const LibertyCell *cell,
int line); int line);
void libWarn(int id, void libWarn(int id,
const LibertyGroup *obj, const LibertyGroup *group,
const char *fmt, const char *fmt,
...) ...) const
__attribute__((format (printf, 4, 5))); __attribute__((format (printf, 4, 5)));
void libWarn(int id, void libWarn(int id,
const LibertySimpleAttr *obj, const LibertySimpleAttr *attr,
const char *fmt, const char *fmt,
...) ...) const
__attribute__((format (printf, 4, 5))); __attribute__((format (printf, 4, 5)));
void libWarn(int id, void libWarn(int id,
const LibertyComplexAttr *obj, const LibertyComplexAttr *attr,
const char *fmt, const char *fmt,
...) ...) const
__attribute__((format (printf, 4, 5))); __attribute__((format (printf, 4, 5)));
void libWarn(int id, void libWarn(int id,
int line, int line,
const char *fmt, const char *fmt,
...) ...) const
__attribute__((format (printf, 4, 5))); __attribute__((format (printf, 4, 5)));
void libError(int id, void libError(int id,
const LibertyGroup *obj, const LibertyGroup *group,
const char *fmt, ...) const char *fmt, ...) const
__attribute__((format (printf, 4, 5))); __attribute__((format (printf, 4, 5)));
void libError(int id, void libError(int id,
const LibertySimpleAttr *obj, const LibertySimpleAttr *attr,
const char *fmt, ...) const char *fmt, ...) const
__attribute__((format (printf, 4, 5))); __attribute__((format (printf, 4, 5)));
void libError(int id, void libError(int id,
const LibertyComplexAttr *obj, const LibertyComplexAttr *attr,
const char *fmt, ...) const char *fmt, ...) const
__attribute__((format (printf, 4, 5))); __attribute__((format (printf, 4, 5)));
const char *filename_; const char *filename_;
@ -485,7 +487,6 @@ protected:
LibertyBuilder builder_; LibertyBuilder builder_;
LibertyVariableMap var_map_; LibertyVariableMap var_map_;
LibertyLibrary *library_; LibertyLibrary *library_;
bool first_cell_;
LibraryGroupVisitorMap group_begin_map_; LibraryGroupVisitorMap group_begin_map_;
LibraryGroupVisitorMap group_end_map_; LibraryGroupVisitorMap group_end_map_;