From 002c4c41d206a505d24fa65a84ff12cd32b433cc Mon Sep 17 00:00:00 2001 From: James Cherry Date: Fri, 21 Nov 2025 07:46:05 -0700 Subject: [PATCH] power cell seq has precedence over test_cell resolves #331 Signed-off-by: James Cherry --- power/Power.cc | 37 +++++++++++++++++++++++++++---------- power/Power.hh | 4 ++++ 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/power/Power.cc b/power/Power.cc index 48692dea..f50fb67d 100644 --- a/power/Power.cc +++ b/power/Power.cc @@ -489,13 +489,16 @@ PropActivityVisitor::visit(Vertex *vertex) } if (network_->isDriver(pin)) { LibertyPort *port = network_->libertyPort(pin); - if (port) { - LibertyCell *test_cell = port->libertyCell()->testCell(); - if (test_cell) - port = test_cell->findLibertyPort(port->name()); - } if (port) { FuncExpr *func = port->function(); + if (func == nullptr) { + LibertyCell *test_cell = port->libertyCell()->testCell(); + if (test_cell) { + port = test_cell->findLibertyPort(port->name()); + if (port) + func = port->function(); + } + } if (func) { PwrActivity activity = power_->evalActivity(func, inst); changed = setActivityCheck(pin, activity); @@ -777,10 +780,24 @@ Power::seedRegOutputActivities(const Instance *inst, BfsFwdIterator &bfs) { LibertyCell *cell = network_->libertyCell(inst); - LibertyCell *test_cell = cell->testCell(); - const SequentialSeq &seqs = test_cell - ? test_cell->sequentials() - : cell->sequentials(); + const SequentialSeq &seqs = cell->sequentials(); + if (!seqs.empty()) + seedRegOutputActivities(inst, nullptr, seqs, bfs); + else { + LibertyCell *test_cell = cell->testCell(); + if (test_cell) { + const SequentialSeq &seqs = test_cell->sequentials(); + seedRegOutputActivities(inst, test_cell, seqs, bfs); + } + } +} + +void +Power::seedRegOutputActivities(const Instance *inst, + const LibertyCell *test_cell, + const SequentialSeq &seqs, + BfsFwdIterator &bfs) +{ for (Sequential *seq : seqs) { seedRegOutputActivities(inst, seq, seq->output(), false); seedRegOutputActivities(inst, seq, seq->outputInv(), true); @@ -791,7 +808,7 @@ Power::seedRegOutputActivities(const Instance *inst, Pin *pin = pin_iter->next(); LibertyPort *port = network_->libertyPort(pin); if (test_cell) - port = test_cell->findLibertyPort(port->name()); + port = test_cell->findLibertyPort(port->name()); if (port) { FuncExpr *func = port->function(); Vertex *vertex = graph_->pinDrvrVertex(pin); diff --git a/power/Power.hh b/power/Power.hh index 55f8a252..5c45fd60 100644 --- a/power/Power.hh +++ b/power/Power.hh @@ -191,6 +191,10 @@ protected: bool invert); void seedRegOutputActivities(const Instance *inst, BfsFwdIterator &bfs); + void seedRegOutputActivities(const Instance *inst, + const LibertyCell *test_cell, + const SequentialSeq &seqs, + BfsFwdIterator &bfs); PwrActivity evalActivity(FuncExpr *expr, const Instance *inst); PwrActivity evalActivity(FuncExpr *expr,