Skip to content

Commit 3c7b677

Browse files
committed
[lib][rr_graph] add node_ptc_number_to_string
1 parent 955502d commit 3c7b677

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

libs/librrgraph/src/base/rr_graph_utils.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,3 +400,20 @@ std::vector<int> parse_ptc_numbers(const std::string& ptc_str) {
400400
}
401401
return ptc_numbers;
402402
}
403+
404+
std::string node_ptc_number_to_string(const RRGraphView& rr_graph, RRNodeId node) {
405+
const t_rr_graph_storage& node_storage = rr_graph.rr_nodes();
406+
407+
if (!node_storage.node_contain_multiple_ptc(node)) {
408+
return std::to_string(size_t(node_storage.node_ptc_num(node)));
409+
}
410+
411+
std::string ret;
412+
const std::vector<short>& track_nums = node_storage.node_tilable_track_nums(node);
413+
for (size_t iptc = 0; iptc < track_nums.size(); iptc++) {
414+
ret += std::to_string(track_nums[iptc]) + ",";
415+
}
416+
// Remove the last comma
417+
ret.pop_back();
418+
return ret;
419+
}

libs/librrgraph/src/base/rr_graph_utils.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,10 @@ bool chan_same_type_are_adjacent(const RRGraphView& rr_graph, RRNodeId node1, RR
132132
*/
133133
std::vector<int> parse_ptc_numbers(const std::string& ptc_str);
134134

135+
/**
136+
* @brief Convert the ptc numbers of a node to a string.
137+
* @param rr_graph The routing resource graph
138+
* @param node The node id
139+
* @return A string representing the ptc numbers of the node in the format of "ptc1,ptc2,ptc3,...ptcn".
140+
*/
141+
std::string node_ptc_number_to_string(const RRGraphView& rr_graph, RRNodeId node);

0 commit comments

Comments
 (0)