Skip to content

Commit

Permalink
write_liberty
Browse files Browse the repository at this point in the history
Signed-off-by: James Cherry <[email protected]>
  • Loading branch information
jjcherry56 committed Jun 7, 2022
1 parent 82dfa21 commit 296bc45
Show file tree
Hide file tree
Showing 9 changed files with 368 additions and 123 deletions.
2 changes: 2 additions & 0 deletions include/sta/Liberty.hh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class StaState;

typedef Set<Library*> LibrarySet;
typedef Map<const char*, TableTemplate*, CharPtrLess> TableTemplateMap;
typedef Vector<TableTemplate*> TableTemplateSeq;
typedef Map<const char*, BusDcl *, CharPtrLess> BusDclMap;
typedef Map<const char*, ScaleFactors*, CharPtrLess> ScaleFactorsMap;
typedef Map<const char*, Wireload*, CharPtrLess> WireloadMap;
Expand Down Expand Up @@ -133,6 +134,7 @@ public:
TableTemplateType type);
TableTemplate *findTableTemplate(const char *name,
TableTemplateType type);
TableTemplateSeq tableTemplates() const;
float nominalProcess() const { return nominal_process_; }
void setNominalProcess(float process);
float nominalVoltage() const { return nominal_voltage_; }
Expand Down
31 changes: 25 additions & 6 deletions include/sta/TableModel.hh
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ public:
bool pocv_enabled,
int digits,
string *result) const;
const TableModel *model() const { return model_; }

// Check the axes before making the model.
// Return true if the model axes are supported.
Expand Down Expand Up @@ -188,15 +189,20 @@ class TableModel
{
public:
TableModel(Table *table,
TableTemplate *tbl_template,
ScaleFactorType scale_factor_type,
RiseFall *rf);
~TableModel();
void setScaleFactorType(ScaleFactorType type);
int order() const;
TableTemplate *tblTemplate() const { return tbl_template_; }
TableAxis *axis1() const;
TableAxis *axis2() const;
TableAxis *axis3() const;
void setIsScaled(bool is_scaled);
float value(size_t index1,
size_t index2,
size_t index3) const;
// Table interpolated lookup.
float findValue(float value1,
float value2,
Expand Down Expand Up @@ -232,6 +238,7 @@ protected:
string *result) const;

Table *table_;
TableTemplate *tbl_template_;
// ScaleFactorType gcc barfs if this is dcl'd.
unsigned scale_factor_type_:scale_factor_bits;
unsigned tr_index_:RiseFall::index_bit_count;
Expand All @@ -250,6 +257,9 @@ public:
virtual TableAxis *axis2() const { return nullptr; }
virtual TableAxis *axis3() const { return nullptr; }
void setIsScaled(bool is_scaled);
virtual float value(size_t axis_idx1,
size_t axis_idx2,
size_t axis_idx3) const = 0;
// Table interpolated lookup.
virtual float findValue(float value1,
float value2,
Expand Down Expand Up @@ -281,6 +291,9 @@ class Table0 : public Table
public:
Table0(float value);
virtual int order() const { return 0; }
virtual float value(size_t index1,
size_t index2,
size_t index3) const;
virtual float findValue(float value1,
float value2,
float value3) const;
Expand Down Expand Up @@ -312,7 +325,10 @@ public:
virtual ~Table1();
virtual int order() const { return 1; }
virtual TableAxis *axis1() const { return axis1_; }
float tableValue(size_t index1) const;
virtual float value(size_t index1,
size_t index2,
size_t index3) const;
float value(size_t index1) const;
virtual float findValue(float value1,
float value2,
float value3) const;
Expand Down Expand Up @@ -349,8 +365,11 @@ public:
virtual int order() const { return 2; }
TableAxis *axis1() const { return axis1_; }
TableAxis *axis2() const { return axis2_; }
float tableValue(size_t index1,
size_t index2) const;
virtual float value(size_t index1,
size_t index2,
size_t index3) const;
float value(size_t index1,
size_t index2) const;
virtual float findValue(float value1,
float value2,
float value3) const;
Expand Down Expand Up @@ -392,9 +411,9 @@ public:
virtual ~Table3();
virtual int order() const { return 3; }
TableAxis *axis3() const { return axis3_; }
float tableValue(size_t index1,
size_t index2,
size_t index3) const;
virtual float value(size_t index1,
size_t index2,
size_t index3) const;
virtual float findValue(float value1,
float value2,
float value3) const;
Expand Down
4 changes: 3 additions & 1 deletion include/sta/TimingArc.hh
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ public:
void arcsFrom(const RiseFall *from_rf,
// Return values.
TimingArc *&arc1,
TimingArc *&arc2);
TimingArc *&arc2) const;
TimingArc *arcTo(const RiseFall *to_rf) const;
const TimingArcSeq &arcs() const { return arcs_; }
// Use the TimingArcSetArcIterator(arc_set) constructor instead.
TimingArcSetArcIterator *timingArcIterator() __attribute__ ((deprecated));
Expand Down Expand Up @@ -215,6 +216,7 @@ protected:
bool is_disabled_constraint_;
TimingArc *from_arc1_[RiseFall::index_count];
TimingArc *from_arc2_[RiseFall::index_count];
TimingArc *to_arc_[RiseFall::index_count];

static TimingArcSet *wire_timing_arc_set_;
};
Expand Down
13 changes: 13 additions & 0 deletions liberty/Liberty.cc
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,19 @@ LibertyLibrary::findTableTemplate(const char *name,
return template_maps_[int(type)][name];
}

TableTemplateSeq
LibertyLibrary::tableTemplates() const
{
TableTemplateSeq tbl_templates;
for (int type = 0; type < table_template_type_count; type++) {
for (auto name_template : template_maps_[type]) {
TableTemplate *tbl_template = name_template.second;
tbl_templates.push_back(tbl_template);
}
}
return tbl_templates;
}

void
LibertyLibrary::setNominalProcess(float process)
{
Expand Down
29 changes: 19 additions & 10 deletions liberty/LibertyReader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3721,7 +3721,8 @@ LibertyReader::endCellRiseFall(LibertyGroup *group)
{
if (table_) {
if (GateTableModel::checkAxes(table_)) {
TableModel *table_model = new TableModel(table_, scale_factor_type_, rf_);
TableModel *table_model = new TableModel(table_, tbl_template_,
scale_factor_type_, rf_);
timing_->setCell(rf_, table_model);
}
else {
Expand Down Expand Up @@ -3749,7 +3750,8 @@ LibertyReader::endRiseFallTransition(LibertyGroup *group)
{
if (table_) {
if (GateTableModel::checkAxes(table_)) {
TableModel *table_model = new TableModel(table_, scale_factor_type_, rf_);
TableModel *table_model = new TableModel(table_, tbl_template_,
scale_factor_type_, rf_);
timing_->setTransition(rf_, table_model);
}
else {
Expand Down Expand Up @@ -3779,7 +3781,8 @@ LibertyReader::endRiseFallConstraint(LibertyGroup *group)
{
if (table_) {
if (CheckTableModel::checkAxes(table_)) {
TableModel *table_model = new TableModel(table_, scale_factor_type_, rf_);
TableModel *table_model = new TableModel(table_, tbl_template_,
scale_factor_type_, rf_);
timing_->setConstraint(rf_, table_model);
}
else {
Expand Down Expand Up @@ -3815,7 +3818,8 @@ LibertyReader::endRiseFallTransitionDegredation(LibertyGroup *group)
{
if (table_) {
if (LibertyLibrary::checkSlewDegradationAxes(table_)) {
TableModel *table_model = new TableModel(table_, scale_factor_type_, rf_);
TableModel *table_model = new TableModel(table_, tbl_template_,
scale_factor_type_, rf_);
library_->setWireSlewDegradationTable(table_model, rf_);
}
else {
Expand Down Expand Up @@ -3911,7 +3915,7 @@ LibertyReader::visitValues(LibertyAttr *attr)

void
LibertyReader::makeTable(LibertyAttr *attr,
float scale)
float scale)
{
if (attr->isComplex()) {
makeTableAxis(0);
Expand Down Expand Up @@ -4540,7 +4544,8 @@ void
LibertyReader::endRiseFallPower(LibertyGroup *)
{
if (table_) {
TableModel *table_model = new TableModel(table_, scale_factor_type_, rf_);
TableModel *table_model = new TableModel(table_, tbl_template_,
scale_factor_type_, rf_);
internal_power_->setModel(rf_, new InternalPowerModel(table_model));
}
endTableModel();
Expand All @@ -4550,7 +4555,8 @@ void
LibertyReader::endPower(LibertyGroup *)
{
if (table_) {
TableModel *table_model = new TableModel(table_, scale_factor_type_, rf_);
TableModel *table_model = new TableModel(table_, tbl_template_,
scale_factor_type_, rf_);
// Share the model for rise/fall.
InternalPowerModel *power_model = new InternalPowerModel(table_model);
internal_power_->setModel(RiseFall::rise(), power_model);
Expand Down Expand Up @@ -4735,7 +4741,8 @@ LibertyReader::endOcvSigmaCell(LibertyGroup *group)
{
if (table_) {
if (GateTableModel::checkAxes(table_)) {
TableModel *table_model = new TableModel(table_, scale_factor_type_, rf_);
TableModel *table_model = new TableModel(table_, tbl_template_,
scale_factor_type_, rf_);
if (sigma_type_ == EarlyLateAll::all()) {
timing_->setDelaySigma(rf_, EarlyLate::min(), table_model);
timing_->setDelaySigma(rf_, EarlyLate::max(), table_model);
Expand Down Expand Up @@ -4768,7 +4775,8 @@ LibertyReader::endOcvSigmaTransition(LibertyGroup *group)
{
if (table_) {
if (GateTableModel::checkAxes(table_)) {
TableModel *table_model = new TableModel(table_, scale_factor_type_, rf_);
TableModel *table_model = new TableModel(table_, tbl_template_,
scale_factor_type_, rf_);
if (sigma_type_ == EarlyLateAll::all()) {
timing_->setSlewSigma(rf_, EarlyLate::min(), table_model);
timing_->setSlewSigma(rf_, EarlyLate::max(), table_model);
Expand Down Expand Up @@ -4801,7 +4809,8 @@ LibertyReader::endOcvSigmaConstraint(LibertyGroup *group)
{
if (table_) {
if (CheckTableModel::checkAxes(table_)) {
TableModel *table_model = new TableModel(table_, scale_factor_type_, rf_);
TableModel *table_model = new TableModel(table_, tbl_template_,
scale_factor_type_, rf_);
if (sigma_type_ == EarlyLateAll::all()) {
timing_->setConstraintSigma(rf_, EarlyLate::min(), table_model);
timing_->setConstraintSigma(rf_, EarlyLate::max(), table_model);
Expand Down
Loading

0 comments on commit 296bc45

Please sign in to comment.