Program Listing for File HSCutOnlyFlow.h

Return to documentation for file (src/sta/HSCutOnlyFlow.h)

#pragma once

#include <vector>

#include "HSPartitionFlow.h"

namespace HSFullTiming {

class HSTimingLocalData;

// 基于已有 HSPartitionFlow + HSTimingLocalData 构建“只保留割边”的缩小版
// timing flow。输出仍复用 HSPartitionFlow 的数据结构,便于后续 TDM/Routing
// 直接消费。
class HSCutOnlyFlow : public HSPartitionFlow {
 public:
  HSCutOnlyFlow() = default;
  explicit HSCutOnlyFlow(const std::vector<int> &partInfo)
      : m_partInfo(partInfo)
  {
  }
  ~HSCutOnlyFlow() override = default;

  // 依据当前 partInfo 判断哪些 outer edge 是 cut edge,并构建 cut-only
  // flow。要求 srcFlow 已完成 buildNextObjInfo,且 partInfo 与
  // srcFlow.getHyperNodeNum() 对齐。
  int buildFrom(const HSPartitionFlow &srcFlow);

  // 兼容接口:从 localData 中提取 partInfo 后调用 buildFrom(srcFlow)。
  int buildFrom(const HSPartitionFlow &srcFlow,
                const HSTimingLocalData *localData);

  void setPartInfo(const std::vector<int> &partInfo)
  {
    m_partInfo = partInfo;
  }

  const std::vector<int> &getPartInfo() const
  {
    return m_partInfo;
  }

  const std::vector<int> &getNew2OldEdgeIds() const
  {
    return m_new2OldEdgeIds;
  }

  const std::vector<int> &getOld2NewEdgeIds() const
  {
    return m_old2NewEdgeIds;
  }

 private:
  void clearCompactMaps();
  void cloneClocksFrom(const HSPartitionFlow &srcFlow);
  void buildCutEdgeMaps(const HSPartitionFlow &srcFlow);
  void buildOuterEdgesFrom(const HSPartitionFlow &srcFlow);
  void buildCutNetsFrom(const HSPartitionFlow &srcFlow);
  void buildCompressedCutAdjacency(
      const HSPartitionFlow &srcFlow,
      const std::vector<flat_hash_map<int, float>> &forwardNonCut2Cut);
  void buildCompressedClockAdjacency(
      const HSPartitionFlow &srcFlow,
      const std::vector<flat_hash_map<int, float>> &forwardNonCut2Cut,
      const std::vector<flat_hash_map<int, float>> &backwardNonCut2Cut);
  void rebuildNode2EdgeIds();

  std::vector<int> m_new2OldEdgeIds;
  std::vector<int> m_old2NewEdgeIds;
  std::vector<int> m_partInfo;
};

}  // namespace HSFullTiming