diff --git a/liberty/Liberty.cc b/liberty/Liberty.cc index 0eef87c4..cb4abe77 100644 --- a/liberty/Liberty.cc +++ b/liberty/Liberty.cc @@ -1029,21 +1029,11 @@ LibertyCell::setClockGateType(ClockGateType type) bool LibertyCell::isBuffer() const { - int input_count = 0; - int output_count = 0; - for (ConcretePort *cport : ports_) { - LibertyPort *port = static_cast(cport); - PortDirection *dir = port->direction(); - if (dir->isInput()) - input_count++; - else if (dir->isOutput()) - output_count++; - else if (!dir->isPowerGround()) - return false; - if (input_count > 1 || output_count > 1) - break; - } - return input_count == 1 && output_count == 1; + LibertyPort *input; + LibertyPort *output; + bufferPorts(input, output); + return input && output + && hasBufferFunc(input, output); } bool @@ -1059,19 +1049,36 @@ LibertyCell::hasBufferFunc(const LibertyPort *input, void LibertyCell::bufferPorts(// Return values. LibertyPort *&input, - LibertyPort *&output) + LibertyPort *&output) const { input = nullptr; output = nullptr; for (ConcretePort *cport : ports_) { LibertyPort *port = static_cast(cport); PortDirection *dir = port->direction(); - if (dir->isInput()) + if (dir->isInput()) { + if (input) { + // More than one input. + input = nullptr; + output = nullptr; + break; + } input = port; - else if (dir->isOutput()) + } + else if (dir->isOutput()) { + if (output) { + // More than one output. + input = nullptr; + output = nullptr; + break; + } output = port; - if (input && output) - return; + } + else if (!dir->isPowerGround()) { + input = nullptr; + output = nullptr; + break; + } } } diff --git a/liberty/Liberty.hh b/liberty/Liberty.hh index 6f45bc82..2bc16329 100644 --- a/liberty/Liberty.hh +++ b/liberty/Liberty.hh @@ -494,7 +494,7 @@ public: // Only valid when isBuffer() returns true. void bufferPorts(// Return values. LibertyPort *&input, - LibertyPort *&output); + LibertyPort *&output) const; protected: void addPort(ConcretePort *port); diff --git a/network/ConcreteNetwork.cc b/network/ConcreteNetwork.cc index 75f3cec8..5002f003 100644 --- a/network/ConcreteNetwork.cc +++ b/network/ConcreteNetwork.cc @@ -456,7 +456,19 @@ LibertyLibrary * ConcreteNetwork::findLiberty(const char *name) { ConcreteLibrary *lib = library_map_.findKey(name); - return static_cast(lib); + if (lib) { + if (lib->isLiberty()) + return static_cast(lib); + // Potential name conflict + else { + for (ConcreteLibrary *lib : library_seq_) { + if (stringEq(lib->name(), name) + && lib->isLiberty()) + return static_cast(lib); + } + } + } + return nullptr; } LibertyLibrary *