From d562879a27cd730499e551a613cfa2ae7800f081 Mon Sep 17 00:00:00 2001 From: James Cherry Date: Mon, 11 May 2020 07:14:36 -0700 Subject: [PATCH] liberty bus port slew/cap/fanout limits --- include/sta/ConcreteLibrary.hh | 2 +- liberty/Liberty.cc | 3 ++- liberty/LibertyReader.cc | 42 +++++++++++++++++++++------------- liberty/LibertyReaderPvt.hh | 3 +++ 4 files changed, 32 insertions(+), 18 deletions(-) diff --git a/include/sta/ConcreteLibrary.hh b/include/sta/ConcreteLibrary.hh index 68a277a7..1ba2878a 100644 --- a/include/sta/ConcreteLibrary.hh +++ b/include/sta/ConcreteLibrary.hh @@ -217,7 +217,7 @@ protected: ConcretePort(ConcreteCell *cell, const char *name, bool is_bus, - int from_index, + int from_index, int to_index, bool is_bundle, ConcretePortSeq *member_ports); diff --git a/liberty/Liberty.cc b/liberty/Liberty.cc index 4adfbf73..99958888 100644 --- a/liberty/Liberty.cc +++ b/liberty/Liberty.cc @@ -2018,7 +2018,8 @@ LibertyPort::slewLimit(const MinMax *min_max, } void -LibertyPort::setSlewLimit(float slew, const MinMax *min_max) +LibertyPort::setSlewLimit(float slew, + const MinMax *min_max) { slew_limit_.setValue(min_max, slew); } diff --git a/liberty/LibertyReader.cc b/liberty/LibertyReader.cc index 5e325299..ec28b3ca 100644 --- a/liberty/LibertyReader.cc +++ b/liberty/LibertyReader.cc @@ -2799,9 +2799,9 @@ LibertyReader::visitDirection(LibertyAttr *attr) LibertyPortSeq::Iterator port_iter(ports_); while (port_iter.hasNext()) { LibertyPort *port = port_iter.next(); + // Tristate enable function sets direction to tristate; don't + // clobber it. if (!port->direction()->isTristate()) - // Tristate enable function sets direction to tristate; don't - // clobber it. port->setDirection(port_dir); } } @@ -2839,6 +2839,21 @@ LibertyReader::visitThreeState(LibertyAttr *attr) } } +void +LibertyReader::visitPorts(std::function func) +{ + LibertyPortSeq::Iterator port_iter(ports_); + while (port_iter.hasNext()) { + LibertyPort *port = port_iter.next(); + func(port); + LibertyPortMemberIterator member_iter(port); + while (member_iter.hasNext()) { + LibertyPort *member = member_iter.next(); + func(member); + } + } +} + void LibertyReader::visitClock(LibertyAttr *attr) { @@ -2994,11 +3009,9 @@ LibertyReader::visitFanout(LibertyAttr *attr, bool exists; getAttrFloat(attr, fanout, exists); if (exists) { - LibertyPortSeq::Iterator port_iter(ports_); - while (port_iter.hasNext()) { - LibertyPort *port = port_iter.next(); - port->setFanoutLimit(fanout, min_max); - } + visitPorts([&] (LibertyPort *port) { + port->setFanoutLimit(fanout, min_max); + }); } } } @@ -3024,11 +3037,9 @@ LibertyReader::visitMinMaxTransition(LibertyAttr *attr, MinMax *min_max) getAttrFloat(attr, value, exists); if (exists) { value *= time_scale_; - LibertyPortSeq::Iterator port_iter(ports_); - while (port_iter.hasNext()) { - LibertyPort *port = port_iter.next(); - port->setSlewLimit(value, min_max); - } + visitPorts([&] (LibertyPort *port) { + port->setSlewLimit(value, min_max); + }); } } } @@ -3056,10 +3067,9 @@ LibertyReader::visitMinMaxCapacitance(LibertyAttr *attr, if (exists) { value *= cap_scale_; LibertyPortSeq::Iterator port_iter(ports_); - while (port_iter.hasNext()) { - LibertyPort *port = port_iter.next(); - port->setCapacitanceLimit(value, min_max); - } + visitPorts([&] (LibertyPort *port) { + port->setCapacitanceLimit(value, min_max); + }); } } } diff --git a/liberty/LibertyReaderPvt.hh b/liberty/LibertyReaderPvt.hh index 097b1ca2..b9575d7b 100644 --- a/liberty/LibertyReaderPvt.hh +++ b/liberty/LibertyReaderPvt.hh @@ -16,6 +16,8 @@ #pragma once +#include + #include "DisallowCopyAssign.hh" #include "Vector.hh" #include "Map.hh" @@ -444,6 +446,7 @@ protected: const char *port_name); float defaultCap(LibertyPort *port); virtual void visitVariable(LibertyVariable *var); + void visitPorts(std::function func); const char *getAttrString(LibertyAttr *attr); void getAttrInt(LibertyAttr *attr, // Return values.