diff --git a/liberty/Liberty.cc b/liberty/Liberty.cc index 57f9f388..0eef87c4 100644 --- a/liberty/Liberty.cc +++ b/liberty/Liberty.cc @@ -1029,17 +1029,21 @@ LibertyCell::setClockGateType(ClockGateType type) bool LibertyCell::isBuffer() const { - if (ports_.size() == 2) { - LibertyPort *port1 = static_cast(ports_[0]); - LibertyPort *port2 = static_cast(ports_[1]); - return (port1->direction()->isInput() - && port2->direction()->isOutput() - && hasBufferFunc(port1, port2)) - || (port2->direction()->isInput() - && port1->direction()->isOutput() - && hasBufferFunc(port2, port1)); + 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 false; + return input_count == 1 && output_count == 1; } bool @@ -1057,17 +1061,18 @@ LibertyCell::bufferPorts(// Return values. LibertyPort *&input, LibertyPort *&output) { - LibertyPort *port1 = static_cast(ports_[0]); - LibertyPort *port2 = static_cast(ports_[1]); - if (port1->direction()->isInput() - && port2->direction()->isOutput()) { - input = port1; - output = port2; - } - else { - input = port2; - output = port1; - } + input = nullptr; + output = nullptr; + for (ConcretePort *cport : ports_) { + LibertyPort *port = static_cast(cport); + PortDirection *dir = port->direction(); + if (dir->isInput()) + input = port; + else if (dir->isOutput()) + output = port; + if (input && output) + return; + } } unsigned diff --git a/network/Network.cc b/network/Network.cc index f577034f..1c172159 100644 --- a/network/Network.cc +++ b/network/Network.cc @@ -1077,7 +1077,7 @@ LeafInstanceIterator1::LeafInstanceIterator1(const Instance *inst, child_iter_(network->childIterator(inst)), next_(nullptr) { - pending_child_iters_.reserve(512); + pending_child_iters_.reserve(8); nextInst(); } diff --git a/search/Sim.cc b/search/Sim.cc index 624a3f44..53d787a7 100644 --- a/search/Sim.cc +++ b/search/Sim.cc @@ -579,9 +579,9 @@ Sim::propagateToInvalidLoads() while (load_iter.hasNext()) { Pin *load_pin = load_iter.next(); Net *net = network_->net(load_pin); - if (network_->isGround(net)) + if (net && network_->isGround(net)) setPinValue(load_pin, LogicValue::zero, true); - else if (network_->isPower(net)) + else if (net && network_->isPower(net)) setPinValue(load_pin, LogicValue::one, true); else { Pin *drvr_pin = findDrvrPin(load_pin, network_); @@ -701,9 +701,14 @@ Sim::connectPinAfter(Pin *pin) void Sim::disconnectPinBefore(Pin *pin) { - if (incremental_ - && network_->isLoad(pin)) - removePropagatedValue(pin); + if (incremental_) { + if (network_->isLoad(pin)) { + invalid_load_pins_.insert(pin); + removePropagatedValue(pin); + } + if (network_->isDriver(pin)) + invalid_drvr_pins_.insert(pin); + } } void