report_power -highest_power_instances

Signed-off-by: James Cherry <cherry@parallaxsw.com>
This commit is contained in:
James Cherry 2025-02-04 09:10:48 -08:00
parent 988514f8f4
commit 6c404a38b1
6 changed files with 43 additions and 1 deletions

Binary file not shown.

Binary file not shown.

View File

@ -321,6 +321,32 @@ Power::powerInside(const Instance *hinst,
delete child_iter;
}
typedef std::pair<Instance*, float> InstPower;
InstanceSeq
Power::highestPowerInstances(size_t count,
const Corner *corner)
{
vector<InstPower> inst_pwrs;
LeafInstanceIterator *inst_iter = network_->leafInstanceIterator();
while (inst_iter->hasNext()) {
Instance *inst = inst_iter->next();
PowerResult pwr = power(inst, corner);
inst_pwrs.push_back({inst, pwr.total()});
}
delete inst_iter;
sort(inst_pwrs.begin(), inst_pwrs.end(), [](InstPower &inst_pwr1,
InstPower &inst_pwr2) {
return inst_pwr1.second > inst_pwr2.second;
});
InstanceSeq insts;
for (size_t i = 0; i < count; i++)
insts.push_back(inst_pwrs[i].first);
return insts;
}
////////////////////////////////////////////////////////////////
class ActivitySrchPred : public SearchPredNonLatch2

View File

@ -100,6 +100,8 @@ public:
void reportActivityAnnotation(bool report_unannotated,
bool report_annotated);
float clockMinPeriod();
InstanceSeq highestPowerInstances(size_t count,
const Corner *corner);
protected:
PwrActivity &activity(const Pin *pin);

View File

@ -117,6 +117,14 @@ clock_min_period()
return power->clockMinPeriod();
}
InstanceSeq
highest_power_instances(size_t count,
const Corner *corner)
{
Power *power = Sta::sta()->power();
return power->highestPowerInstances(count, corner);
}
////////////////////////////////////////////////////////////////
void

View File

@ -32,6 +32,7 @@ namespace eval sta {
define_cmd_args "report_power" \
{ [-instances instances]\
[-highest_power_instances count]\
[-corner corner]\
[-digits digits]\
[> filename] [>> filename] }
@ -40,7 +41,7 @@ proc_redirect report_power {
global sta_report_default_digits
parse_key_args "report_power" args \
keys {-instances -corner -digits} flags {}
keys {-instances -highest_power_instances -corner -digits} flags {}
check_argc_eq0 "report_power" $args
@ -58,6 +59,11 @@ proc_redirect report_power {
if { [info exists keys(-instances)] } {
set insts [get_instances_error "-instances" $keys(-instances)]
report_power_insts $insts $corner $digits
} elseif { [info exists keys(-highest_power_instances)] } {
set count $keys(-highest_power_instances)
check_positive_integer "-highest_power_instances" $count
set insts [highest_power_instances $count $corner]
report_power_insts $insts $corner $digits
} else {
report_power_design $corner $digits
}