Skip to content

Commit bbb7b4d

Browse files
committed
Add comments to the new functions and data structures
1 parent f6fb051 commit bbb7b4d

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

libs/librrgraph/src/io/rr_graph_uxsdcxx_serializer.h

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,12 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {
382382
side_map_[(1 << TOP) | (1 << RIGHT) | (1 << BOTTOM) | (1 << LEFT)] = uxsd::enum_loc_side::TOP_RIGHT_BOTTOM_LEFT;
383383
}
384384

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+
*/
385389
void init_segment_inf_x_y(){
390+
386391
/* Create a temp copy to convert from vtr::vector to std::vector
387392
* This is required because the ``alloc_and_load_rr_indexed_data()`` function supports only std::vector data
388393
* type for ``rr_segments``
@@ -401,7 +406,14 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {
401406

402407
}
403408

404-
int find_segment_index_along_axis(int seg_index, e_parallel_axis axis) const {
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 {
405417
const std::vector<t_segment_inf>* segment_inf_vec_ptr;
406418

407419
if (axis == X_AXIS)
@@ -410,10 +422,16 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {
410422
segment_inf_vec_ptr = &segment_inf_y_;
411423

412424
for(std::vector<t_segment_inf>::size_type i=0; i < (*segment_inf_vec_ptr).size(); i++){
413-
if((*segment_inf_vec_ptr)[i].seg_index == seg_index)
425+
if((*segment_inf_vec_ptr)[i].seg_index == segment_id)
414426
return static_cast<int>(i);
415427
}
416-
return 0;
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;
417435
}
418436

419437
public:
@@ -2000,8 +2018,8 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {
20002018
* the methods following routines:rr_graph_rr_nodes and init_node_segment according to the changes in
20012019
* rr_graph_indexed_data.cpp */
20022020
const vtr::vector<RRSegmentId, t_segment_inf>& segment_inf_;
2003-
std::vector<t_segment_inf> segment_inf_x_;
2004-
std::vector<t_segment_inf> segment_inf_y_;
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.
20052023
const std::vector<t_physical_tile_type>& physical_tile_types_;
20062024
const DeviceGrid& grid_;
20072025
MetadataStorage<int>* rr_node_metadata_;

0 commit comments

Comments
 (0)