Skip to content

Commit adec8f6

Browse files
committed
[vpr][route] fix formatting issues in tileable rr graph
1 parent 4c66882 commit adec8f6

File tree

12 files changed

+446
-446
lines changed

12 files changed

+446
-446
lines changed

libs/librrgraph/src/io/rr_graph_uxsdcxx_serializer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1846,14 +1846,14 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {
18461846
void process_rr_node_indices() {
18471847
auto& rr_graph_builder = (*rr_graph_builder_);
18481848

1849-
/* Alloc the lookup table */
1849+
// Alloc the lookup table
18501850
for (e_rr_type rr_type : RR_TYPES) {
18511851
rr_graph_builder.node_lookup().resize_nodes(grid_.get_num_layers(), grid_.width(), grid_.height(), rr_type, NUM_2D_SIDES);
18521852
}
18531853

1854-
/* Add the correct node into the vector */
1854+
// Add the correct node into the vector
18551855
for (const t_rr_node& node : *rr_nodes_) {
1856-
/* Set track numbers as a node may have multiple ptc */
1856+
// Set track numbers as a node may have multiple ptc
18571857
if (rr_graph_builder.node_contain_multiple_ptc(node.id())) {
18581858
if (rr_graph_->node_type(node.id()) == e_rr_type::CHANX || rr_graph_->node_type(node.id()) == e_rr_type::CHANY) {
18591859
rr_graph_builder.add_track_node_to_lookup(node.id());

vpr/src/base/read_blif.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -644,47 +644,47 @@ vtr::LogicValue to_vtr_logic_value(blifparse::LogicValue val) {
644644
}
645645

646646
bool is_string_param(const std::string& param) {
647-
/* Empty param is considered a string */
647+
// Empty param is considered a string
648648
if (param.empty()) {
649649
return true;
650650
}
651651

652-
/* There have to be at least 2 characters (the quotes) */
652+
// There have to be at least 2 characters (the quotes)
653653
if (param.length() < 2) {
654654
return false;
655655
}
656656

657-
/* The first and the last characters must be quotes */
657+
// The first and the last characters must be quotes
658658
size_t len = param.length();
659659
if (param[0] != '"' || param[len - 1] != '"') {
660660
return false;
661661
}
662662

663-
/* There mustn't be any other quotes except for escaped ones */
663+
// There mustn't be any other quotes except for escaped ones
664664
for (size_t i = 1; i < (len - 1); ++i) {
665665
if (param[i] == '"' && param[i - 1] != '\\') {
666666
return false;
667667
}
668668
}
669669

670-
/* This is a string param */
670+
// This is a string param
671671
return true;
672672
}
673673

674674
bool is_binary_param(const std::string& param) {
675-
/* Must be non-empty */
675+
// Must be non-empty
676676
if (param.empty()) {
677677
return false;
678678
}
679679

680-
/* The string must contain only '0' and '1' */
680+
// The string must contain only '0' and '1'
681681
for (size_t i = 0; i < param.length(); ++i) {
682682
if (param[i] != '0' && param[i] != '1') {
683683
return false;
684684
}
685685
}
686686

687-
/* This is a binary word param */
687+
// This is a binary word param
688688
return true;
689689
}
690690

@@ -694,13 +694,13 @@ bool is_real_param(const std::string& param) {
694694
return false;
695695
}
696696

697-
/* The string must match the regular expression */
697+
// The string must match the regular expression
698698
const std::regex real_number_expr("[+-]?([0-9]*\\.[0-9]+)|([0-9]+\\.[0-9]*)");
699699
if (!std::regex_match(param, real_number_expr)) {
700700
return false;
701701
}
702702

703-
/* This is a real number param */
703+
// This is a real number param
704704
return true;
705705
}
706706

vpr/src/base/vpr_context.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,7 @@ struct DeviceContext : public Context {
254254
rr_graph_builder.node_in_edge_storage(),
255255
rr_graph_builder.node_ptc_storage()};
256256

257-
/* Track ids for each rr_node in the rr_graph.
258-
* This is used by drawer for tileable routing resource graph
259-
*/
257+
///@brief Track ids for each rr_node in the rr_graph. This is used by drawer for tileable routing resource graph
260258
std::map<RRNodeId, std::vector<size_t>> rr_node_track_ids;
261259

262260
std::vector<t_arch_switch_inf> arch_switch_inf; // [0..(num_arch_switches-1)]

vpr/src/draw/draw.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1227,7 +1227,7 @@ static void run_graphics_commands(const std::string& commands) {
12271227
t_draw_state backup_draw_state = *draw_state;
12281228

12291229
std::vector<std::vector<std::string>> cmds;
1230-
for (std::string raw_cmd : vtr::StringToken(commands).split(";")) {
1230+
for (const std::string& raw_cmd : vtr::StringToken(commands).split(";")) {
12311231
cmds.push_back(vtr::StringToken(raw_cmd).split(" \t\n"));
12321232
}
12331233

vpr/src/route/rr_graph_generation/rr_graph.cpp

Lines changed: 220 additions & 231 deletions
Large diffs are not rendered by default.

vpr/src/route/rr_graph_generation/tileable_rr_graph/device_grid_annotation.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
#include "vtr_log.h"
33
#include "vpr_utils.h"
44

5-
DeviceGridAnnotation::DeviceGridAnnotation(const DeviceGrid& grid, const bool& perimeter_cb) {
5+
DeviceGridAnnotation::DeviceGridAnnotation(const DeviceGrid& grid, const bool perimeter_cb) {
66
alloc(grid);
77
init(grid, perimeter_cb);
88
}
99

1010
void DeviceGridAnnotation::alloc(const DeviceGrid& grid) {
11-
/* Allocate */
11+
// Allocate
1212
chanx_existence_.resize({grid.width(), grid.height()}, false);
1313
chany_existence_.resize({grid.width(), grid.height()}, false);
1414
}
1515

16-
void DeviceGridAnnotation::init(const DeviceGrid& grid, const bool& perimeter_cb) {
17-
/* If shrink is not considered, perimeters are the borderlines */
16+
void DeviceGridAnnotation::init(const DeviceGrid& grid, const bool perimeter_cb) {
17+
// If shrink is not considered, perimeters are the borderlines
1818
size_t start_x = 1;
1919
size_t end_x = grid.width() - 1;
2020
if (perimeter_cb) {
Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
#pragma once
22

3-
/********************************************************************
4-
* Include header files required by the data structure definition
5-
*******************************************************************/
63
#include <array>
74
#include "vtr_geometry.h"
85
#include "vtr_ndmatrix.h"
@@ -13,14 +10,14 @@
1310
* - Border of the device grid (check where the empty types cover the perimeters)
1411
*/
1512
class DeviceGridAnnotation {
16-
public: /* Constructor */
17-
DeviceGridAnnotation(const DeviceGrid& grid, const bool& perimeter_cb);
13+
public: // Constructor
14+
DeviceGridAnnotation(const DeviceGrid& grid, const bool perimeter_cb);
1815

19-
private: /* Private mutators */
16+
private: // Private mutators
2017
void alloc(const DeviceGrid& grid);
21-
void init(const DeviceGrid& grid, const bool& perimeter_cb);
18+
void init(const DeviceGrid& grid, const bool perimeter_cb);
2219

23-
public: /* Public accessors */
20+
public: // Public accessors
2421
/** @brief Check if at a given coordinate, a X-direction routing channel should exist or not */
2522
bool is_chanx_exist(const vtr::Point<size_t>& coord) const;
2623
bool is_chanx_start(const vtr::Point<size_t>& coord) const;
@@ -30,10 +27,10 @@ class DeviceGridAnnotation {
3027
bool is_chany_start(const vtr::Point<size_t>& coord) const;
3128
bool is_chany_end(const vtr::Point<size_t>& coord) const;
3229

33-
private: /* Private validators */
30+
private: // Private validators
3431
vtr::Point<size_t> get_neighbor_coord(const vtr::Point<size_t>& coord, const e_side& side) const;
3532

36-
private: /* Internal data */
33+
private: // Internal data
3734
vtr::NdMatrix<bool, 2> chanx_existence_;
3835
vtr::NdMatrix<bool, 2> chany_existence_;
3936
};

vpr/src/route/rr_graph_generation/tileable_rr_graph/rr_chan.cpp

Lines changed: 29 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ size_t RRChan::get_chan_width() const {
2828
}
2929

3030
/* get the track_id of a node */
31-
int RRChan::get_node_track_id(const RRNodeId& node) const {
31+
int RRChan::get_node_track_id(const RRNodeId node) const {
3232
/* if the given node is NULL, we return an invalid id */
3333
if (RRNodeId::INVALID() == node) {
3434
return -1;
@@ -42,15 +42,15 @@ int RRChan::get_node_track_id(const RRNodeId& node) const {
4242
}
4343

4444
/* get the rr_node with the track_id */
45-
RRNodeId RRChan::get_node(const size_t& track_num) const {
45+
RRNodeId RRChan::get_node(const size_t track_num) const {
4646
if (false == valid_node_id(track_num)) {
4747
return RRNodeId::INVALID();
4848
}
4949
return nodes_[track_num];
5050
}
5151

5252
/* get the segment id of a node */
53-
RRSegmentId RRChan::get_node_segment(const RRNodeId& node) const {
53+
RRSegmentId RRChan::get_node_segment(const RRNodeId node) const {
5454
int node_id = get_node_track_id(node);
5555
if (false == valid_node_id(node_id)) {
5656
return RRSegmentId::INVALID();
@@ -59,7 +59,7 @@ RRSegmentId RRChan::get_node_segment(const RRNodeId& node) const {
5959
}
6060

6161
/* get the segment id of a node */
62-
RRSegmentId RRChan::get_node_segment(const size_t& track_num) const {
62+
RRSegmentId RRChan::get_node_segment(const size_t track_num) const {
6363
if (false == valid_node_id(track_num)) {
6464
return RRSegmentId::INVALID();
6565
}
@@ -70,14 +70,10 @@ RRSegmentId RRChan::get_node_segment(const size_t& track_num) const {
7070
std::vector<RRSegmentId> RRChan::get_segment_ids() const {
7171
std::vector<RRSegmentId> seg_list;
7272

73-
/* make sure a clean start */
74-
seg_list.clear();
75-
7673
/* Traverse node_segments */
7774
for (size_t inode = 0; inode < get_chan_width(); ++inode) {
78-
std::vector<RRSegmentId>::iterator it;
7975
/* Try to find the node_segment id in the list */
80-
it = find(seg_list.begin(), seg_list.end(), node_segments_[inode]);
76+
auto it = find(seg_list.begin(), seg_list.end(), node_segments_[inode]);
8177
if (it == seg_list.end()) {
8278
/* Not found, add it to the list */
8379
seg_list.push_back(node_segments_[inode]);
@@ -88,15 +84,12 @@ std::vector<RRSegmentId> RRChan::get_segment_ids() const {
8884
}
8985

9086
/* Get a list of nodes whose segment_id is specified */
91-
std::vector<size_t> RRChan::get_node_ids_by_segment_ids(const RRSegmentId& seg_id) const {
87+
std::vector<size_t> RRChan::get_node_ids_by_segment_ids(const RRSegmentId seg_id) const {
9288
std::vector<size_t> node_list;
9389

94-
/* make sure a clean start */
95-
node_list.clear();
96-
97-
/* Traverse node_segments */
90+
// Traverse node_segments
9891
for (size_t inode = 0; inode < get_chan_width(); ++inode) {
99-
/* Try to find the node_segment id in the list */
92+
// Try to find the node_segment id in the list
10093
if (seg_id == node_segments_[inode]) {
10194
node_list.push_back(inode);
10295
}
@@ -109,35 +102,34 @@ std::vector<size_t> RRChan::get_node_ids_by_segment_ids(const RRSegmentId& seg_i
109102
* Mutators
110103
***********************************************************************/
111104
void RRChan::set(const RRChan& rr_chan) {
112-
/* Ensure a clean start */
113-
this->clear();
114-
/* Assign type of this routing channel */
115-
this->type_ = rr_chan.get_type();
116-
/* Copy node and node_segments */
117-
this->nodes_.resize(rr_chan.get_chan_width());
118-
this->node_segments_.resize(rr_chan.get_chan_width());
105+
// Ensure a clean start
106+
clear();
107+
// Assign type of this routing channel
108+
type_ = rr_chan.get_type();
109+
// Copy node and node_segments
110+
nodes_.resize(rr_chan.get_chan_width());
111+
node_segments_.resize(rr_chan.get_chan_width());
119112
for (size_t inode = 0; inode < rr_chan.get_chan_width(); ++inode) {
120-
this->nodes_[inode] = rr_chan.get_node(inode);
121-
this->node_segments_[inode] = rr_chan.get_node_segment(inode);
113+
nodes_[inode] = rr_chan.get_node(inode);
114+
node_segments_[inode] = rr_chan.get_node_segment(inode);
122115
}
123-
return;
124116
}
125117

126118
/* modify type */
127-
void RRChan::set_type(const e_rr_type& type) {
128-
VTR_ASSERT(valid_type(type));
119+
void RRChan::set_type(const e_rr_type type) {
120+
VTR_ASSERT(is_rr_type_valid(type));
129121
type_ = type;
130122
}
131123

132124
/* Reserve node list */
133-
void RRChan::reserve_node(const size_t& node_size) {
134-
nodes_.reserve(node_size); /* reserve to the maximum */
135-
node_segments_.reserve(node_size); /* reserve to the maximum */
125+
void RRChan::reserve_node(const size_t node_size) {
126+
nodes_.reserve(node_size);
127+
node_segments_.reserve(node_size);
136128
}
137129

138130
/* add a node to the array */
139-
void RRChan::add_node(const RRGraphView& rr_graph, const RRNodeId& node, const RRSegmentId& node_segment) {
140-
/* fill the dedicated element in the vector */
131+
void RRChan::add_node(const RRGraphView& rr_graph, const RRNodeId node, const RRSegmentId node_segment) {
132+
// fill the dedicated element in the vector
141133
nodes_.push_back(node);
142134
node_segments_.push_back(node_segment);
143135

@@ -160,28 +152,28 @@ void RRChan::clear() {
160152
* Internal validators
161153
***********************************************************************/
162154
/* for type, only valid type is CHANX and CHANY */
163-
bool RRChan::valid_type(const e_rr_type& type) const {
155+
bool RRChan::is_rr_type_valid(const e_rr_type type) const {
164156
if ((e_rr_type::CHANX == type) || (e_rr_type::CHANY == type)) {
165157
return true;
166158
}
167159
return false;
168160
}
169161

170162
/* Check each node, see if the node type is consistent with the type */
171-
bool RRChan::valid_node_type(const RRGraphView& rr_graph, const RRNodeId& node) const {
172-
valid_type(rr_graph.node_type(node));
163+
bool RRChan::valid_node_type(const RRGraphView& rr_graph, const RRNodeId node) const {
164+
is_rr_type_valid(rr_graph.node_type(node));
173165
if (e_rr_type::NUM_RR_TYPES == type_) {
174166
return true;
175167
}
176-
valid_type(type_);
168+
is_rr_type_valid(type_);
177169
if (type_ != rr_graph.node_type(node)) {
178170
return false;
179171
}
180172
return true;
181173
}
182174

183175
/* check if the node id is valid */
184-
bool RRChan::valid_node_id(const size_t& node_id) const {
176+
bool RRChan::valid_node_id(const size_t node_id) const {
185177
if (node_id < nodes_.size()) {
186178
return true;
187179
}

0 commit comments

Comments
 (0)