@@ -66,6 +66,19 @@ static void add_pins_spatial_lookup(RRGraphBuilder& rr_graph_builder,
6666 int * index,
6767 const std::vector<e_side>& wanted_sides);
6868
69+ /* *
70+ * @brief Check consistency between RR node count and expected coverage from RR nodes
71+ *
72+ * This helper validates that each RR node appears the correct number of times
73+ * in the node lookup structure based on its span or area.
74+ */
75+ static void check_rr_node_counts (const std::unordered_map<RRNodeId, int >& rr_node_counts,
76+ const RRGraphView& rr_graph,
77+ const t_rr_graph_storage& rr_nodes,
78+ const DeviceGrid& grid,
79+ const vtr::vector<RRIndexedDataId, t_rr_indexed_data>& rr_indexed_data,
80+ bool is_flat);
81+
6982/* As the rr_indices builders modify a local copy of indices, use the local copy in the builder
7083 * TODO: these building functions should only talk to a RRGraphBuilder object
7184 */
@@ -596,33 +609,40 @@ bool verify_rr_node_indices(const DeviceGrid& grid,
596609 }
597610 }
598611
612+ check_rr_node_counts (rr_node_counts, rr_graph, rr_nodes, grid, rr_indexed_data, is_flat);
613+
614+ return true ;
615+ }
616+
617+ static void check_rr_node_counts (const std::unordered_map<RRNodeId, int >& rr_node_counts,
618+ const RRGraphView& rr_graph,
619+ const t_rr_graph_storage& rr_nodes,
620+ const DeviceGrid& grid,
621+ const vtr::vector<RRIndexedDataId, t_rr_indexed_data>& rr_indexed_data,
622+ bool is_flat) {
599623 if (rr_node_counts.size () != rr_nodes.size ()) {
600624 VPR_ERROR (VPR_ERROR_ROUTE, " Mismatch in number of unique RR nodes in rr_nodes (%zu) and rr_node_indices (%zu)" ,
601625 rr_nodes.size (),
602626 rr_node_counts.size ());
603627 }
604628
605- for (auto kv : rr_node_counts) {
606- RRNodeId inode = kv.first ;
607- int count = kv.second ;
608-
629+ for (const auto & [inode, count] : rr_node_counts) {
609630 const t_rr_node& rr_node = rr_nodes[size_t (inode)];
631+ e_rr_type node_type = rr_graph.node_type (inode);
610632
611- if (rr_graph. node_type (inode) == e_rr_type::SOURCE || rr_graph. node_type (inode) == e_rr_type::SINK) {
612- int rr_width = ( rr_graph.node_xhigh (rr_node. id ()) - rr_graph.node_xlow (rr_node. id ()) + 1 ) ;
613- int rr_height = ( rr_graph.node_yhigh (rr_node. id ()) - rr_graph.node_ylow (rr_node. id ()) + 1 ) ;
633+ if (node_type == e_rr_type::SOURCE || node_type == e_rr_type::SINK) {
634+ int rr_width = rr_graph.node_xhigh (inode) - rr_graph.node_xlow (inode) + 1 ;
635+ int rr_height = rr_graph.node_yhigh (inode) - rr_graph.node_ylow (inode) + 1 ;
614636 int rr_area = rr_width * rr_height;
637+
615638 if (count != rr_area) {
616- VPR_ERROR (VPR_ERROR_ROUTE, " Mismatch between RR node size (%d) and count within rr_node_indices (%d): %s" ,
639+ VPR_ERROR (VPR_ERROR_ROUTE, " Mismatch between RR node area (%d) and count within rr_node_indices (%d): %s" ,
617640 rr_area,
618- rr_node.length (),
619641 count,
620642 describe_rr_node (rr_graph, grid, rr_indexed_data, inode, is_flat).c_str ());
621643 }
622- // As we allow a pin to be indexable on multiple sides,
623- // This check code should not be applied to input and output pins
624644
625- } else if (( e_rr_type::OPIN != rr_graph. node_type (inode)) && ( e_rr_type::IPIN != rr_graph. node_type (inode)) ) {
645+ } else if (node_type != e_rr_type::OPIN && node_type != e_rr_type::IPIN) {
626646 if (count != rr_node.length () + 1 ) {
627647 VPR_ERROR (VPR_ERROR_ROUTE, " Mismatch between RR node length (%d) and count within rr_node_indices (%d, should be length + 1): %s" ,
628648 rr_node.length (),
@@ -631,6 +651,4 @@ bool verify_rr_node_indices(const DeviceGrid& grid,
631651 }
632652 }
633653 }
634-
635- return true ;
636- }
654+ }
0 commit comments