Program Listing for File HSStaBase.h¶
↰ Return to documentation for file (src/sta/HSStaBase.h)
#pragma once
#include <float.h>
#include <math.h>
#include <forward_list>
#include <list>
#include <map>
#include <set>
#include <utility>
#include <vector>
using std::forward_list;
using std::list;
using std::make_pair;
using std::map;
using std::pair;
using std::set;
using std::vector;
#include "HSGraphClock.h"
#include "HSOuterEdge.h"
namespace HSFullTiming {
// The HSStaBase class is a base class for static timing analysis.
// It provides common data structures and methods for performing STA.
class HSStaBase {
public:
// Default constructor.
HSStaBase();
// Virtual destructor to ensure proper cleanup of derived classes.
virtual ~HSStaBase();
// Cleans up the base data structures.
virtual void cleanBase();
// Builds information about the next objects in the timing graph.
// @return An integer status code.
int buildNextObjInfo();
// count paths
int pathCount();
// Pure virtual function to build local data for derived classes.
// @return An integer status code.
virtual int buildLocalData() = 0;
// get or set data functions
// Sets the cut delay, which is an additional delay for outer edges.
// @param cutDelay The cut delay value.
static void setCutDelay(float cutDelay);
// Gets all outer edges in the timing graph.
// @return A constant reference to a vector of HSOuterEdge pointers.
const vector<HSOuterEdge *> &getOuterEdge() const;
// Gets the next data for all outer edges.
// Each element in the vector corresponds to an outer edge, and the
// forward_list contains pairs of (object ID, delay) for the next objects.
// @return A constant reference to a vector of forward_lists.
const vector<forward_list<pair<int, float>>> &getNextData() const;
// Gets the previous data for all outer edges.
// Each element in the vector corresponds to an outer edge, and the
// forward_list contains pairs of (object ID, delay) for the previous objects.
// @return A constant reference to a vector of forward_lists.
const vector<forward_list<pair<int, float>>> &getPreData() const;
// Gets the next data for a specific outer edge ID.
// @param id The ID of the outer edge.
// @return A constant reference to a forward_list of (object ID, delay) pairs.
const forward_list<pair<int, float>> &getNextData(int id) const;
// Gets the previous data for a specific outer edge ID.
// @param id The ID of the outer edge.
// @return A constant reference to a forward_list of (object ID, delay) pairs.
const forward_list<pair<int, float>> &getPreData(int id) const;
// Gets the mapping from clocks to next data.
// The map stores HSGraphClock pointers as keys and forward_lists of (object
// ID, delay) pairs as values, representing the next objects driven by each
// clock.
// @return A constant reference to the map.
const map<HSGraphClock *, forward_list<pair<int, float>>> &getClk2NextData()
const;
// Gets the mapping from clocks to previous data.
// The map stores HSGraphClock pointers as keys and forward_lists of (object
// ID, delay) pairs as values, representing the previous objects related to
// each clock.
// @return A constant reference to the map.
const map<HSGraphClock *, forward_list<pair<int, float>>> &getClk2PreData()
const;
// Gets node2edgeIds
const vector<vector<int>> &getNode2EdgeIds() const;
// Gets the cut delay value.
// @return The cut delay value.
float getCutDelay() const;
// Gets the maximum level in the timing graph.
// @return The maximum level.
int getMaxLevel() const;
// The timingpath struct represents a path in the timing graph.
struct timingpath {
// A forward_list of edge IDs that make up the timing path.
forward_list<int> m_edgeIdList;
// Adds an edge ID to the end of the m_edgeIdList.
// @param id The ID of the edge to add.
void emplace_backEdgeId(int id);
// pop the edgeId of the end of the edgeIdList
void pop_backEdgeId();
// The ID of the clock associated with this timing path.
int m_clkId = -1;
// The slack of the timing path. Initialized to the maximum float value.
float m_slack = FLT_MAX;
// The number of hops (edges) in the timing path.
int m_hop = 0;
// Comparison operator for sorting timing paths.
// @param another The other timingpath to compare against.
// @return True if this timingpath is less than the other, false otherwise.
bool operator<(const timingpath &another) const;
// Checks if this timingpath is the same as another.
// @param another The other timingpath to compare against.
// @return True if the timing paths are the same, false otherwise.
bool isSame(const timingpath &another);
// Static boolean flag used for sorting paths during merging.
static bool m_bSortForMerge;
// Static pointer to the HSStaBase object, used for accessing context within
// timingpath methods.
static HSStaBase *m_staFlow;
// -------------------------------------------------------------------------
// Added by peicy on 20250718, used for sorting ins_paths.
// Note: pathId is different before and after sorting/merging.
int pathId = 0;
// add slackPre, slackPost, edgeId
float slackPre = 0;
float slackPost = 0;
int edgeId = 0;
};
protected:
// The maximum level in the timing graph.
int m_maxLevel = 0;
// A vector containing all outer edges in the timing graph.
vector<HSOuterEdge *> m_outerEdgeAll;
// A vector where each element is a forward_list representing the next objects
// connected to an outer edge. The pair contains (object ID, delay).
vector<forward_list<pair<int, float>>> m_outerEdge2next;
// A vector where each element is a forward_list representing the previous
// objects connected to an outer edge. The pair contains (object ID, delay).
vector<forward_list<pair<int, float>>> m_outerEdge2pre;
// A map that stores the relationship between clocks and their next objects.
// The key is a pointer to an HSGraphClock object, and the value is a
// forward_list of (object ID, delay) pairs.
map<HSGraphClock *, forward_list<pair<int, float>>> m_clk2next;
// A map that stores the relationship between clocks and their previous
// objects. The key is a pointer to an HSGraphClock object, and the value is a
// forward_list of (object ID, delay) pairs.
map<HSGraphClock *, forward_list<pair<int, float>>> m_clk2pre;
// A vector containing all clocks in the timing graph.
vector<HSGraphClock *> m_clkAll;
// Static member representing an additional delay for outer edges.
static float m_cutDelay; // addition delay of outerEdge
// 存储每个节点连接的edgeId
vector<vector<int>> m_node2edgeIds;
};
} // namespace HSFullTiming