internal power

This commit is contained in:
James Cherry 2020-05-01 09:40:26 -07:00
parent 77d507d0a5
commit 8b65b522fb
2 changed files with 71 additions and 68 deletions

View File

@ -117,6 +117,16 @@ public:
}
};
class StringLessIf
{
public:
bool operator()(const char *string1,
const char *string2) const
{
return stringLessIf(string1, string2);
}
};
// strdup using new instead of malloc so delete can be used on the strings.
char *
stringCopy(const char *str);

View File

@ -622,6 +622,7 @@ Power::findOutputInternalPower(const Pin *to_pin,
debugPrint0(debug_, "power", 2, " when act/ns duty wgt energy power\n");
float duty_sum = 0.0;
map<const char*, float, StringLessIf> pg_duty_sum;
for (InternalPower *pwr : *cell->internalPowers(to_port)) {
const char *related_pg_pin = pwr->relatedPgPin();
const LibertyPort *from_port = pwr->relatedPort();
@ -634,9 +635,6 @@ Power::findOutputInternalPower(const Pin *to_pin,
}
// If all the "when" clauses exist VSS internal power is ignored.
const Pin *from_pin = network_->findPin(inst, from_port);
if (from_pin
&& ((when && internalPowerMissingWhen(cell, to_port, related_pg_pin))
|| pgNameVoltage(cell, related_pg_pin, dcalc_ap) != 0.0)) {
Vertex *from_vertex = graph_->pinLoadVertex(from_pin);
float duty;
if (infered_when) {
@ -654,8 +652,7 @@ Power::findOutputInternalPower(const Pin *to_pin,
duty = 1.0;
else
duty = 0.5;
duty_sum += duty;
}
pg_duty_sum[related_pg_pin] += duty;
if (infered_when)
infered_when->deleteSubexprs();
}
@ -673,9 +670,6 @@ Power::findOutputInternalPower(const Pin *to_pin,
}
// If all the "when" clauses exist VSS internal power is ignored.
const Pin *from_pin = network_->findPin(inst, from_port);
if (from_pin
&& ((when && internalPowerMissingWhen(cell, to_port, related_pg_pin))
|| pgNameVoltage(cell, related_pg_pin, dcalc_ap) != 0.0)) {
Vertex *from_vertex = graph_->pinLoadVertex(from_pin);
float duty;
if (infered_when) {
@ -709,7 +703,7 @@ Power::findOutputInternalPower(const Pin *to_pin,
}
}
energy /= tr_count; // average non-inf energies
float weight = duty / duty_sum;
float weight = duty / pg_duty_sum[related_pg_pin];
float port_internal = weight * energy * to_activity.activity();
debugPrint9(debug_, "power", 2, " %s -> %s %6s %.2f %.2f %.2f %9.2e %9.2e %s\n",
from_port->name(),
@ -722,7 +716,6 @@ Power::findOutputInternalPower(const Pin *to_pin,
port_internal,
related_pg_pin ? related_pg_pin : "no pg_pin");
internal += port_internal;
}
if (infered_when)
infered_when->deleteSubexprs();
}