Skip to content

Commit 80604ef

Browse files
Merge pull request #3001 from verilog-to-routing/temp_enum_class_rr_type
enum class rr_type
2 parents 444b9ac + 9f139f1 commit 80604ef

File tree

73 files changed

+945
-860
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+945
-860
lines changed

doc/src/api/vtrutil/containers.rst

+6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ vtr_vector
88
:project: vtr
99
:sections: briefdescription detaileddescription innernamespace innerclass public-func typedef func
1010

11+
vtr_array
12+
----------
13+
.. doxygenfile:: vtr_array.h
14+
:project: vtr
15+
:sections: briefdescription detaileddescription innernamespace innerclass public-func typedef func
16+
1117
vtr_small_vector
1218
----------------
1319
.. doxygenclass:: vtr::small_vector

libs/librrgraph/src/base/check_rr_graph.cpp

+54-62
Large diffs are not rendered by default.

libs/librrgraph/src/base/check_rr_graph_obj.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static bool check_rr_graph_source_nodes(const RRGraph& rr_graph) {
9494
*/
9595
for (auto node : rr_graph.nodes()) {
9696
/* Pass nodes whose types are not SOURCE */
97-
if (SOURCE != rr_graph.node_type(node)) {
97+
if (e_rr_type::SOURCE != rr_graph.node_type(node)) {
9898
continue;
9999
}
100100
if ((0 != rr_graph.node_fan_in(node))
@@ -123,7 +123,7 @@ static bool check_rr_graph_sink_nodes(const RRGraph& rr_graph) {
123123
*/
124124
for (auto node : rr_graph.nodes()) {
125125
/* Pass nodes whose types are not SINK */
126-
if (SINK != rr_graph.node_type(node)) {
126+
if (e_rr_type::SINK != rr_graph.node_type(node)) {
127127
continue;
128128
}
129129
if ((0 == rr_graph.node_fan_in(node))

libs/librrgraph/src/base/rr_graph_builder.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ MetadataStorage<std::tuple<int, int, short>>& RRGraphBuilder::rr_edge_metadata()
2626
}
2727

2828
void RRGraphBuilder::add_node_to_all_locs(RRNodeId node) {
29-
t_rr_type node_type = node_storage_.node_type(node);
29+
e_rr_type node_type = node_storage_.node_type(node);
3030
short node_ptc_num = node_storage_.node_ptc_num(node);
3131
short node_layer = node_storage_.node_layer(node);
3232
short node_twist = node_storage_.node_ptc_twist(node);
@@ -36,20 +36,20 @@ void RRGraphBuilder::add_node_to_all_locs(RRNodeId node) {
3636
node_ptc_num += node_twist * node_offset;
3737
node_offset++;
3838
switch (node_type) {
39-
case SOURCE:
40-
case SINK:
41-
case CHANY:
39+
case e_rr_type::SOURCE:
40+
case e_rr_type::SINK:
41+
case e_rr_type::CHANY:
4242
node_lookup_.add_node(node, node_layer, ix, iy, node_type, node_ptc_num, TOTAL_2D_SIDES[0]);
4343
break;
44-
case CHANX:
44+
case e_rr_type::CHANX:
4545
/* Currently need to swap x and y for CHANX because of chan, seg convention
4646
* TODO: Once the builders is reworked for use consistent (x, y) convention,
4747
* the following swapping can be removed
4848
*/
4949
node_lookup_.add_node(node, node_layer, iy, ix, node_type, node_ptc_num, TOTAL_2D_SIDES[0]);
5050
break;
51-
case OPIN:
52-
case IPIN:
51+
case e_rr_type::OPIN:
52+
case e_rr_type::IPIN:
5353
for (const e_side& side : TOTAL_2D_SIDES) {
5454
if (node_storage_.is_node_on_specific_side(node, side)) {
5555
node_lookup_.add_node(node,node_layer, ix, iy, node_type, node_ptc_num, side);

libs/librrgraph/src/base/rr_graph_builder.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class RRGraphBuilder {
119119
}
120120

121121
/** @brief Set the type of a node with a given valid id */
122-
inline void set_node_type(RRNodeId id, t_rr_type type) {
122+
inline void set_node_type(RRNodeId id, e_rr_type type) {
123123
node_storage_.set_node_type(id, type);
124124
}
125125

libs/librrgraph/src/base/rr_graph_obj.cpp

+35-32
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ RRGraph::segment_range RRGraph::segments() const {
3232
}
3333

3434
//Node attributes
35-
t_rr_type RRGraph::node_type(const RRNodeId& node) const {
35+
e_rr_type RRGraph::node_type(const RRNodeId& node) const {
3636
VTR_ASSERT_SAFE(valid_node_id(node));
3737
return node_types_[node];
3838
}
@@ -81,7 +81,7 @@ vtr::Rect<short> RRGraph::node_bounding_box(const RRNodeId& node) const {
8181
***********************************************************************/
8282
vtr::Point<short> RRGraph::node_start_coordinate(const RRNodeId& node) const {
8383
/* Make sure we have CHANX or CHANY */
84-
VTR_ASSERT((CHANX == node_type(node)) || (CHANY == node_type(node)));
84+
VTR_ASSERT((e_rr_type::CHANX == node_type(node)) || (e_rr_type::CHANY == node_type(node)));
8585

8686
vtr::Point<short> start_coordinate(node_xlow(node), node_ylow(node));
8787

@@ -105,7 +105,7 @@ vtr::Point<short> RRGraph::node_start_coordinate(const RRNodeId& node) const {
105105
***********************************************************************/
106106
vtr::Point<short> RRGraph::node_end_coordinate(const RRNodeId& node) const {
107107
/* Make sure we have CHANX or CHANY */
108-
VTR_ASSERT((CHANX == node_type(node)) || (CHANY == node_type(node)));
108+
VTR_ASSERT((e_rr_type::CHANX == node_type(node)) || (e_rr_type::CHANY == node_type(node)));
109109

110110
vtr::Point<short> end_coordinate(node_xhigh(node), node_yhigh(node));
111111

@@ -135,19 +135,19 @@ short RRGraph::node_ptc_num(const RRNodeId& node) const {
135135
}
136136

137137
short RRGraph::node_pin_num(const RRNodeId& node) const {
138-
VTR_ASSERT_MSG(node_type(node) == IPIN || node_type(node) == OPIN,
138+
VTR_ASSERT_MSG(node_type(node) == e_rr_type::IPIN || node_type(node) == e_rr_type::OPIN,
139139
"Pin number valid only for IPIN/OPIN RR nodes");
140140
return node_ptc_num(node);
141141
}
142142

143143
short RRGraph::node_track_num(const RRNodeId& node) const {
144-
VTR_ASSERT_MSG(node_type(node) == CHANX || node_type(node) == CHANY,
144+
VTR_ASSERT_MSG(node_type(node) == e_rr_type::CHANX || node_type(node) == e_rr_type::CHANY,
145145
"Track number valid only for CHANX/CHANY RR nodes");
146146
return node_ptc_num(node);
147147
}
148148

149149
short RRGraph::node_class_num(const RRNodeId& node) const {
150-
VTR_ASSERT_MSG(node_type(node) == SOURCE || node_type(node) == SINK, "Class number valid only for SOURCE/SINK RR nodes");
150+
VTR_ASSERT_MSG(node_type(node) == e_rr_type::SOURCE || node_type(node) == e_rr_type::SINK, "Class number valid only for SOURCE/SINK RR nodes");
151151
return node_ptc_num(node);
152152
}
153153

@@ -158,13 +158,13 @@ RRIndexedDataId RRGraph::node_cost_index(const RRNodeId& node) const {
158158

159159
Direction RRGraph::node_direction(const RRNodeId& node) const {
160160
VTR_ASSERT_SAFE(valid_node_id(node));
161-
VTR_ASSERT_MSG(node_type(node) == CHANX || node_type(node) == CHANY, "Direction valid only for CHANX/CHANY RR nodes");
161+
VTR_ASSERT_MSG(node_type(node) == e_rr_type::CHANX || node_type(node) == e_rr_type::CHANY, "Direction valid only for CHANX/CHANY RR nodes");
162162
return node_directions_[node];
163163
}
164164

165165
e_side RRGraph::node_side(const RRNodeId& node) const {
166166
VTR_ASSERT_SAFE(valid_node_id(node));
167-
VTR_ASSERT_MSG(node_type(node) == IPIN || node_type(node) == OPIN, "Side valid only for IPIN/OPIN RR nodes");
167+
VTR_ASSERT_MSG(node_type(node) == e_rr_type::IPIN || node_type(node) == e_rr_type::OPIN, "Side valid only for IPIN/OPIN RR nodes");
168168
return node_sides_[node];
169169
}
170170

@@ -372,11 +372,11 @@ std::vector<RREdgeId> RRGraph::find_edges(const RRNodeId& src_node, const RRNode
372372
return matching_edges;
373373
}
374374

375-
RRNodeId RRGraph::find_node(const short& x, const short& y, const t_rr_type& type, const int& ptc, const e_side& side) const {
375+
RRNodeId RRGraph::find_node(const short& x, const short& y, const e_rr_type type, const int& ptc, const e_side& side) const {
376376
initialize_fast_node_lookup();
377377

378-
size_t itype = type;
379-
size_t iside = side;
378+
const size_t itype = (size_t)type;
379+
const size_t iside = side;
380380

381381
/* Check if x, y, type and ptc, side is valid */
382382
if ((x < 0) /* See if x is smaller than the index of first element */
@@ -401,14 +401,14 @@ RRNodeId RRGraph::find_node(const short& x, const short& y, const t_rr_type& typ
401401

402402
/* Check if x, y, type and ptc, side is valid */
403403
if ((ptc < 0) /* See if ptc is smaller than the index of first element */
404-
|| (size_t(ptc) > node_lookup_[x][y][type].size() - 1)) { /* See if ptc is large than the index of last element */
404+
|| (size_t(ptc) > node_lookup_[x][y][itype].size() - 1)) { /* See if ptc is large than the index of last element */
405405
/* Return a zero range! */
406406
return RRNodeId::INVALID();
407407
}
408408

409409
/* Check if x, y, type and ptc, side is valid */
410410
/* iside is always larger than -1, we can skip checking */
411-
if (iside > node_lookup_[x][y][type][ptc].size() - 1) { /* See if side is large than the index of last element */
411+
if (iside > node_lookup_[x][y][itype][ptc].size() - 1) { /* See if side is large than the index of last element */
412412
/* Return a zero range! */
413413
return RRNodeId::INVALID();
414414
}
@@ -417,9 +417,9 @@ RRNodeId RRGraph::find_node(const short& x, const short& y, const t_rr_type& typ
417417
}
418418

419419
/* Find the channel width (number of tracks) of a channel [x][y] */
420-
short RRGraph::chan_num_tracks(const short& x, const short& y, const t_rr_type& type) const {
420+
short RRGraph::chan_num_tracks(const short& x, const short& y, const e_rr_type& type) const {
421421
/* Must be CHANX or CHANY */
422-
VTR_ASSERT_MSG(CHANX == type || CHANY == type,
422+
VTR_ASSERT_MSG(e_rr_type::CHANX == type || e_rr_type::CHANY == type,
423423
"Required node_type to be CHANX or CHANY!");
424424
initialize_fast_node_lookup();
425425

@@ -432,18 +432,18 @@ short RRGraph::chan_num_tracks(const short& x, const short& y, const t_rr_type&
432432

433433
/* Check if x, y, type and ptc is valid */
434434
if ((y < 0) /* See if y is smaller than the index of first element */
435-
|| (size_t(y) > node_lookup_[x].size() - 1)) { /* See if y is large than the index of last element */
435+
|| (size_t(y) > node_lookup_[x].size() - 1)) { /* See if y is larger than the index of last element */
436436
/* Return a zero range! */
437437
return 0;
438438
}
439439

440440
/* Check if x, y, type and ptc is valid */
441-
if ((size_t(type) > node_lookup_[x][y].size() - 1)) { /* See if type is large than the index of last element */
441+
if ((size_t(type) > node_lookup_[x][y].size() - 1)) { /* See if type is larger than the index of last element */
442442
/* Return a zero range! */
443443
return 0;
444444
}
445445

446-
const auto& matching_nodes = node_lookup_[x][y][type];
446+
const auto& matching_nodes = node_lookup_[x][y][(size_t)type];
447447

448448
return vtr::make_range(matching_nodes.begin(), matching_nodes.end()).size();
449449
}
@@ -465,8 +465,8 @@ void RRGraph::print_node(const RRNodeId& node) const {
465465
bool RRGraph::validate_node_segment(const RRNodeId& node) const {
466466
VTR_ASSERT_SAFE(valid_node_id(node));
467467
/* Only CHANX and CHANY requires a valid segment id */
468-
if ((CHANX == node_type(node))
469-
|| (CHANY == node_type(node))) {
468+
if ((e_rr_type::CHANX == node_type(node))
469+
|| (e_rr_type::CHANY == node_type(node))) {
470470
return valid_segment_id(node_segments_[node]);
471471
} else {
472472
return true;
@@ -477,7 +477,7 @@ bool RRGraph::validate_node_segment(const RRNodeId& node) const {
477477
bool RRGraph::validate_node_segments() const {
478478
bool all_valid = true;
479479
for (auto node : nodes()) {
480-
if (true == validate_node_segment(node)) {
480+
if (validate_node_segment(node)) {
481481
continue;
482482
}
483483
/* Reach here it means we find an invalid segment id */
@@ -499,7 +499,7 @@ bool RRGraph::validate_edge_switch(const RREdgeId& edge) const {
499499
bool RRGraph::validate_edge_switches() const {
500500
bool all_valid = true;
501501
for (auto edge : edges()) {
502-
if (true == validate_edge_switch(edge)) {
502+
if (validate_edge_switch(edge)) {
503503
continue;
504504
}
505505
/* Reach here it means we find an invalid segment id */
@@ -798,7 +798,7 @@ void RRGraph::reserve_segments(const int& num_segments) {
798798
}
799799

800800
/* Mutators */
801-
RRNodeId RRGraph::create_node(const t_rr_type& type) {
801+
RRNodeId RRGraph::create_node(const e_rr_type& type) {
802802
//Allocate an ID
803803
RRNodeId node_id = RRNodeId(node_ids_.size());
804804

@@ -971,21 +971,24 @@ void RRGraph::set_node_ptc_num(const RRNodeId& node, const short& ptc) {
971971

972972
void RRGraph::set_node_pin_num(const RRNodeId& node, const short& pin_id) {
973973
VTR_ASSERT(valid_node_id(node));
974-
VTR_ASSERT_MSG(node_type(node) == IPIN || node_type(node) == OPIN, "Pin number valid only for IPIN/OPIN RR nodes");
974+
VTR_ASSERT_MSG(node_type(node) == e_rr_type::IPIN || node_type(node) == e_rr_type::OPIN,
975+
"Pin number valid only for IPIN/OPIN RR nodes");
975976

976977
set_node_ptc_num(node, pin_id);
977978
}
978979

979980
void RRGraph::set_node_track_num(const RRNodeId& node, const short& track_id) {
980981
VTR_ASSERT(valid_node_id(node));
981-
VTR_ASSERT_MSG(node_type(node) == CHANX || node_type(node) == CHANY, "Track number valid only for CHANX/CHANY RR nodes");
982+
VTR_ASSERT_MSG(node_type(node) == e_rr_type::CHANX || node_type(node) == e_rr_type::CHANY,
983+
"Track number valid only for CHANX/CHANY RR nodes");
982984

983985
set_node_ptc_num(node, track_id);
984986
}
985987

986988
void RRGraph::set_node_class_num(const RRNodeId& node, const short& class_id) {
987989
VTR_ASSERT(valid_node_id(node));
988-
VTR_ASSERT_MSG(node_type(node) == SOURCE || node_type(node) == SINK, "Class number valid only for SOURCE/SINK RR nodes");
990+
VTR_ASSERT_MSG(node_type(node) == e_rr_type::SOURCE || node_type(node) == e_rr_type::SINK,
991+
"Class number valid only for SOURCE/SINK RR nodes");
989992

990993
set_node_ptc_num(node, class_id);
991994
}
@@ -997,14 +1000,14 @@ void RRGraph::set_node_cost_index(const RRNodeId& node, const RRIndexedDataId& c
9971000

9981001
void RRGraph::set_node_direction(const RRNodeId& node, const Direction& direction) {
9991002
VTR_ASSERT(valid_node_id(node));
1000-
VTR_ASSERT_MSG(node_type(node) == CHANX || node_type(node) == CHANY, "Direct can only be specified on CHANX/CNAY rr nodes");
1003+
VTR_ASSERT_MSG(node_type(node) == e_rr_type::CHANX || node_type(node) == e_rr_type::CHANY, "Direct can only be specified on CHANX/CNAY rr nodes");
10011004

10021005
node_directions_[node] = direction;
10031006
}
10041007

10051008
void RRGraph::set_node_side(const RRNodeId& node, const e_side& side) {
10061009
VTR_ASSERT(valid_node_id(node));
1007-
VTR_ASSERT_MSG(node_type(node) == IPIN || node_type(node) == OPIN, "Side can only be specified on IPIN/OPIN rr nodes");
1010+
VTR_ASSERT_MSG(node_type(node) == e_rr_type::IPIN || node_type(node) == e_rr_type::OPIN, "Side can only be specified on IPIN/OPIN rr nodes");
10081011

10091012
node_sides_[node] = side;
10101013
}
@@ -1028,8 +1031,8 @@ void RRGraph::set_node_segment(const RRNodeId& node, const RRSegmentId& segment_
10281031
VTR_ASSERT(valid_node_id(node));
10291032

10301033
/* Only CHANX and CHANY requires a valid segment id */
1031-
if ((CHANX == node_type(node))
1032-
|| (CHANY == node_type(node))) {
1034+
if ((e_rr_type::CHANX == node_type(node))
1035+
|| (e_rr_type::CHANY == node_type(node))) {
10331036
VTR_ASSERT(valid_segment_id(segment_id));
10341037
}
10351038

@@ -1119,7 +1122,7 @@ void RRGraph::build_fast_node_lookup() const {
11191122
node_lookup_[x].resize(y + 1);
11201123
}
11211124

1122-
size_t itype = node_type(node);
1125+
size_t itype = (size_t)node_type(node);
11231126
if (itype >= node_lookup_[x][y].size()) {
11241127
node_lookup_[x][y].resize(itype + 1);
11251128
}
@@ -1130,7 +1133,7 @@ void RRGraph::build_fast_node_lookup() const {
11301133
}
11311134

11321135
size_t iside = -1;
1133-
if (node_type(node) == OPIN || node_type(node) == IPIN) {
1136+
if (node_type(node) == e_rr_type::OPIN || node_type(node) == e_rr_type::IPIN) {
11341137
iside = node_side(node);
11351138
} else {
11361139
iside = NUM_2D_SIDES;

libs/librrgraph/src/base/rr_graph_obj.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
* // Get the unique node id that you may get
6161
* // from other data structures or functions
6262
* RRNodeId node_id;
63-
* t_rr_type node_type = rr_graph.node_type(node_id);
63+
* e_rr_type node_type = rr_graph.node_type(node_id);
6464
*
6565
* // Access all the fan-out edges from a given node
6666
* for (const RREdgeId& out_edge_id : rr_graph.node_out_edges(node_id)) {
@@ -257,9 +257,9 @@ class RRGraph {
257257

258258
/* get the type of a RRGraph node : types of each node, can be channel wires (CHANX or CHANY) or
259259
* logic block pins(OPIN or IPIN) or virtual nodes (SOURCE or SINK)
260-
* see t_rr_type definition for more details
260+
* see e_rr_type definition for more details
261261
*/
262-
t_rr_type node_type(const RRNodeId& node) const;
262+
e_rr_type node_type(const RRNodeId& node) const;
263263

264264
/* Get coordinate of a node. (xlow, xhigh, ylow, yhigh):
265265
* For OPIN/IPIN/SOURCE/SINK, xlow = xhigh and ylow = yhigh
@@ -510,9 +510,9 @@ class RRGraph {
510510
/* Find the edges connecting two nodes */
511511
std::vector<RREdgeId> find_edges(const RRNodeId& src_node, const RRNodeId& sink_node) const;
512512
/* Find a node with given features from internal fast look-up */
513-
RRNodeId find_node(const short& x, const short& y, const t_rr_type& type, const int& ptc, const e_side& side = NUM_2D_SIDES) const;
513+
RRNodeId find_node(const short& x, const short& y, const e_rr_type type, const int& ptc, const e_side& side = NUM_2D_SIDES) const;
514514
/* Find the number of routing tracks in a routing channel with a given coordinate */
515-
short chan_num_tracks(const short& x, const short& y, const t_rr_type& type) const;
515+
short chan_num_tracks(const short& x, const short& y, const e_rr_type& type) const;
516516

517517
/* This flag is raised when the RRgraph contains invalid nodes/edges etc.
518518
* Invalid nodes/edges exist when users remove nodes/edges from RRGraph
@@ -589,7 +589,7 @@ class RRGraph {
589589
* RRNodeId node = create_node();
590590
* set_node_xlow(node, 0);
591591
*/
592-
RRNodeId create_node(const t_rr_type& type);
592+
RRNodeId create_node(const e_rr_type& type);
593593
/* Add a edge to the RRGraph, by providing the source and sink node
594594
* This function will automatically create a node and
595595
* configure the nodes and edges in connection
@@ -782,7 +782,7 @@ class RRGraph {
782782
private: /* Internal Data */
783783
/* Node related data */
784784
vtr::vector<RRNodeId, RRNodeId> node_ids_; /* Unique identifiers for the nodes */
785-
vtr::vector<RRNodeId, t_rr_type> node_types_;
785+
vtr::vector<RRNodeId, e_rr_type> node_types_;
786786

787787
vtr::vector<RRNodeId, vtr::Rect<short>> node_bounding_boxes_;
788788

0 commit comments

Comments
 (0)