set_property

commit 36ab310762d17cf4aa3f11df636205e62db34c3a
Author: James Cherry <cherry@parallaxsw.com>
Date:   Thu May 22 08:48:28 2025 -0700

    path_ref_property -> path_property

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 5371ad1a020b223fe384ffe168fab91e762f2784
Author: James Cherry <cherry@parallaxsw.com>
Date:   Thu May 22 08:30:32 2025 -0700

    set_property

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

Signed-off-by: James Cherry <cherry@parallaxsw.com>
This commit is contained in:
James Cherry 2025-05-26 15:33:51 -07:00
parent ccf960460d
commit b2bc995160
12 changed files with 1018 additions and 633 deletions

View File

@ -36,6 +36,7 @@
%include "sdc/Sdc.i"
%include "sdf/Sdf.i"
%include "search/Search.i"
%include "search/Property.i"
%include "util/Util.i"
%include "spice/WriteSpice.i"
%include "verilog/Verilog.i"

View File

@ -12,6 +12,12 @@ build directory instead of `app/`.
The set_max_delay and set_min_delay commands now support the -probe option.
With -probe these commands do not break paths at internal (non-startpoint) pins.
The set_property command is used to annotate a user defined property
on an object. It does not change the value of built in properties. If
property names a built-in property it has no effect.
set_property [-object_type type] object property value
Release 2.6.1 2025/03/30
-------------------------

Binary file not shown.

View File

@ -24,6 +24,7 @@
#pragma once
#include <map>
#include <string>
#include "LibertyClass.hh"
@ -35,6 +36,136 @@
namespace sta {
class Sta;
class PropertyValue;
template<class TYPE>
class PropertyRegistry
{
public:
PropertyValue getProperty(TYPE inst,
const std::string property);
void setProperty(TYPE inst,
const std::string property,
PropertyValue value);
private:
std::map<std::pair<TYPE, const std::string>, PropertyValue> registry_;
};
class Properties
{
public:
Properties(Sta *sta);
PropertyValue getProperty(const Library *lib,
const std::string property);
void setProperty(const Library *lib,
const std::string property,
PropertyValue value);
PropertyValue getProperty(const LibertyLibrary *lib,
const std::string property);
void setProperty(const LibertyLibrary *lib,
const std::string property,
PropertyValue value);
PropertyValue getProperty(const Cell *cell,
const std::string property);
void setProperty(const Cell *cell,
const std::string property,
PropertyValue value);
PropertyValue getProperty(const LibertyCell *cell,
const std::string property);
void setProperty(const LibertyCell *cell,
const std::string property,
PropertyValue value);
PropertyValue getProperty(const Port *port,
const std::string property);
void setProperty(const Port *port,
const std::string property,
PropertyValue value);
PropertyValue getProperty(const LibertyPort *port,
const std::string property);
void setProperty(const LibertyPort *port,
const std::string property,
PropertyValue value);
PropertyValue getProperty(const Instance *inst,
const std::string property);
void setProperty(const Instance *inst,
const std::string property,
PropertyValue value);
PropertyValue getProperty(const Pin *pin,
const std::string property);
void setProperty(const Pin *pin,
const std::string property,
PropertyValue value);
PropertyValue getProperty(const Net *net,
const std::string property);
void setProperty(const Net *net,
const std::string property,
PropertyValue value);
PropertyValue getProperty(Edge *edge,
const std::string property);
void setProperty(Edge *edge,
const std::string property,
PropertyValue value);
PropertyValue getProperty(const Clock *clk,
const std::string property);
void setProperty(const Clock *clk,
const std::string property,
PropertyValue value);
PropertyValue getProperty(PathEnd *end,
const std::string property);
PropertyValue getProperty(Path *path,
const std::string property);
PropertyValue getProperty(TimingArcSet *arc_set,
const std::string property);
private:
PropertyValue portSlew(const Port *port,
const MinMax *min_max);
PropertyValue portSlew(const Port *port,
const RiseFall *rf,
const MinMax *min_max);
PropertyValue portSlack(const Port *port,
const MinMax *min_max);
PropertyValue portSlack(const Port *port,
const RiseFall *rf,
const MinMax *min_max);
PropertyValue pinArrival(const Pin *pin,
const RiseFall *rf,
const MinMax *min_max);
PropertyValue pinSlack(const Pin *pin,
const MinMax *min_max);
PropertyValue pinSlack(const Pin *pin,
const RiseFall *rf,
const MinMax *min_max);
PropertyValue pinSlew(const Pin *pin,
const MinMax *min_max);
PropertyValue pinSlew(const Pin *pin,
const RiseFall *rf,
const MinMax *min_max);
PropertyValue delayPropertyValue(Delay delay);
PropertyValue resistancePropertyValue(float res);
PropertyValue capacitancePropertyValue(float cap);
PropertyValue edgeDelay(Edge *edge,
const RiseFall *rf,
const MinMax *min_max);
// set_property user definied properties.
PropertyRegistry<const Library*> registry_lib_;
PropertyRegistry<const LibertyLibrary*> registry_liberty_lib_;
PropertyRegistry<const Cell*> registry_cell_;
PropertyRegistry<const LibertyCell*> registry_liberty_cell_;
PropertyRegistry<const Port*> registry_port_;
PropertyRegistry<const LibertyPort*> registry_liberty_port_;
PropertyRegistry<const Instance*> registry_inst_;
PropertyRegistry<const Pin*> registry_pin_;
PropertyRegistry<const Net*> registry_net_;
PropertyRegistry<const Edge*> registry_edge_;
PropertyRegistry<const Clock*> registry_clk_;
Sta *sta_;
};
// Adding a new property type
// value union
@ -133,74 +264,4 @@ private:
const Unit *unit_;
};
PropertyValue
getProperty(const Instance *inst,
const char *property,
Sta *sta);
PropertyValue
getProperty(const Pin *pin,
const char *property,
Sta *sta);
PropertyValue
getProperty(const Net *net,
const char *property,
Sta *sta);
PropertyValue
getProperty(const Port *port,
const char *property,
Sta *sta);
PropertyValue
getProperty(const Cell *cell,
const char *property,
Sta *sta);
PropertyValue
getProperty(const LibertyCell *cell,
const char *property,
Sta *sta);
PropertyValue
getProperty(const LibertyPort *port,
const char *property,
Sta *);
PropertyValue
getProperty(const LibertyLibrary *lib,
const char *property,
Sta *sta);
PropertyValue
getProperty(const Library *lib,
const char *property,
Sta *sta);
PropertyValue
getProperty(Edge *edge,
const char *property,
Sta *sta);
PropertyValue
getProperty(Clock *clk,
const char *property,
Sta *sta);
PropertyValue
getProperty(PathEnd *end,
const char *property,
Sta *sta);
PropertyValue
getProperty(Path *end,
const char *property,
Sta *sta);
PropertyValue
getProperty(TimingArcSet *arc_set,
const char *property,
Sta *sta);
} // namespace

View File

@ -39,6 +39,7 @@
#include "ArcDelayCalc.hh"
#include "CircuitSim.hh"
#include "Variables.hh"
#include "Property.hh"
struct Tcl_Interp;
@ -1327,6 +1328,8 @@ public:
void setUseDefaultArrivalClock(bool enable);
////////////////////////////////////////////////////////////////
Properties &properties() { return properties_; }
protected:
// Default constructors that are called by makeComponents in the Sta
// constructor. These can be redefined by a derived class to
@ -1470,6 +1473,7 @@ protected:
bool graph_sdc_annotated_;
bool parasitics_per_corner_;
bool parasitics_per_min_max_;
Properties properties_;
// Singleton sta used by tcl command interpreter.
static Sta *sta_;

View File

@ -1223,12 +1223,13 @@ filter_objects(const char *property,
Vector<T*> filtered_objects;
if (objects) {
Sta *sta = Sta::sta();
Properties &properties = sta->properties();
bool exact_match = stringEq(op, "==");
bool pattern_match = stringEq(op, "=~");
bool not_match = stringEq(op, "!=");
bool not_pattern_match = stringEq(op, "!~");
for (T *object : *objects) {
PropertyValue value(getProperty(object, property, sta));
PropertyValue value(properties.getProperty(object, property));
string prop_str = value.to_string(sta->network());
const char *prop = prop_str.c_str();
if (!prop_str.empty()

File diff suppressed because it is too large Load Diff

249
search/Property.i Normal file
View File

@ -0,0 +1,249 @@
// OpenSTA, Static Timing Analyzer
// Copyright (c) 2025, 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 <https://www.gnu.org/licenses/>.
//
// The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software.
//
// Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
//
// This notice may not be removed or altered from any source distribution.
%module properties
%{
#include "Property.hh"
#include "Sta.hh"
using namespace sta;
%}
%inline %{
PropertyValue
library_property(const Library *lib,
const char *property)
{
Properties &properties = Sta::sta()->properties();
return properties.getProperty(lib, property);
}
void
set_library_property(const Library *lib,
const char *property,
PropertyValue value)
{
Properties &properties = Sta::sta()->properties();
properties.setProperty(lib, property, value);
}
PropertyValue
liberty_library_property(const LibertyLibrary *lib,
const char *property)
{
Properties &properties = Sta::sta()->properties();
return properties.getProperty(lib, property);
}
void
set_liberty_library_property(const LibertyLibrary *lib,
const char *property,
PropertyValue value)
{
Properties &properties = Sta::sta()->properties();
properties.setProperty(lib, property, value);
}
PropertyValue
cell_property(const Cell *cell,
const char *property)
{
Properties &properties = Sta::sta()->properties();
return properties.getProperty(cell, property);
}
void
set_cell_property(const Cell *cell,
const char *property,
PropertyValue value)
{
Properties &properties = Sta::sta()->properties();
properties.setProperty(cell, property, value);
}
PropertyValue
liberty_cell_property(const LibertyCell *cell,
const char *property)
{
Properties &properties = Sta::sta()->properties();
return properties.getProperty(cell, property);
}
void
set_liberty_cell_property(const LibertyCell *cell,
const char *property,
PropertyValue value)
{
Properties &properties = Sta::sta()->properties();
properties.setProperty(cell, property, value);
}
PropertyValue
port_property(const Port *port,
const char *property)
{
Properties &properties = Sta::sta()->properties();
return properties.getProperty(port, property);
}
void
set_port_property(const Port *port,
const char *property,
PropertyValue value)
{
Properties &properties = Sta::sta()->properties();
properties.setProperty(port, property, value);
}
PropertyValue
liberty_port_property(const LibertyPort *port,
const char *property)
{
Properties &properties = Sta::sta()->properties();
return properties.getProperty(port, property);
}
void
set_liberty_port_property(const LibertyPort *port,
const char *property,
PropertyValue value)
{
Properties &properties = Sta::sta()->properties();
properties.setProperty(port, property, value);
}
PropertyValue
instance_property(const Instance *inst,
const char *property)
{
Properties &properties = Sta::sta()->properties();
return properties.getProperty(inst, property);
}
void
set_instance_property(const Instance *inst,
const char *property,
PropertyValue value)
{
Properties &properties = Sta::sta()->properties();
properties.setProperty(inst, property, value);
}
PropertyValue
pin_property(const Pin *pin,
const char *property)
{
Properties &properties = Sta::sta()->properties();
return properties.getProperty(pin, property);
}
void
set_pin_property(const Pin *pin,
const char *property,
PropertyValue value)
{
Properties &properties = Sta::sta()->properties();
properties.setProperty(pin, property, value);
}
PropertyValue
net_property(const Net *net,
const char *property)
{
Properties &properties = Sta::sta()->properties();
return properties.getProperty(net, property);
}
void
set_net_property(const Net *net,
const char *property,
PropertyValue value)
{
Properties &properties = Sta::sta()->properties();
properties.setProperty(net, property, value);
}
PropertyValue
edge_property(Edge *edge,
const char *property)
{
Properties &properties = Sta::sta()->properties();
return properties.getProperty(edge, property);
}
void
set_edge_property(Edge *edge,
const char *property,
PropertyValue value)
{
Properties &properties = Sta::sta()->properties();
properties.setProperty(edge, property, value);
}
PropertyValue
clock_property(Clock *clk,
const char *property)
{
Properties &properties = Sta::sta()->properties();
return properties.getProperty(clk, property);
}
void
set_clock_property(const Clock *clk,
const char *property,
PropertyValue value)
{
Properties &properties = Sta::sta()->properties();
properties.setProperty(clk, property, value);
}
PropertyValue
path_end_property(PathEnd *end,
const char *property)
{
Properties &properties = Sta::sta()->properties();
return properties.getProperty(end, property);
}
PropertyValue
path_property(Path *path,
const char *property)
{
Properties &properties = Sta::sta()->properties();
return properties.getProperty(path, property);
}
PropertyValue
timing_arc_set_property(TimingArcSet *arc_set,
const char *property)
{
Properties &properties = Sta::sta()->properties();
return properties.getProperty(arc_set, property);
}
%} // inline

View File

@ -1128,111 +1128,6 @@ set_use_default_arrival_clock(bool enable)
Sta::sta()->setUseDefaultArrivalClock(enable);
}
////////////////////////////////////////////////////////////////
//
// Properties
//
////////////////////////////////////////////////////////////////
PropertyValue
pin_property(const Pin *pin,
const char *property)
{
return getProperty(pin, property, Sta::sta());
}
PropertyValue
instance_property(const Instance *inst,
const char *property)
{
return getProperty(inst, property, Sta::sta());
}
PropertyValue
net_property(const Net *net,
const char *property)
{
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)
{
return getProperty(edge, property, Sta::sta());
}
PropertyValue
clock_property(Clock *clk,
const char *property)
{
return getProperty(clk, property, Sta::sta());
}
PropertyValue
path_end_property(PathEnd *end,
const char *property)
{
return getProperty(end, property, Sta::sta());
}
PropertyValue
path_ref_property(Path *path,
const char *property)
{
return getProperty(path, property, Sta::sta());
}
PropertyValue
timing_arc_set_property(TimingArcSet *arc_set,
const char *property)
{
return getProperty(arc_set, property, Sta::sta());
}
%} // inline
////////////////////////////////////////////////////////////////

View File

@ -285,7 +285,8 @@ Sta::Sta() :
equiv_cells_(nullptr),
graph_sdc_annotated_(false),
// Default to same parasitics for all corners.
parasitics_per_corner_(false)
parasitics_per_corner_(false),
properties_(this)
{
}

View File

@ -25,28 +25,24 @@
namespace eval sta {
define_cmd_args "get_property" \
{[-object_type cell|pin|net|port|clock|timing_arc] object property}
{[-object_type library|liberty_library|cell|liberty_cell|instance|pin|net|port|clock|timing_arc] object property}
proc get_property { args } {
return [get_property_cmd "get_property" "-object_type" $args]
}
proc get_property_cmd { cmd type_key cmd_args } {
parse_key_args $cmd cmd_args keys $type_key flags {-quiet}
parse_key_args "get_property" args keys {-object_type} flags {-quiet}
check_argc_eq2 "get_property" $args
set quiet [info exists flags(-quiet)]
check_argc_eq2 $cmd $cmd_args
set object [lindex $cmd_args 0]
set object [lindex $args 0]
if { $object == "" } {
sta_error 320 "$cmd object is null."
sta_error 2200 "get_property object is null."
} elseif { ![is_object $object] } {
if [info exists keys($type_key)] {
set object_type $keys($type_key)
if [info exists keys(-object_type)] {
set object_type $keys(-object_type)
} else {
sta_error 321 "$cmd $type_key must be specified with object name argument."
sta_error 2201 "get_property -object_type must be specified with object name argument."
}
set object [get_property_object_type $object_type $object $quiet]
}
set prop [lindex $cmd_args 1]
set prop [lindex $args 1]
return [get_object_property $object $prop]
}
@ -78,14 +74,14 @@ proc get_object_property { object prop } {
} elseif { $object_type == "PathEnd" } {
return [path_end_property $object $prop]
} elseif { $object_type == "Path" } {
return [path_ref_property $object $prop]
return [path_property $object $prop]
} elseif { $object_type == "TimingArcSet" } {
return [timing_arc_set_property $object $prop]
} else {
sta_error 322 "get_property unsupported object type $object_type."
sta_error 2203 "get_property unsupported object type $object_type."
}
} else {
sta_error 323 "get_property $object is not an object."
sta_error 2204 "get_property $object is not an object."
}
}
@ -112,13 +108,73 @@ proc get_property_object_type { object_type object_name quiet } {
|| $object_type == "lib"} {
set object [get_libs -quiet $object_name]
} else {
sta_error 324 "$object_type not supported."
sta_error 2205 "$object_type not supported."
}
if { $object == "NULL" && !$quiet } {
sta_error 325 "$object_type '$object_name' not found."
sta_error 2206 "$object_type '$object_name' not found."
}
return [lindex $object 0]
}
define_cmd_args "set_property" \
{[-object_type library|liberty_library|cell|liberty_cell|instance|pin|net|port|clock|timing_arc] object property value}
proc set_property { args } {
return [get_property_cmd "set_property" "-object_type" $args]
}
proc set_property { args } {
parse_key_args "set_property" args keys {-object_type} flags {-quiet}
check_argc_eq3 "set_property" $args
set quiet [info exists flags(-quiet)]
set object [lindex $args 0]
if { $object == "" } {
sta_error 2207 "set_property object is null."
} elseif { ![is_object $object] } {
if [info exists keys(-object_type)] {
set object_type $keys(-object_type)
} else {
sta_error 2208 "set_property -object_type must be specified with object name argument."
}
set object [get_property_object_type $object_type $object $quiet]
}
set prop [lindex $args 1]
set value [lindex $args 2]
set_object_property $object $prop $value
}
proc set_object_property { object prop value } {
if { [is_object $object] } {
set object_type [object_type $object]
if { $object_type == "Instance" } {
set_instance_property $object $prop $value
} elseif { $object_type == "Pin" } {
set_pin_property $object $prop $value
} elseif { $object_type == "Net" } {
set_net_property $object $prop $value
} elseif { $object_type == "Clock" } {
set_clock_property $object $prop $value
} elseif { $object_type == "Port" } {
set_port_property $object $prop $value
} elseif { $object_type == "LibertyPort" } {
set_liberty_port_property $object $prop $value
} elseif { $object_type == "LibertyCell" } {
set_liberty_cell_property $object $prop $value
} elseif { $object_type == "Cell" } {
set_cell_property $object $prop $value
} elseif { $object_type == "Library" } {
set_library_property $object $prop $value
} elseif { $object_type == "LibertyLibrary" } {
set_liberty_library_property $object $prop $value
} elseif { $object_type == "Edge" } {
set_edge_property $object $prop $value
} else {
sta_error 2209 "get_property unsupported object type $object_type."
}
} else {
sta_error 2210 "get_property $object is not an object."
}
}
# sta namespace end.
}

View File

@ -1260,6 +1260,12 @@ using namespace sta;
Tcl_SetObjResult(interp, list);
}
%typemap(in) PropertyValue {
int length;
const char *arg = Tcl_GetStringFromObj($input, &length);
$1 = PropertyValue(arg);
}
%typemap(out) PropertyValue {
PropertyValue value = $1;
switch (value.type()) {