Files
OpenSTA/include/sta/PathGroup.hh
T

231 lines
8.3 KiB
C++
Raw Normal View History

2018-09-28 08:54:21 -07:00
// OpenSTA, Static Timing Analyzer
2026-03-10 13:21:17 -07:00
// Copyright (c) 2026, Parallax Software, Inc.
2018-09-28 08:54:21 -07:00
//
// 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
2022-01-04 10:17:08 -07:00
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2018-09-28 08:54:21 -07:00
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
2022-01-04 10:17:08 -07:00
// along with this program. If not, see <https://www.gnu.org/licenses/>.
2025-01-21 18:54:33 -07:00
//
// 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.
2018-09-28 08:54:21 -07:00
2020-02-15 17:13:16 -07:00
#pragma once
2018-09-28 08:54:21 -07:00
2026-04-15 09:38:10 -07:00
#include <map>
#include <mutex>
2026-01-03 16:59:35 -08:00
#include <string>
2026-03-28 19:13:35 -07:00
#include <string_view>
2026-01-03 16:59:35 -08:00
#include <vector>
2020-04-05 11:35:51 -07:00
2026-04-15 09:38:10 -07:00
#include "PathEnd.hh"
2020-04-05 14:53:44 -07:00
#include "SdcClass.hh"
#include "SearchClass.hh"
2026-04-15 09:38:10 -07:00
#include "StaState.hh"
2026-02-28 15:53:23 -08:00
#include "StringUtil.hh"
2018-09-28 08:54:21 -07:00
namespace sta {
class MinMax;
class PathEndVisitor;
2026-01-03 16:59:35 -08:00
using PathGroupIterator = PathEndSeq::iterator;
using PathGroupClkMap = std::map<const Clock*, PathGroup*>;
2026-03-15 14:35:24 -07:00
using PathGroupNamedMap = std::map<std::string, PathGroup*>;
2026-01-03 16:59:35 -08:00
using PathGroupSeq = std::vector<PathGroup*>;
2018-09-28 08:54:21 -07:00
// A collection of PathEnds grouped and sorted for reporting.
class PathGroup
{
public:
// Path group that compares compare slacks.
2026-03-28 19:13:35 -07:00
static PathGroup *makePathGroupArrival(std::string_view name,
2026-04-13 14:58:16 -07:00
size_t group_path_count,
size_t endpoint_path_count,
2026-01-03 16:59:35 -08:00
bool unique_pins,
bool unique_edges,
const MinMax *min_max,
const StaState *sta);
2018-09-28 08:54:21 -07:00
// Path group that compares arrival time, sorted by min_max.
2026-03-28 19:13:35 -07:00
static PathGroup *makePathGroupSlack(std::string_view name,
2026-04-13 14:58:16 -07:00
size_t group_path_count,
size_t endpoint_path_count,
2026-01-03 16:59:35 -08:00
bool unique_pins,
bool unique_edges,
2026-04-13 14:58:16 -07:00
float slack_min,
float slack_max,
2026-01-03 16:59:35 -08:00
const StaState *sta);
2026-03-10 10:26:59 -07:00
~PathGroup();
2026-03-08 16:39:48 -07:00
const std::string &name() const { return name_; }
2018-09-28 08:54:21 -07:00
const MinMax *minMax() const { return min_max_;}
2026-03-15 08:33:49 -07:00
PathEndSeq pathEnds() const { return path_ends_; }
2018-09-28 08:54:21 -07:00
void insert(PathEnd *path_end);
2024-11-23 15:38:26 -08:00
// Push group_path_count into path_ends.
2023-01-20 11:19:39 -07:00
void pushEnds(PathEndSeq &path_ends);
2025-01-13 16:58:47 -07:00
// Predicate to determine if a PathEnd is worth saving.
bool saveable(PathEnd *path_end);
bool enumMinSlackUnderMin(PathEnd *path_end);
2026-04-13 14:58:16 -07:00
size_t maxPaths() const { return group_path_count_; }
2018-09-28 08:54:21 -07:00
// This does NOT delete the path ends.
void clear();
2026-04-13 14:58:16 -07:00
static size_t group_path_count_max;
2019-02-16 12:07:59 -08:00
2018-09-28 08:54:21 -07:00
protected:
2026-03-28 19:13:35 -07:00
PathGroup(std::string_view name,
2026-04-13 14:58:16 -07:00
size_t group_path_count,
size_t endpoint_path_count,
2026-01-03 16:59:35 -08:00
bool unique_pins,
bool unique_edges,
2026-04-13 14:58:16 -07:00
float slack_min,
float slack_max,
2026-01-03 16:59:35 -08:00
bool cmp_slack,
const MinMax *min_max,
const StaState *sta);
2026-03-15 08:33:49 -07:00
void ensureSortedMaxPaths();
void prune();
void sort();
2018-09-28 08:54:21 -07:00
2026-01-03 16:59:35 -08:00
std::string name_;
2026-04-13 14:58:16 -07:00
size_t group_path_count_;
size_t endpoint_path_count_;
2018-09-28 08:54:21 -07:00
bool unique_pins_;
2025-11-04 12:30:55 -07:00
bool unique_edges_;
2018-09-28 08:54:21 -07:00
float slack_min_;
float slack_max_;
2026-03-15 08:33:49 -07:00
PathEndSeq path_ends_;
2018-09-28 08:54:21 -07:00
const MinMax *min_max_;
2026-03-09 10:15:53 -07:00
bool cmp_slack_;
2026-03-15 08:33:49 -07:00
float threshold_;
2019-03-12 17:25:53 -07:00
std::mutex lock_;
2018-09-28 08:54:21 -07:00
const StaState *sta_;
};
class PathGroups : public StaState
{
public:
2026-04-13 14:58:16 -07:00
PathGroups(size_t group_path_count,
size_t endpoint_path_count,
2026-01-03 16:59:35 -08:00
bool unique_pins,
bool unique_edges,
float slack_min,
float slack_max,
2026-03-08 15:51:50 -07:00
StringSeq &group_names,
2026-01-03 16:59:35 -08:00
bool setup,
bool hold,
bool recovery,
bool removal,
bool clk_gating_setup,
bool clk_gating_hold,
bool unconstrained,
const Mode *mode);
2026-04-13 14:58:16 -07:00
~PathGroups() override;
2026-01-03 16:59:35 -08:00
// Use scene nullptr to make PathEnds for all scenes.
2018-09-28 08:54:21 -07:00
// The PathEnds in the vector are owned by the PathGroups.
2026-01-03 16:59:35 -08:00
void makePathEnds(ExceptionTo *to,
const SceneSeq &scenes,
const MinMaxAll *min_max,
bool sort_by_slack,
bool unconstrained_paths,
// Return value.
PathEndSeq &path_ends);
2026-03-15 14:35:24 -07:00
PathGroup *findPathGroup(const std::string &name,
2026-01-03 16:59:35 -08:00
const MinMax *min_max) const;
2018-09-28 08:54:21 -07:00
PathGroup *findPathGroup(const Clock *clock,
2026-01-03 16:59:35 -08:00
const MinMax *min_max) const;
PathGroupSeq pathGroups(const PathEnd *path_end) const;
2026-06-06 11:55:51 -07:00
static bool inPathGroupNamed(const PathEnd *path_end,
std::string_view path_group_name,
const StaState *sta);
2026-03-28 19:13:35 -07:00
static std::string_view asyncPathGroupName() { return async_group_name_; }
static std::string_view pathDelayGroupName() { return path_delay_group_name_; }
static std::string_view gatedClkGroupName() { return gated_clk_group_name_; }
static std::string_view unconstrainedGroupName() { return unconstrained_group_name_; }
2018-09-28 08:54:21 -07:00
protected:
void makeGroupPathEnds(ExceptionTo *to,
2026-04-13 14:58:16 -07:00
size_t group_path_count,
size_t endpoint_path_count,
2026-01-03 16:59:35 -08:00
bool unique_pins,
bool unique_edges,
const SceneSeq &scenes,
const MinMaxAll *min_max);
2018-09-28 08:54:21 -07:00
void makeGroupPathEnds(ExceptionTo *to,
2026-01-03 16:59:35 -08:00
const SceneSeq &scenes,
const MinMaxAll *min_max,
PathEndVisitor *visitor);
void makeGroupPathEnds(VertexSet &endpoints,
const SceneSeq &scenes,
const MinMaxAll *min_max,
PathEndVisitor *visitor);
2018-09-28 08:54:21 -07:00
void enumPathEnds(PathGroup *group,
2026-04-13 14:58:16 -07:00
size_t group_path_count,
size_t endpoint_path_count,
2026-01-03 16:59:35 -08:00
bool unique_pins,
bool unique_edges,
bool cmp_slack);
2018-09-28 08:54:21 -07:00
2026-01-03 16:59:35 -08:00
void pushEnds(PathEndSeq &path_ends);
2023-01-20 11:19:39 -07:00
void pushUnconstrainedPathEnds(PathEndSeq &path_ends,
2026-01-03 16:59:35 -08:00
const MinMaxAll *min_max);
2018-09-28 08:54:21 -07:00
2026-04-13 14:58:16 -07:00
void makeGroups(size_t group_path_count,
size_t endpoint_path_count,
2026-01-03 16:59:35 -08:00
bool unique_pins,
bool unique_edges,
float slack_min,
float slack_max,
2026-03-08 15:55:12 -07:00
StringSet &group_names,
2026-01-03 16:59:35 -08:00
bool setup_hold,
bool async,
bool gated_clk,
bool unconstrained,
const MinMax *min_max);
2026-03-15 14:35:24 -07:00
bool reportGroup(const std::string &group_name,
2026-03-08 15:55:12 -07:00
StringSet &group_names) const;
2026-01-03 16:59:35 -08:00
static GroupPath *groupPathTo(const PathEnd *path_end,
const StaState *sta);
2026-03-08 15:51:50 -07:00
StringSeq pathGroupNames();
2018-09-28 08:54:21 -07:00
2026-01-03 16:59:35 -08:00
const Mode *mode_;
2026-04-13 14:58:16 -07:00
size_t group_path_count_;
size_t endpoint_path_count_;
2018-09-28 08:54:21 -07:00
bool unique_pins_;
2025-11-04 12:30:55 -07:00
bool unique_edges_;
2018-09-28 08:54:21 -07:00
float slack_min_;
float slack_max_;
// Paths grouped by SDC group_path command.
// name -> PathGroup
PathGroupNamedMap named_map_[MinMax::index_count];
// clock -> PathGroup
PathGroupClkMap clk_map_[MinMax::index_count];
// Min/max path delays.
PathGroup *path_delay_[MinMax::index_count];
// Gated clock checks.
PathGroup *gated_clk_[MinMax::index_count];
// Asynchronous (recovery/removal) checks.
PathGroup *async_[MinMax::index_count];
// Unconstrained paths.
PathGroup *unconstrained_[MinMax::index_count];
2026-03-28 19:13:35 -07:00
static constexpr std::string_view path_delay_group_name_ = "path delay";
static constexpr std::string_view gated_clk_group_name_ = "gated clock";
static constexpr std::string_view async_group_name_ = "asynchronous";
static constexpr std::string_view unconstrained_group_name_ = "unconstrained";
2018-09-28 08:54:21 -07:00
};
2026-04-13 14:58:16 -07:00
} // namespace sta