diff --git a/CMakeLists.txt b/CMakeLists.txt index db103b6f..a361a3be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -233,7 +233,6 @@ set(STA_TCL_FILES tcl/Util.tcl tcl/CmdArgs.tcl tcl/CmdUtil.tcl - tcl/Link.tcl tcl/Property.tcl tcl/Sta.tcl tcl/Splash.tcl @@ -241,6 +240,7 @@ set(STA_TCL_FILES dcalc/DelayCalc.tcl graph/Graph.tcl liberty/Liberty.tcl + network/Link.tcl network/Network.tcl network/NetworkEdit.tcl parasitics/Parasitics.tcl @@ -436,8 +436,8 @@ set(SWIG_FILES ${STA_HOME}/search/Search.i ${STA_HOME}/spice/WriteSpice.i ${STA_HOME}/tcl/Exception.i - ${STA_HOME}/tcl/StaTcl.i ${STA_HOME}/tcl/StaTclTypes.i + ${STA_HOME}/util/Util.i ${STA_HOME}/verilog/Verilog.i ) diff --git a/app/StaApp.i b/app/StaApp.i index 7bfb257f..dfb0f3b7 100644 --- a/app/StaApp.i +++ b/app/StaApp.i @@ -18,7 +18,6 @@ %include "tcl/Exception.i" %include "tcl/StaTclTypes.i" -%include "tcl/StaTcl.i" %include "dcalc/DelayCalc.i" %include "graph/Graph.i" %include "liberty/Liberty.i" @@ -29,5 +28,6 @@ %include "sdc/Sdc.i" %include "sdf/Sdf.i" %include "search/Search.i" +%include "util/Util.i" %include "spice/WriteSpice.i" %include "verilog/Verilog.i" diff --git a/tcl/Link.tcl b/network/Link.tcl similarity index 100% rename from tcl/Link.tcl rename to network/Link.tcl diff --git a/network/NetworkEdit.i b/network/NetworkEdit.i index 7ecfbb58..ec385446 100644 --- a/network/NetworkEdit.i +++ b/network/NetworkEdit.i @@ -23,17 +23,14 @@ using sta::Net; using sta::Port; using sta::Pin; using sta::NetworkEdit; -using sta::cmdEditNetwork; + +namespace sta { +NetworkEdit * +cmdEditNetwork(); +} %} -//////////////////////////////////////////////////////////////// -// -// SWIG type definitions. -// -//////////////////////////////////////////////////////////////// - - //////////////////////////////////////////////////////////////// // // C++ functions visible as TCL functions. @@ -67,7 +64,7 @@ Net * make_net_cmd(const char *name, Instance *parent) { - Net *net = cmdEditNetwork()->makeNet(name, parent); + Net *net = sta::cmdEditNetwork()->makeNet(name, parent); // Sta notification unnecessary. return net; } diff --git a/sdc/Sdc.i b/sdc/Sdc.i index ce2425d4..909bb927 100644 --- a/sdc/Sdc.i +++ b/sdc/Sdc.i @@ -21,6 +21,7 @@ #include "Wireload.hh" #include "Clock.hh" #include "PortDelay.hh" +#include "Property.hh" #include "Sta.hh" using namespace sta; @@ -1426,6 +1427,24 @@ pin_logic_value(const Pin *pin) return logicValueString(value); } +//////////////////////////////////////////////////////////////// +// +// Variables +// +//////////////////////////////////////////////////////////////// + +bool +propagate_all_clocks() +{ + return Sta::sta()->propagateAllClocks(); +} + +void +set_propagate_all_clocks(bool prop) +{ + Sta::sta()->setPropagateAllClocks(prop); +} + %} // inline //////////////////////////////////////////////////////////////// diff --git a/search/Search.i b/search/Search.i index 94e13bbf..a5c83a20 100644 --- a/search/Search.i +++ b/search/Search.i @@ -18,11 +18,68 @@ %{ -#include "Sta.hh" +#include "Units.hh" #include "PathGroup.hh" #include "Search.hh" #include "search/Levelize.hh" #include "search/ReportPath.hh" +#include "Sta.hh" + +namespace sta { + +//////////////////////////////////////////////////////////////// +// +// C++ helper functions used by the interface functions. +// These are not visible in the TCL API. +// +//////////////////////////////////////////////////////////////// + +// Get the network for commands. +Network * +cmdNetwork() +{ + return Sta::sta()->cmdNetwork(); +} + +// Make sure the network has been read and linked. +// Throwing an error means the caller doesn't have to check the result. +Network * +cmdLinkedNetwork() +{ + Network *network = cmdNetwork(); + if (network->isLinked()) + return network; + else { + Report *report = Sta::sta()->report(); + report->error(1570, "no network has been linked."); + return nullptr; + } +} + +// Make sure an editable network has been read and linked. +NetworkEdit * +cmdEditNetwork() +{ + Network *network = cmdLinkedNetwork(); + if (network->isEditable()) + return dynamic_cast(network); + else { + Report *report = Sta::sta()->report(); + report->error(1571, "network does not support edits."); + return nullptr; + } +} + +// Get the graph for commands. +// Throw to cmd level on failure. +Graph * +cmdGraph() +{ + cmdLinkedNetwork(); + return Sta::sta()->ensureGraph(); +} + +} // namespace using namespace sta; @@ -88,6 +145,51 @@ private: int group_count_max = PathGroup::group_count_max; +//////////////////////////////////////////////////////////////// + +// Initialize sta after delete_all_memory. +void +init_sta() +{ + initSta(); +} + +void +clear_sta() +{ + Sta::sta()->clear(); +} + +void +make_sta(Tcl_Interp *interp) +{ + Sta *sta = new Sta; + Sta::setSta(sta); + sta->makeComponents(); + sta->setTclInterp(interp); +} + +Tcl_Interp * +tcl_interp() +{ + return Sta::sta()->tclInterp(); +} + +void +clear_network() +{ + Sta *sta = Sta::sta(); + sta->network()->clear(); +} + +void +delete_all_memory() +{ + deleteAllMemory(); +} + +//////////////////////////////////////////////////////////////// + void find_timing_cmd(bool full) { @@ -958,6 +1060,298 @@ find_fanout_insts(PinSeq *from, return fanout; } +//////////////////////////////////////////////////////////////// +// +// Variables +// +//////////////////////////////////////////////////////////////// + +bool +crpr_enabled() +{ + return Sta::sta()->crprEnabled(); +} + +void +set_crpr_enabled(bool enabled) +{ + return Sta::sta()->setCrprEnabled(enabled); +} + +const char * +crpr_mode() +{ + switch (Sta::sta()->crprMode()) { + case CrprMode::same_transition: + return "same_transition"; + case CrprMode::same_pin: + return "same_pin"; + default: + return ""; + } +} + +void +set_crpr_mode(const char *mode) +{ + Sta *sta = Sta::sta(); + if (stringEq(mode, "same_pin")) + Sta::sta()->setCrprMode(CrprMode::same_pin); + else if (stringEq(mode, "same_transition")) + Sta::sta()->setCrprMode(CrprMode::same_transition); + else + sta->report()->critical(1573, "unknown common clk pessimism mode."); +} + +bool +pocv_enabled() +{ + return Sta::sta()->pocvEnabled(); +} + +void +set_pocv_enabled(bool enabled) +{ +#if !SSTA + if (enabled) + Sta::sta()->report()->error(1574, "POCV support requires compilation with SSTA=1."); +#endif + return Sta::sta()->setPocvEnabled(enabled); +} + +float +pocv_sigma_factor() +{ + return Sta::sta()->sigmaFactor(); +} + +void +set_pocv_sigma_factor(float factor) +{ + Sta::sta()->setSigmaFactor(factor); +} + +bool +propagate_gated_clock_enable() +{ + return Sta::sta()->propagateGatedClockEnable(); +} + +void +set_propagate_gated_clock_enable(bool enable) +{ + Sta::sta()->setPropagateGatedClockEnable(enable); +} + +bool +preset_clr_arcs_enabled() +{ + return Sta::sta()->presetClrArcsEnabled(); +} + +void +set_preset_clr_arcs_enabled(bool enable) +{ + Sta::sta()->setPresetClrArcsEnabled(enable); +} + +bool +cond_default_arcs_enabled() +{ + return Sta::sta()->condDefaultArcsEnabled(); +} + +void +set_cond_default_arcs_enabled(bool enabled) +{ + Sta::sta()->setCondDefaultArcsEnabled(enabled); +} + +bool +bidirect_inst_paths_enabled() +{ + return Sta::sta()->bidirectInstPathsEnabled(); +} + +void +set_bidirect_inst_paths_enabled(bool enabled) +{ + Sta::sta()->setBidirectInstPathsEnabled(enabled); +} + +bool +bidirect_net_paths_enabled() +{ + return Sta::sta()->bidirectNetPathsEnabled(); +} + +void +set_bidirect_net_paths_enabled(bool enabled) +{ + Sta::sta()->setBidirectNetPathsEnabled(enabled); +} + +bool +recovery_removal_checks_enabled() +{ + return Sta::sta()->recoveryRemovalChecksEnabled(); +} + +void +set_recovery_removal_checks_enabled(bool enabled) +{ + Sta::sta()->setRecoveryRemovalChecksEnabled(enabled); +} + +bool +gated_clk_checks_enabled() +{ + return Sta::sta()->gatedClkChecksEnabled(); +} + +void +set_gated_clk_checks_enabled(bool enabled) +{ + Sta::sta()->setGatedClkChecksEnabled(enabled); +} + +bool +dynamic_loop_breaking() +{ + return Sta::sta()->dynamicLoopBreaking(); +} + +void +set_dynamic_loop_breaking(bool enable) +{ + Sta::sta()->setDynamicLoopBreaking(enable); +} + +bool +use_default_arrival_clock() +{ + return Sta::sta()->useDefaultArrivalClock(); +} + +void +set_use_default_arrival_clock(bool enable) +{ + return Sta::sta()->setUseDefaultArrivalClock(enable); +} + +//////////////////////////////////////////////////////////////// +// +// Properties +// +//////////////////////////////////////////////////////////////// + +PropertyValue +pin_property(const Pin *pin, + const char *property) +{ + cmdLinkedNetwork(); + return getProperty(pin, property, Sta::sta()); +} + +PropertyValue +instance_property(const Instance *inst, + const char *property) +{ + cmdLinkedNetwork(); + return getProperty(inst, property, Sta::sta()); +} + +PropertyValue +net_property(const Net *net, + const char *property) +{ + cmdLinkedNetwork(); + return getProperty(net, property, Sta::sta()); +} + +PropertyValue +port_property(const Port *port, + const char *property) +{ + return getProperty(port, property, Sta::sta()); +} + + +PropertyValue +liberty_cell_property(const LibertyCell *cell, + const char *property) +{ + return getProperty(cell, property, Sta::sta()); +} + +PropertyValue +cell_property(const Cell *cell, + const char *property) +{ + return getProperty(cell, property, Sta::sta()); +} + +PropertyValue +liberty_port_property(const LibertyPort *port, + const char *property) +{ + return getProperty(port, property, Sta::sta()); +} + +PropertyValue +library_property(const Library *lib, + const char *property) +{ + return getProperty(lib, property, Sta::sta()); +} + +PropertyValue +liberty_library_property(const LibertyLibrary *lib, + const char *property) +{ + return getProperty(lib, property, Sta::sta()); +} + +PropertyValue +edge_property(Edge *edge, + const char *property) +{ + cmdGraph(); + return getProperty(edge, property, Sta::sta()); +} + +PropertyValue +clock_property(Clock *clk, + const char *property) +{ + cmdLinkedNetwork(); + return getProperty(clk, property, Sta::sta()); +} + +PropertyValue +path_end_property(PathEnd *end, + const char *property) +{ + cmdLinkedNetwork(); + return getProperty(end, property, Sta::sta()); +} + +PropertyValue +path_ref_property(PathRef *path, + const char *property) +{ + cmdLinkedNetwork(); + return getProperty(path, property, Sta::sta()); +} + +PropertyValue +timing_arc_set_property(TimingArcSet *arc_set, + const char *property) +{ + cmdLinkedNetwork(); + return getProperty(arc_set, property, Sta::sta()); +} + %} // inline //////////////////////////////////////////////////////////////// diff --git a/tcl/WritePathSpice.tcl b/tcl/WritePathSpice.tcl deleted file mode 100644 index e69de29b..00000000 diff --git a/tcl/StaTcl.i b/util/Util.i similarity index 56% rename from tcl/StaTcl.i rename to util/Util.i index 3543d5f4..e149c2f6 100644 --- a/tcl/StaTcl.i +++ b/util/Util.i @@ -14,85 +14,17 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -//////////////////////////////////////////////////////////////// -// -// Define TCL methods for each network object. This works despite the -// fact that the underlying implementation does not have class methods -// corresponding to the TCL methods defined here. -// -// Note the function name changes from sta naming convention -// (lower/capitalize) to TCL naming convention (lower/underscore). -// -//////////////////////////////////////////////////////////////// - -%module sta +%module util %{ -#include "Machine.hh" + +#include "Sta.hh" #include "StaConfig.hh" // STA_VERSION #include "Stats.hh" #include "Report.hh" #include "Error.hh" #include "Fuzzy.hh" #include "Units.hh" -#include "Property.hh" -#include "Sta.hh" - -namespace sta { - -//////////////////////////////////////////////////////////////// -// -// C++ helper functions used by the interface functions. -// These are not visible in the TCL API. -// -//////////////////////////////////////////////////////////////// - -// Get the network for commands. -Network * -cmdNetwork() -{ - return Sta::sta()->cmdNetwork(); -} - -// Make sure the network has been read and linked. -// Throwing an error means the caller doesn't have to check the result. -Network * -cmdLinkedNetwork() -{ - Network *network = cmdNetwork(); - if (network->isLinked()) - return network; - else { - Report *report = Sta::sta()->report(); - report->error(1570, "no network has been linked."); - return nullptr; - } -} - -// Make sure an editable network has been read and linked. -NetworkEdit * -cmdEditNetwork() -{ - Network *network = cmdLinkedNetwork(); - if (network->isEditable()) - return dynamic_cast(network); - else { - Report *report = Sta::sta()->report(); - report->error(1571, "network does not support edits."); - return nullptr; - } -} - -// Get the graph for commands. -// Throw to cmd level on failure. -Graph * -cmdGraph() -{ - cmdLinkedNetwork(); - return Sta::sta()->ensureGraph(); -} - -} // namespace using namespace sta; @@ -100,7 +32,8 @@ using namespace sta; //////////////////////////////////////////////////////////////// // -// C++ functions visible as TCL functions. +// Empty class definitions to make swig happy. +// Private constructor/destructor so swig doesn't emit them. // //////////////////////////////////////////////////////////////// @@ -319,49 +252,6 @@ is_object_list(const char *list, return true; } -//////////////////////////////////////////////////////////////// - -// Initialize sta after delete_all_memory. -void -init_sta() -{ - initSta(); -} - -void -clear_sta() -{ - Sta::sta()->clear(); -} - -void -make_sta(Tcl_Interp *interp) -{ - Sta *sta = new Sta; - Sta::setSta(sta); - sta->makeComponents(); - sta->setTclInterp(interp); -} - -Tcl_Interp * -tcl_interp() -{ - return Sta::sta()->tclInterp(); -} - -void -clear_network() -{ - Sta *sta = Sta::sta(); - sta->network()->clear(); -} - -void -delete_all_memory() -{ - deleteAllMemory(); -} - //////////////////////////////////////////////////////////////// // // Units @@ -623,310 +513,6 @@ fall_short_name() return RiseFall::fall()->shortName(); } -//////////////////////////////////////////////////////////////// -// -// Properties -// -//////////////////////////////////////////////////////////////// - -PropertyValue -pin_property(const Pin *pin, - const char *property) -{ - cmdLinkedNetwork(); - return getProperty(pin, property, Sta::sta()); -} - -PropertyValue -instance_property(const Instance *inst, - const char *property) -{ - cmdLinkedNetwork(); - return getProperty(inst, property, Sta::sta()); -} - -PropertyValue -net_property(const Net *net, - const char *property) -{ - cmdLinkedNetwork(); - return getProperty(net, property, Sta::sta()); -} - -PropertyValue -port_property(const Port *port, - const char *property) -{ - return getProperty(port, property, Sta::sta()); -} - - -PropertyValue -liberty_cell_property(const LibertyCell *cell, - const char *property) -{ - return getProperty(cell, property, Sta::sta()); -} - -PropertyValue -cell_property(const Cell *cell, - const char *property) -{ - return getProperty(cell, property, Sta::sta()); -} - -PropertyValue -liberty_port_property(const LibertyPort *port, - const char *property) -{ - return getProperty(port, property, Sta::sta()); -} - -PropertyValue -library_property(const Library *lib, - const char *property) -{ - return getProperty(lib, property, Sta::sta()); -} - -PropertyValue -liberty_library_property(const LibertyLibrary *lib, - const char *property) -{ - return getProperty(lib, property, Sta::sta()); -} - -PropertyValue -edge_property(Edge *edge, - const char *property) -{ - cmdGraph(); - return getProperty(edge, property, Sta::sta()); -} - -PropertyValue -clock_property(Clock *clk, - const char *property) -{ - cmdLinkedNetwork(); - return getProperty(clk, property, Sta::sta()); -} - -PropertyValue -path_end_property(PathEnd *end, - const char *property) -{ - cmdLinkedNetwork(); - return getProperty(end, property, Sta::sta()); -} - -PropertyValue -path_ref_property(PathRef *path, - const char *property) -{ - cmdLinkedNetwork(); - return getProperty(path, property, Sta::sta()); -} - -PropertyValue -timing_arc_set_property(TimingArcSet *arc_set, - const char *property) -{ - cmdLinkedNetwork(); - return getProperty(arc_set, property, Sta::sta()); -} - -//////////////////////////////////////////////////////////////// -// -// Variables -// -//////////////////////////////////////////////////////////////// - -bool -crpr_enabled() -{ - return Sta::sta()->crprEnabled(); -} - -void -set_crpr_enabled(bool enabled) -{ - return Sta::sta()->setCrprEnabled(enabled); -} - -const char * -crpr_mode() -{ - switch (Sta::sta()->crprMode()) { - case CrprMode::same_transition: - return "same_transition"; - case CrprMode::same_pin: - return "same_pin"; - default: - return ""; - } -} - -void -set_crpr_mode(const char *mode) -{ - Sta *sta = Sta::sta(); - if (stringEq(mode, "same_pin")) - Sta::sta()->setCrprMode(CrprMode::same_pin); - else if (stringEq(mode, "same_transition")) - Sta::sta()->setCrprMode(CrprMode::same_transition); - else - sta->report()->critical(1573, "unknown common clk pessimism mode."); -} - -bool -pocv_enabled() -{ - return Sta::sta()->pocvEnabled(); -} - -void -set_pocv_enabled(bool enabled) -{ -#if !SSTA - if (enabled) - Sta::sta()->report()->error(1574, "POCV support requires compilation with SSTA=1."); -#endif - return Sta::sta()->setPocvEnabled(enabled); -} - -float -pocv_sigma_factor() -{ - return Sta::sta()->sigmaFactor(); -} - -void -set_pocv_sigma_factor(float factor) -{ - Sta::sta()->setSigmaFactor(factor); -} - -bool -propagate_gated_clock_enable() -{ - return Sta::sta()->propagateGatedClockEnable(); -} - -void -set_propagate_gated_clock_enable(bool enable) -{ - Sta::sta()->setPropagateGatedClockEnable(enable); -} - -bool -preset_clr_arcs_enabled() -{ - return Sta::sta()->presetClrArcsEnabled(); -} - -void -set_preset_clr_arcs_enabled(bool enable) -{ - Sta::sta()->setPresetClrArcsEnabled(enable); -} - -bool -cond_default_arcs_enabled() -{ - return Sta::sta()->condDefaultArcsEnabled(); -} - -void -set_cond_default_arcs_enabled(bool enabled) -{ - Sta::sta()->setCondDefaultArcsEnabled(enabled); -} - -bool -bidirect_inst_paths_enabled() -{ - return Sta::sta()->bidirectInstPathsEnabled(); -} - -void -set_bidirect_inst_paths_enabled(bool enabled) -{ - Sta::sta()->setBidirectInstPathsEnabled(enabled); -} - -bool -bidirect_net_paths_enabled() -{ - return Sta::sta()->bidirectNetPathsEnabled(); -} - -void -set_bidirect_net_paths_enabled(bool enabled) -{ - Sta::sta()->setBidirectNetPathsEnabled(enabled); -} - -bool -recovery_removal_checks_enabled() -{ - return Sta::sta()->recoveryRemovalChecksEnabled(); -} - -void -set_recovery_removal_checks_enabled(bool enabled) -{ - Sta::sta()->setRecoveryRemovalChecksEnabled(enabled); -} - -bool -gated_clk_checks_enabled() -{ - return Sta::sta()->gatedClkChecksEnabled(); -} - -void -set_gated_clk_checks_enabled(bool enabled) -{ - Sta::sta()->setGatedClkChecksEnabled(enabled); -} - -bool -dynamic_loop_breaking() -{ - return Sta::sta()->dynamicLoopBreaking(); -} - -void -set_dynamic_loop_breaking(bool enable) -{ - Sta::sta()->setDynamicLoopBreaking(enable); -} - -bool -use_default_arrival_clock() -{ - return Sta::sta()->useDefaultArrivalClock(); -} - -void -set_use_default_arrival_clock(bool enable) -{ - return Sta::sta()->setUseDefaultArrivalClock(enable); -} - -bool -propagate_all_clocks() -{ - return Sta::sta()->propagateAllClocks(); -} - -void -set_propagate_all_clocks(bool prop) -{ - Sta::sta()->setPropagateAllClocks(prop); -} - //////////////////////////////////////////////////////////////// bool @@ -938,6 +524,10 @@ fuzzy_equal(float value1, %} // inline -// Local Variables: -// mode:c++ -// End: +//////////////////////////////////////////////////////////////// +// +// Object Methods +// +//////////////////////////////////////////////////////////////// + +