OpenSTA/search/WorstSlack.hh

118 lines
3.1 KiB
C++
Raw Permalink Normal View History

2018-09-28 17:54:21 +02:00
// OpenSTA, Static Timing Analyzer
// Copyright (c) 2025, Parallax Software, Inc.
2018-09-28 17:54:21 +02: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
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2018-09-28 17:54:21 +02:00
// 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.
2018-09-28 17:54:21 +02:00
2020-02-16 01:13:16 +01:00
#pragma once
2018-09-28 17:54:21 +02:00
2019-03-13 01:25:53 +01:00
#include <mutex>
2020-04-05 20:35:51 +02:00
2020-04-05 23:53:44 +02:00
#include "MinMax.hh"
#include "Vector.hh"
#include "GraphClass.hh"
#include "SearchClass.hh"
#include "StaState.hh"
2018-09-28 17:54:21 +02:00
2020-04-06 04:44:41 +02:00
namespace sta {
2018-09-28 17:54:21 +02:00
class StaState;
class WorstSlack;
2018-12-05 23:18:41 +01:00
class WnsSlackLess;
typedef Vector<WorstSlack> WorstSlackSeq;
2018-09-28 17:54:21 +02:00
class WorstSlacks
{
public:
WorstSlacks(StaState *sta);
2018-12-05 23:18:41 +01:00
void worstSlack(const MinMax *min_max,
// Return values.
Slack &worst_slack,
Vertex *&worst_vertex);
void worstSlack(const Corner *corner,
const MinMax *min_max,
// Return values.
Slack &worst_slack,
Vertex *&worst_vertex);
2018-09-28 17:54:21 +02:00
void updateWorstSlacks(Vertex *vertex,
2018-12-05 23:18:41 +01:00
SlackSeq &slacks);
2018-09-28 17:54:21 +02:00
void worstSlackNotifyBefore(Vertex *vertex);
protected:
2018-12-05 23:18:41 +01:00
WorstSlackSeq worst_slacks_;
const StaState *sta_;
};
class WnsSlackLess
{
public:
WnsSlackLess(PathAPIndex path_ap_index,
const StaState *sta);
bool operator()(Vertex *vertex1,
Vertex *vertex2);
private:
PathAPIndex path_ap_index_;
Search *search_;
};
class WorstSlack : public StaState
2018-12-05 23:18:41 +01:00
{
public:
WorstSlack(StaState *sta);
~WorstSlack();
2018-12-05 23:18:41 +01:00
WorstSlack(const WorstSlack &);
void worstSlack(PathAPIndex path_ap_index,
// Return values.
Slack &worst_slack,
Vertex *&worst_vertex);
void updateWorstSlack(Vertex *vertex,
SlackSeq &slacks,
PathAPIndex path_ap_index);
2018-12-05 23:18:41 +01:00
void deleteVertexBefore(Vertex *vertex);
protected:
void findWorstSlack(PathAPIndex path_ap_index);
void initQueue(PathAPIndex path_ap_index);
void findWorstInQueue(PathAPIndex path_ap_index);
2018-12-05 23:18:41 +01:00
void setWorstSlack(Vertex *vertex,
Slack slack);
void sortQueue(PathAPIndex path_ap_index);
void checkQueue(PathAPIndex path_ap_index);
2018-12-05 23:18:41 +01:00
Slack slack_init_;
// Vertex with the worst slack.
2019-03-13 01:25:53 +01:00
// When nullptr the worst slack is unknown but in the queue.
2018-12-05 23:18:41 +01:00
Vertex *worst_vertex_;
Slack worst_slack_;
Slack slack_threshold_;
// Vertices with slack < threshold_
VertexSet *queue_;
2018-12-05 23:18:41 +01:00
// Queue is sorted and pruned to min_queue_size_ vertices when it
// reaches max_queue_size_.
int min_queue_size_;
int max_queue_size_;
2019-03-13 01:25:53 +01:00
std::mutex lock_;
2018-09-28 17:54:21 +02:00
};
} // namespace