@@ -325,6 +325,7 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {
325
325
, is_flat_(is_flat) {
326
326
// Initialize internal data
327
327
init_side_map ();
328
+ init_segment_inf_x_y ();
328
329
}
329
330
330
331
/* A truth table to help understand the conversion from VPR side mask to uxsd side code
@@ -381,6 +382,58 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {
381
382
side_map_[(1 << TOP) | (1 << RIGHT) | (1 << BOTTOM) | (1 << LEFT)] = uxsd::enum_loc_side::TOP_RIGHT_BOTTOM_LEFT;
382
383
}
383
384
385
+ /* *
386
+ * @brief This function separates the segments in segment_inf_ based on whether their parallel axis
387
+ * is X or Y, and it stores them in segment_inf_x_ and segment_inf_y_.
388
+ */
389
+ void init_segment_inf_x_y (){
390
+
391
+ /* Create a temp copy to convert from vtr::vector to std::vector
392
+ * This is required because the ``alloc_and_load_rr_indexed_data()`` function supports only std::vector data
393
+ * type for ``rr_segments``
394
+ * Note that this is a dirty fix (to avoid massive code changes)
395
+ * TODO: The ``alloc_and_load_rr_indexed_data()`` function should embrace ``vtr::vector`` for ``rr_segments``
396
+ */
397
+ std::vector<t_segment_inf> rr_segs;
398
+ rr_segs.reserve (segment_inf_.size ());
399
+ for (auto & rr_seg : segment_inf_) {
400
+ rr_segs.push_back (rr_seg);
401
+ }
402
+
403
+ t_unified_to_parallel_seg_index seg_index_map;
404
+ segment_inf_x_ = get_parallel_segs (rr_segs, seg_index_map, X_AXIS);
405
+ segment_inf_y_ = get_parallel_segs (rr_segs, seg_index_map, Y_AXIS);
406
+
407
+ }
408
+
409
+ /* *
410
+ * @brief Search for a segment with a matching segment ID and return its position index
411
+ * in the list of segments along the corresponding axis (X or Y).
412
+ * @param segment_id The ID of the segment to search for.
413
+ * @param axis The axis along which to search for the segment (X or Y).
414
+ * @return int The position index of the matching segment.
415
+ */
416
+ int find_segment_index_along_axis (int segment_id, e_parallel_axis axis) const {
417
+ const std::vector<t_segment_inf>* segment_inf_vec_ptr;
418
+
419
+ if (axis == X_AXIS)
420
+ segment_inf_vec_ptr = &segment_inf_x_;
421
+ else
422
+ segment_inf_vec_ptr = &segment_inf_y_;
423
+
424
+ for (std::vector<t_segment_inf>::size_type i=0 ; i < (*segment_inf_vec_ptr).size (); i++){
425
+ if ((*segment_inf_vec_ptr)[i].seg_index == segment_id)
426
+ return static_cast <int >(i);
427
+ }
428
+
429
+ if (axis == X_AXIS)
430
+ VTR_LOG_ERROR (" Segment ID %d not found in the list of segments along X axis.\n " , segment_id);
431
+ else
432
+ VTR_LOG_ERROR (" Segment ID %d not found in the list of segments along Y axis.\n " , segment_id);
433
+
434
+ return -1 ;
435
+ }
436
+
384
437
public:
385
438
void start_load (const std::function<void (const char *)>* report_error_in) final {
386
439
// report_error_in should be invoked if RrGraphSerializer encounters
@@ -748,10 +801,12 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {
748
801
if (GRAPH_GLOBAL == graph_type_) {
749
802
rr_graph_builder_->set_node_cost_index (node_id, RRIndexedDataId (0 ));
750
803
} else if (rr_graph.node_type (node.id ()) == CHANX) {
751
- rr_graph_builder_->set_node_cost_index (node_id, RRIndexedDataId (CHANX_COST_INDEX_START + segment_id));
804
+ int seg_ind_x = find_segment_index_along_axis (segment_id, X_AXIS);
805
+ rr_graph_builder_->set_node_cost_index (node_id, RRIndexedDataId (CHANX_COST_INDEX_START + seg_ind_x));
752
806
seg_index_[rr_graph.node_cost_index (node.id ())] = segment_id;
753
807
} else if (rr_graph.node_type (node.id ()) == CHANY) {
754
- rr_graph_builder_->set_node_cost_index (node_id, RRIndexedDataId (CHANX_COST_INDEX_START + segment_inf_.size () + segment_id));
808
+ int seg_ind_y = find_segment_index_along_axis (segment_id, Y_AXIS);
809
+ rr_graph_builder_->set_node_cost_index (node_id, RRIndexedDataId (CHANX_COST_INDEX_START + segment_inf_x_.size () + seg_ind_y));
755
810
seg_index_[rr_graph.node_cost_index (node.id ())] = segment_id;
756
811
}
757
812
return inode;
@@ -884,7 +939,7 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {
884
939
885
940
inline void * init_rr_graph_rr_nodes (void *& /* ctx*/ ) final {
886
941
rr_nodes_->clear ();
887
- seg_index_.resize (CHANX_COST_INDEX_START + 2 * segment_inf_ .size (), -1 );
942
+ seg_index_.resize (CHANX_COST_INDEX_START + segment_inf_x_. size () + segment_inf_y_ .size (), -1 );
888
943
return nullptr ;
889
944
}
890
945
inline void finish_rr_graph_rr_nodes (void *& /* ctx*/ ) final {
@@ -1612,22 +1667,13 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {
1612
1667
process_rr_node_indices ();
1613
1668
1614
1669
rr_graph_builder_->init_fan_in ();
1615
- /* Create a temp copy to convert from vtr::vector to std::vector
1616
- * This is required because the ``alloc_and_load_rr_indexed_data()`` function supports only std::vector data
1617
- * type for ``rr_segments``
1618
- * Note that this is a dirty fix (to avoid massive code changes)
1619
- * TODO: The ``alloc_and_load_rr_indexed_data()`` function should embrace ``vtr::vector`` for ``rr_segments``
1620
- */
1670
+
1621
1671
std::vector<t_segment_inf> temp_rr_segs;
1622
1672
temp_rr_segs.reserve (segment_inf_.size ());
1623
1673
for (auto & rr_seg : segment_inf_) {
1624
1674
temp_rr_segs.push_back (rr_seg);
1625
1675
}
1626
1676
1627
- t_unified_to_parallel_seg_index seg_index_map;
1628
- auto segment_inf_x_ = get_parallel_segs (temp_rr_segs, seg_index_map, X_AXIS);
1629
- auto segment_inf_y_ = get_parallel_segs (temp_rr_segs, seg_index_map, Y_AXIS);
1630
-
1631
1677
alloc_and_load_rr_indexed_data (
1632
1678
*rr_graph_,
1633
1679
grid_,
@@ -1972,6 +2018,8 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {
1972
2018
* the methods following routines:rr_graph_rr_nodes and init_node_segment according to the changes in
1973
2019
* rr_graph_indexed_data.cpp */
1974
2020
const vtr::vector<RRSegmentId, t_segment_inf>& segment_inf_;
2021
+ std::vector<t_segment_inf> segment_inf_x_; // [num_segs_along_x_axis-1:0] - vector of segment information for segments along the x-axis.
2022
+ std::vector<t_segment_inf> segment_inf_y_; // [num_segs_along_y_axis-1:0] - vector of segment information for segments along the y-axis.
1975
2023
const std::vector<t_physical_tile_type>& physical_tile_types_;
1976
2024
const DeviceGrid& grid_;
1977
2025
MetadataStorage<int >* rr_node_metadata_;
0 commit comments