From 46d2446f88904a2a4c47ddb814fa1950cb89b726 Mon Sep 17 00:00:00 2001 From: James Cherry Date: Thu, 9 Jul 2020 08:42:52 -0700 Subject: [PATCH] LibertyCell::isInverter --- include/sta/Liberty.hh | 3 +++ liberty/Liberty.cc | 21 +++++++++++++++++++++ search/Property.cc | 2 ++ 3 files changed, 26 insertions(+) diff --git a/include/sta/Liberty.hh b/include/sta/Liberty.hh index 5818e4bb..c7f374b4 100644 --- a/include/sta/Liberty.hh +++ b/include/sta/Liberty.hh @@ -493,6 +493,7 @@ public: Report *report, Debug *debug); bool isBuffer() const; + bool isInverter() const; // Only valid when isBuffer() returns true. void bufferPorts(// Return values. LibertyPort *&input, @@ -522,6 +523,8 @@ protected: void makeTimingArcPortMaps(); bool hasBufferFunc(const LibertyPort *input, const LibertyPort *output) const; + bool hasInverterFunc(const LibertyPort *input, + const LibertyPort *output) const; LibertyLibrary *liberty_library_; float area_; diff --git a/liberty/Liberty.cc b/liberty/Liberty.cc index 38a64706..efb7919d 100644 --- a/liberty/Liberty.cc +++ b/liberty/Liberty.cc @@ -1064,6 +1064,27 @@ LibertyCell::hasBufferFunc(const LibertyPort *input, && func->port() == input; } +bool +LibertyCell::isInverter() const +{ + LibertyPort *input; + LibertyPort *output; + bufferPorts(input, output); + return input && output + && hasInverterFunc(input, output); +} + +bool +LibertyCell::hasInverterFunc(const LibertyPort *input, + const LibertyPort *output) const +{ + FuncExpr *func = output->function(); + return func + && func->op() == FuncExpr::op_not + && func->left()->op() == FuncExpr::op_port + && func->left()->port() == input; +} + void LibertyCell::bufferPorts(// Return values. LibertyPort *&input, diff --git a/search/Property.cc b/search/Property.cc index 0a840dfa..d69bd3f1 100644 --- a/search/Property.cc +++ b/search/Property.cc @@ -566,6 +566,8 @@ getProperty(const LibertyCell *cell, return PropertyValue(cell->libertyLibrary()); else if (stringEqual(property, "is_buffer")) return PropertyValue(cell->isBuffer()); + else if (stringEqual(property, "is_inverter")) + return PropertyValue(cell->isInverter()); else if (stringEqual(property, "dont_use")) return PropertyValue(cell->dontUse()); else