Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions include/sta/PowerClass.hh
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,22 @@ public:
PowerResult();
void clear();
float internal() const { return internal_; }
float inputinternal() const { return inputinternal_; }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the function and variable names do not follow the naming conventions.
see doc/CodiingGuidelines.txt

float outputinternal() const { return outputinternal_; }
float switching() const { return switching_; }
float leakage() const { return leakage_; }
float total() const;
void incr(PowerResult &result);
void incrInternal(float pwr);
void incrInputInternal(float pwr);
void incrOutputInternal(float pwr);
void incrSwitching(float pwr);
void incrLeakage(float pwr);

private:
float internal_;
float inputinternal_;
float outputinternal_;
float switching_;
float leakage_;
};
Expand Down
29 changes: 29 additions & 0 deletions power/Power.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,7 @@ Power::findInputInternalPower(const Pin *pin,
internal += port_internal;
}
result.incrInternal(internal);
result.incrInputInternal(internal);
}
}
}
Expand Down Expand Up @@ -1102,7 +1103,9 @@ Power::findOutputInternalPower(const LibertyPort *to_port,
FuncExpr *func = to_port->function();

map<const char*, float, StringLessIf> pg_duty_sum;
int numArcs = 0;
for (InternalPower *pwr : corner_cell->internalPowers(to_corner_port)) {
numArcs += 1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the variable does not follow the coding guidelines.
look around. you will never see "num" anything.
It should be arc_count

const LibertyPort *from_corner_port = pwr->relatedPort();
if (from_corner_port) {
const Pin *from_pin = findLinkPin(inst, from_corner_port);
Expand All @@ -1113,10 +1116,13 @@ Power::findOutputInternalPower(const LibertyPort *to_port,
pg_duty_sum[related_pg_pin] += from_density * duty;
}
}
// The number of pins that consume internal power in total
float numInternalPowerPins = numArcs / (float) pg_duty_sum.size();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no nums


debugPrint(debug_, "power", 2,
" when act/ns duty wgt energy power");
float internal = 0.0;
float out_internal = 0.0;
for (InternalPower *pwr : corner_cell->internalPowers(to_corner_port)) {
FuncExpr *when = pwr->when();
const char *related_pg_pin = pwr->relatedPgPin();
Expand Down Expand Up @@ -1157,6 +1163,7 @@ Power::findOutputInternalPower(const LibertyPort *to_port,
}
}
float port_internal = weight * energy * to_activity.density();
float avg_arc_internal = energy * to_activity.density();
debugPrint(debug_, "power", 2, "%3s -> %-3s %6s %.3f %.3f %.3f %9.2e %9.2e %s",
from_corner_port ? from_corner_port->name() : "-" ,
to_port->name(),
Expand All @@ -1168,8 +1175,13 @@ Power::findOutputInternalPower(const LibertyPort *to_port,
port_internal,
related_pg_pin ? related_pg_pin : "no pg_pin");
internal += port_internal;
out_internal += avg_arc_internal;
}
result.incrInternal(internal);
if (numInternalPowerPins)
result.incrOutputInternal(out_internal / numInternalPowerPins);
else
result.incrOutputInternal(0.0);
}

float
Expand Down Expand Up @@ -1603,6 +1615,8 @@ Power::deletePinBefore(const Pin *)

PowerResult::PowerResult() :
internal_(0.0),
inputinternal_(0.0),
outputinternal_(0.0),
switching_(0.0),
leakage_(0.0)
{
Expand All @@ -1612,6 +1626,8 @@ void
PowerResult::clear()
{
internal_ = 0.0;
inputinternal_ = 0.0;
outputinternal_ = 0.0;
switching_ = 0.0;
leakage_ = 0.0;
}
Expand All @@ -1627,6 +1643,17 @@ PowerResult::incrInternal(float pwr)
{
internal_ += pwr;
}
void
PowerResult::incrInputInternal(float pwr)
{
inputinternal_ += pwr;
}

void
PowerResult::incrOutputInternal(float pwr)
{
outputinternal_ += pwr;
}

void
PowerResult::incrSwitching(float pwr)
Expand All @@ -1644,6 +1671,8 @@ void
PowerResult::incr(PowerResult &result)
{
internal_ += result.internal_;
inputinternal_ += result.inputinternal_;
outputinternal_ += result.outputinternal_;
switching_ += result.switching_;
leakage_ += result.leakage_;
}
Expand Down
17 changes: 17 additions & 0 deletions power/Power.i
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ pushPowerResultFloats(PowerResult &power,
powers.push_back(power.leakage());
powers.push_back(power.total());
}
static void
pushInternalPowerComponents(PowerResult &power,
FloatSeq &powers)
{
powers.push_back(power.inputinternal());
powers.push_back(power.outputinternal());
}

FloatSeq
design_power(const Corner *corner)
Expand All @@ -62,6 +69,16 @@ design_power(const Corner *corner)
return powers;
}

FloatSeq
internal_power_components(const Corner *corner)
{
PowerResult total, sequential, combinational, clock, macro, pad;
Sta::sta()->power(corner, total, sequential, combinational, clock, macro, pad);
FloatSeq powers;
pushInternalPowerComponents(total, powers);
return powers;
}

FloatSeq
instance_power(Instance *inst,
const Corner *corner)
Expand Down
13 changes: 13 additions & 0 deletions power/Power.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,19 @@ proc_redirect report_power {
}
}

define_cmd_args "report_internal_power_components" { [> filename] [>> filename] }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does this require a reporting function? none of the other power types have unique reporting functions.

proc_redirect report_internal_power_components {
global sta_report_default_digits
# Set the default corner
set corner [cmd_corner]
if { ![liberty_libraries_exist] } {
sta_error 304 "No liberty libraries have been read."
}
set power_result [internal_power_components $corner]
report_line $power_result
}


proc liberty_libraries_exist {} {
set lib_iter [liberty_library_iterator]
set have_liberty 0
Expand Down