[lib] developing linker

This commit is contained in:
tangxifan 2023-02-22 18:36:22 -08:00
parent ce20a16aad
commit bf2876c60e
2 changed files with 27 additions and 0 deletions

View File

@ -199,6 +199,27 @@ void ClockNetwork::add_spine_switch_point(const ClockSpineId& spine_id, const Cl
spine_parent_[drive_spine_id] = spine_id;
}
bool ClockNetwork::link() {
for (ClockTreeId& tree_id : trees()) {
if (!link_tree(tree_id)) {
return false;
}
}
return true;
}
bool ClockNetwork::link_tree(const ClockTreeId& tree_id) {
tree_top_spines_[tree_id].clear();
/* Sort the spines under a tree; assign levels and identify top-level spines */
for (ClockSpineId spine_id : spines(tree_id)) {
/* Spines that have no parent are the top-level spines*/
if (!spine_parent_[spine_id]) {
tree_top_spines_[tree_id].push_back(spine_id);
}
}
return true;
}
/************************************************************************
* Internal invalidators/validators
***********************************************************************/

View File

@ -81,6 +81,8 @@ class ClockNetwork {
void set_spine_start_point(const ClockSpineId& spine_id, const vtr::Point<int>& coord);
void set_spine_end_point(const ClockSpineId& spine_id, const vtr::Point<int>& coord);
void add_spine_switch_point(const ClockSpineId& spine_id, const ClockSpineId& drive_spine_id, const vtr::Point<int>& coord);
/* Build internal links between clock tree, spines etc. This is also an validator to verify the correctness of the clock network. Must run before using the data! */
bool link();
public: /* Public invalidators/validators */
/* Show if the tree id is a valid for data queries */
@ -89,6 +91,10 @@ class ClockNetwork {
bool valid_spine_id(const ClockSpineId& spine_id) const;
bool valid_spine_switch_point_id(const ClockSpineId& spine_id, const ClockSwitchPointId& switch_point_id) const;
private: /* Private mutators */
/* Build internal links between spines under a given tree */
bool link_tree(const ClockTreeId& tree_id);
private: /* Internal data */
/* Basic information of each tree */
vtr::vector<ClockTreeId, ClockTreeId> tree_ids_;