Struct DelayLibrary¶
Defined in File delay_lib.h
Struct Documentation¶
-
struct DelayLibrary¶
从 JSON 构建并查询 GIO/MGT 延迟模型的统一入口。
buildFromJson()成功后,可通过delay()、slope()、minRatio()、maxRatio()和choices()访问模型。对象本身不负责读取文件,调用方需先 将文件解析为nlohmann::json。默认范围查询
-
inline double delayGio(double r) const¶
-
inline double delayMgt(double r) const¶
-
inline double slopeGio(double r) const¶
-
inline double slopeMgt(double r) const¶
合法范围查询
-
inline double minRatio(DelayScope scope, RatioLib lib) const¶
-
inline double maxRatio(DelayScope scope, RatioLib lib) const¶
Public Functions
-
inline void initDefaultScopeModels()¶
-
inline bool parseScopeModels(const nlohmann::json &j)¶
-
inline bool buildFromJson(const nlohmann::json &j)¶
从已解析的 JSON 构建完整延迟库。
根对象必须同时包含可用的
gio和mgt对象。若choices或边界 缺省,将从 PWL 横坐标推断;可选的scopes用于层次化延迟覆盖。- Returns:
两类基础模型及全部 scope 配置均有效时返回
true。
-
inline double clampGio(double r) const¶
将 ratio 限制到默认 GIO 模型边界。
-
inline double clampMgt(double r) const¶
-
inline const LibModel &modelFor(DelayScope scope, RatioLib lib) const¶
返回指定范围和互连类型的模型;缺省时回退默认模型。
-
inline const LibMeta &metaFor(DelayScope scope, RatioLib lib) const¶
返回指定范围和互连类型的元信息;缺省时回退默认元信息。
-
inline double delay(DelayScope scope, RatioLib lib, double r) const¶
按层次范围和互连类型查询延迟(ns)。
-
inline double slope(DelayScope scope, RatioLib lib, double r) const¶
按层次范围和互连类型查询局部斜率。
-
inline double delayGio(DelayScope scope, double r) const¶
-
inline double delayMgt(DelayScope scope, double r) const¶
-
inline double slopeGio(DelayScope scope, double r) const¶
-
inline double slopeMgt(DelayScope scope, double r) const¶
-
inline std::vector<int> choices(RatioLib lib) const¶
返回默认范围的合法离散 ratio。
JSON 未给
choices时,从 PWL 横坐标和 bypass 点推断并去重。
-
inline std::vector<int> choices(DelayScope scope, RatioLib lib) const¶
返回指定范围的合法离散 ratio,缺省时使用该范围的 PWL 点。
-
inline bool hasChoice(DelayScope scope, RatioLib lib, int r) const¶
判断指定范围是否包含给定离散 ratio。
-
inline std::optional<double> discreteDelay(RatioLib lib, double r) const¶
查询默认范围中精确离散点的延迟。
- Returns:
ratio 不在 PWL/bypass 离散点上时返回
std::nullopt。
-
inline std::optional<double> discreteDelay(DelayScope scope, RatioLib lib, double r) const¶
查询指定范围中精确离散点的延迟。
Note
本接口不会做插值;需要连续求值时使用
delay()。
Public Members
-
std::array<ScopedLibModels, kDelayScopeCount> scoped_models¶
分范围模型。
-
bool has_scoped_models = false¶
JSON 是否提供了非默认范围模型。
Public Static Functions
-
static inline LinearModel fitLinear(const std::vector<double> &xs, const std::vector<double> &ys)¶
对采样点进行最小二乘直线拟合。
- Returns:
数据不足或退化时返回
valid=false的模型。
-
static inline bool parsePoints(const nlohmann::json &arr, std::vector<double> &xs, std::vector<double> &ys)¶
解析
points数组。支持
[[ratio, delay], ...]与对象数组两种格式;对象中的 延迟键可为delay或delay_ns。
-
static inline bool parseBypass(const nlohmann::json &b, double &r, std::optional<double> &dopt)¶
解析 GIO bypass 配置。
delay 可省略;此时由同一模型的 PWL 点插值或外推得到。
-
static inline void parseMeta(const nlohmann::json &j, LibMeta &meta)¶
解析
min_ratio、max_ratio与choices元信息。
-
static inline int scopeIndex(DelayScope scope)¶
-
static inline std::string normalizeName(std::string name)¶
-
static inline std::optional<DelayScope> parseScopeName(const std::string &name)¶
-
static inline double parseOffsetNs(const nlohmann::json &j)¶
Public Static Attributes
-
static constexpr int kDelayScopeCount = 5¶
DelayScope枚举项数量。
-
inline double delayGio(double r) const¶