From 8ea2580566dc303dc42b3d38d0619e3bc652283b Mon Sep 17 00:00:00 2001 From: James Cherry Date: Thu, 27 Oct 2022 15:43:47 -0700 Subject: [PATCH] power directory Signed-off-by: James Cherry --- CMakeLists.txt | 21 +++-- app/StaApp.i | 1 + {search => power}/Power.cc | 4 +- {search => power}/Power.hh | 0 power/Power.i | 124 +++++++++++++++++++++++++ {tcl => power}/Power.tcl | 0 {search => power}/ReadVcdActivities.cc | 0 {search => power}/ReadVcdActivities.hh | 0 {search => power}/Vcd.cc | 0 {search => power}/Vcd.hh | 0 {search => power}/VcdReader.cc | 0 {search => power}/VcdReader.hh | 0 search/Property.cc | 2 +- search/Sta.cc | 2 +- tcl/StaTcl.i | 78 ---------------- 15 files changed, 141 insertions(+), 91 deletions(-) rename {search => power}/Power.cc (99%) rename {search => power}/Power.hh (100%) create mode 100644 power/Power.i rename {tcl => power}/Power.tcl (100%) rename {search => power}/ReadVcdActivities.cc (100%) rename {search => power}/ReadVcdActivities.hh (100%) rename {search => power}/Vcd.cc (100%) rename {search => power}/Vcd.hh (100%) rename {search => power}/VcdReader.cc (100%) rename {search => power}/VcdReader.hh (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 02dcd3bc..6f3a1d76 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -173,9 +173,7 @@ set(STA_SOURCE search/PathRef.cc search/PathVertex.cc search/PathVertexRep.cc - search/Power.cc search/Property.cc - search/ReadVcdActivities.cc search/ReportPath.cc search/Search.cc search/SearchPred.cc @@ -184,14 +182,17 @@ set(STA_SOURCE search/StaState.cc search/Tag.cc search/TagGroup.cc - search/Vcd.cc - search/VcdReader.cc search/VertexVisitor.cc search/VisitPathEnds.cc search/VisitPathGroupVertices.cc search/WorstSlack.cc search/WritePathSpice.cc + power/Power.cc + power/ReadVcdActivities.cc + power/Vcd.cc + power/VcdReader.cc + util/Debug.cc util/DispatchQueue.cc util/Error.cc @@ -229,10 +230,10 @@ set(STA_TCL_FILES tcl/Cmds.tcl tcl/Variables.tcl tcl/Sta.tcl - tcl/Power.tcl tcl/Splash.tcl dcalc/DelayCalc.tcl parasitics/Parasitics.tcl + power/Power.tcl sdf/Sdf.tcl verilog/Verilog.tcl ) @@ -315,18 +316,20 @@ set_property(SOURCE ${STA_SWIG_FILE} -I${STA_HOME}/sdf -I${STA_HOME}/dcalc -I${STA_HOME}/parasitics + -I${STA_HOME}/power -I${STA_HOME}/verilog ) set_property(SOURCE ${STA_SWIG_FILE} PROPERTY DEPENDS + ${STA_HOME}/dcalc/DelayCalc.i + ${STA_HOME}/parasitics/Parasitics.i + ${STA_HOME}/power/Power.i + ${STA_HOME}/sdf/Sdf.i ${STA_HOME}/tcl/Exception.i ${STA_HOME}/tcl/StaTcl.i - ${STA_HOME}/verilog/Verilog.i ${STA_HOME}/tcl/NetworkEdit.i - ${STA_HOME}/sdf/Sdf.i - ${STA_HOME}/parasitics/Parasitics.i - ${STA_HOME}/dcalc/DelayCalc.i + ${STA_HOME}/verilog/Verilog.i ) swig_add_library(sta_swig diff --git a/app/StaApp.i b/app/StaApp.i index 3c8d3019..3f5efaa5 100644 --- a/app/StaApp.i +++ b/app/StaApp.i @@ -23,3 +23,4 @@ %include "Sdf.i" %include "DelayCalc.i" %include "Parasitics.i" +%include "Power.i" diff --git a/search/Power.cc b/power/Power.cc similarity index 99% rename from search/Power.cc rename to power/Power.cc index ea4e91ef..c92dcdc4 100644 --- a/search/Power.cc +++ b/power/Power.cc @@ -41,8 +41,8 @@ #include "GraphDelayCalc.hh" #include "Corner.hh" #include "PathVertex.hh" -#include "Levelize.hh" -#include "Sim.hh" +#include "search/Levelize.hh" +#include "search/Sim.hh" #include "Search.hh" #include "Bfs.hh" #include "ClkNetwork.hh" diff --git a/search/Power.hh b/power/Power.hh similarity index 100% rename from search/Power.hh rename to power/Power.hh diff --git a/power/Power.i b/power/Power.i new file mode 100644 index 00000000..7202ea38 --- /dev/null +++ b/power/Power.i @@ -0,0 +1,124 @@ +%module power + +%{ + +// OpenSTA, Static Timing Analyzer +// Copyright (c) 2022, Parallax Software, Inc. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#include "Sta.hh" +#include "power/Power.hh" +#include "power/VcdReader.hh" +#include "power/ReadVcdActivities.hh" + +namespace sta { + +typedef FloatSeq TmpFloatSeq; + +} // namespace + +using namespace sta; + +%} + +%typemap(out) TmpFloatSeq* { + FloatSeq *floats = $1; + Tcl_Obj *list = Tcl_NewListObj(0, nullptr); + if (floats) { + for (unsigned i = 0; i < floats->size(); i++) { + Tcl_Obj *obj = Tcl_NewDoubleObj((*floats)[i]); + Tcl_ListObjAppendElement(interp, list, obj); + } + delete floats; + } + Tcl_SetObjResult(interp, list); +} + +%inline %{ + +TmpFloatSeq * +design_power(const Corner *corner) +{ + cmdLinkedNetwork(); + PowerResult total, sequential, combinational, macro, pad; + Sta::sta()->power(corner, total, sequential, combinational, macro, pad); + FloatSeq *floats = new FloatSeq; + pushPowerResultFloats(total, floats); + pushPowerResultFloats(sequential, floats); + pushPowerResultFloats(combinational, floats); + pushPowerResultFloats(macro, floats); + pushPowerResultFloats(pad, floats); + return floats; +} + +TmpFloatSeq * +instance_power(Instance *inst, + const Corner *corner) +{ + cmdLinkedNetwork(); + PowerResult power; + Sta::sta()->power(inst, corner, power); + FloatSeq *floats = new FloatSeq; + floats->push_back(power.internal()); + floats->push_back(power.switching()); + floats->push_back(power.leakage()); + floats->push_back(power.total()); + return floats; +} + +void +set_power_global_activity(float activity, + float duty) +{ + Sta::sta()->power()->setGlobalActivity(activity, duty); +} + +void +set_power_input_activity(float activity, + float duty) +{ + return Sta::sta()->power()->setInputActivity(activity, duty); +} + +void +set_power_input_port_activity(const Port *input_port, + float activity, + float duty) +{ + return Sta::sta()->power()->setInputPortActivity(input_port, activity, duty); +} + +void +set_power_pin_activity(const Pin *pin, + float activity, + float duty) +{ + return Sta::sta()->power()->setUserActivity(pin, activity, duty, + PwrActivityOrigin::user); +} + +void +read_vcd_activities(const char *filename) +{ + readVcdActivities(filename, Sta::sta()); +} + +void +report_vcd_waveforms(const char *filename) +{ + reportVcdWaveforms(filename, Sta::sta()); +} + +%} // inline diff --git a/tcl/Power.tcl b/power/Power.tcl similarity index 100% rename from tcl/Power.tcl rename to power/Power.tcl diff --git a/search/ReadVcdActivities.cc b/power/ReadVcdActivities.cc similarity index 100% rename from search/ReadVcdActivities.cc rename to power/ReadVcdActivities.cc diff --git a/search/ReadVcdActivities.hh b/power/ReadVcdActivities.hh similarity index 100% rename from search/ReadVcdActivities.hh rename to power/ReadVcdActivities.hh diff --git a/search/Vcd.cc b/power/Vcd.cc similarity index 100% rename from search/Vcd.cc rename to power/Vcd.cc diff --git a/search/Vcd.hh b/power/Vcd.hh similarity index 100% rename from search/Vcd.hh rename to power/Vcd.hh diff --git a/search/VcdReader.cc b/power/VcdReader.cc similarity index 100% rename from search/VcdReader.cc rename to power/VcdReader.cc diff --git a/search/VcdReader.hh b/power/VcdReader.hh similarity index 100% rename from search/VcdReader.hh rename to power/VcdReader.hh diff --git a/search/Property.cc b/search/Property.cc index f2961f34..bad74605 100644 --- a/search/Property.cc +++ b/search/Property.cc @@ -30,7 +30,7 @@ #include "PathEnd.hh" #include "PathExpanded.hh" #include "PathRef.hh" -#include "Power.hh" +#include "power/Power.hh" #include "Sta.hh" namespace sta { diff --git a/search/Sta.cc b/search/Sta.cc index f8ed0584..45317cfe 100644 --- a/search/Sta.cc +++ b/search/Sta.cc @@ -68,7 +68,7 @@ #include "VisitPathGroupVertices.hh" #include "Genclks.hh" #include "ClkNetwork.hh" -#include "Power.hh" +#include "power/Power.hh" #include "VisitPathEnds.hh" #include "PathExpanded.hh" #include "MakeTimingModel.hh" diff --git a/tcl/StaTcl.i b/tcl/StaTcl.i index 7a261763..6887ff43 100644 --- a/tcl/StaTcl.i +++ b/tcl/StaTcl.i @@ -79,9 +79,6 @@ #include "search/CheckMinPulseWidths.hh" #include "search/Levelize.hh" #include "search/ReportPath.hh" -#include "search/Power.hh" -#include "search/VcdReader.hh" -#include "search/ReadVcdActivities.hh" namespace sta { @@ -4948,75 +4945,6 @@ report_capacitance_limit_verbose(Pin *pin, //////////////////////////////////////////////////////////////// -TmpFloatSeq * -design_power(const Corner *corner) -{ - cmdLinkedNetwork(); - PowerResult total, sequential, combinational, macro, pad; - Sta::sta()->power(corner, total, sequential, combinational, macro, pad); - FloatSeq *floats = new FloatSeq; - pushPowerResultFloats(total, floats); - pushPowerResultFloats(sequential, floats); - pushPowerResultFloats(combinational, floats); - pushPowerResultFloats(macro, floats); - pushPowerResultFloats(pad, floats); - return floats; -} - -TmpFloatSeq * -instance_power(Instance *inst, - const Corner *corner) -{ - cmdLinkedNetwork(); - PowerResult power; - Sta::sta()->power(inst, corner, power); - FloatSeq *floats = new FloatSeq; - floats->push_back(power.internal()); - floats->push_back(power.switching()); - floats->push_back(power.leakage()); - floats->push_back(power.total()); - return floats; -} - -void -set_power_global_activity(float activity, - float duty) -{ - Sta::sta()->power()->setGlobalActivity(activity, duty); -} - -void -set_power_input_activity(float activity, - float duty) -{ - return Sta::sta()->power()->setInputActivity(activity, duty); -} - -void -set_power_input_port_activity(const Port *input_port, - float activity, - float duty) -{ - return Sta::sta()->power()->setInputPortActivity(input_port, activity, duty); -} - -void -set_power_pin_activity(const Pin *pin, - float activity, - float duty) -{ - return Sta::sta()->power()->setUserActivity(pin, activity, duty, - PwrActivityOrigin::user); -} - -void -read_vcd_activities(const char *filename) -{ - readVcdActivities(filename, Sta::sta()); -} - -//////////////////////////////////////////////////////////////// - EdgeSeq * disabled_edges_sorted() { @@ -5578,12 +5506,6 @@ endpoint_count() return Sta::sta()->endpointCount(); } -void -report_vcd_waveforms(const char *filename) -{ - reportVcdWaveforms(filename, Sta::sta()); -} - %} // inline ////////////////////////////////////////////////////////////////