Skip to content

Commit 1bae57a

Browse files
committed
[vpr][route][crr] rename side to e_sw_template_side
1 parent 0e30395 commit 1bae57a

File tree

4 files changed

+72
-43
lines changed

4 files changed

+72
-43
lines changed

vpr/src/route/rr_graph_generation/tileable_rr_graph/crr_generator/crr_common.h

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

33
#include <vector>
4+
#include <array>
45

56
#include "rr_graph_fwd.h"
67
#include "rr_node_types.h"
@@ -30,14 +31,16 @@ constexpr int DEFAULT_SWITCH_DELAY_MIN = 10000;
3031
enum class Direction { INC_DIR,
3132
DEC_DIR };
3233

33-
// Side types
34-
enum class Side { LEFT,
35-
RIGHT,
36-
TOP,
37-
BOTTOM,
38-
IPIN,
39-
OPIN,
40-
INVALID };
34+
// e_sw_template_side types
35+
enum class e_sw_template_side {LEFT = 0,
36+
RIGHT,
37+
TOP,
38+
BOTTOM,
39+
IPIN,
40+
OPIN,
41+
NUM_SIDES};
42+
43+
constexpr std::array<e_sw_template_side, (size_t)e_sw_template_side::NUM_SIDES> SIDE
4144

4245
// Location structure
4346
struct Location {

vpr/src/route/rr_graph_generation/tileable_rr_graph/crr_generator/crr_connection_builder.cpp

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,19 @@ std::map<size_t, RRNodeId> CRRConnectionBuilder::get_vertical_nodes(Coordinate x
153153
std::map<size_t, RRNodeId> source_nodes;
154154
std::string prev_seg_type = "";
155155
int prev_seg_index = -1;
156-
Side prev_side = Side::INVALID;
156+
e_sw_template_side prev_side = e_sw_template_side::NUM_SIDES;
157157
int prev_ptc_number = 0;
158158

159159
for (size_t row = NUM_EMPTY_ROWS; row < df.rows(); ++row) {
160160
SegmentInfo info = parse_segment_info(df, row, true);
161161
RRNodeId node_id;
162162

163-
if (info.side == Side::IPIN || info.side == Side::OPIN) {
163+
if (info.side == e_sw_template_side::IPIN || info.side == e_sw_template_side::OPIN) {
164164
node_id = process_opin_ipin_node(info, x, y, node_lookup);
165-
} else if (info.side == Side::LEFT || info.side == Side::RIGHT || info.side == Side::TOP || info.side == Side::BOTTOM) {
165+
} else if (info.side == e_sw_template_side::LEFT ||
166+
info.side == e_sw_template_side::RIGHT ||
167+
info.side == e_sw_template_side::TOP ||
168+
info.side == e_sw_template_side::BOTTOM) {
166169
node_id = process_channel_node(info, x, y, node_lookup, prev_seg_index,
167170
prev_side, prev_seg_type, prev_ptc_number, true);
168171
}
@@ -185,19 +188,22 @@ std::map<size_t, RRNodeId> CRRConnectionBuilder::get_horizontal_nodes(Coordinate
185188
std::map<size_t, RRNodeId> sink_nodes;
186189
std::string prev_seg_type = "";
187190
int prev_seg_index = -1;
188-
Side prev_side = Side::INVALID;
191+
e_sw_template_side prev_side = e_sw_template_side::NUM_SIDES;
189192
int prev_ptc_number = 0;
190193

191194
for (size_t col = NUM_EMPTY_COLS; col < df.cols(); ++col) {
192195
SegmentInfo info = parse_segment_info(df, col, false);
193-
if (info.side == Side::INVALID) {
196+
if (info.side == e_sw_template_side::NUM_SIDES) {
194197
continue;
195198
}
196199
RRNodeId node_id;
197200

198-
if (info.side == Side::IPIN) {
201+
if (info.side == e_sw_template_side::IPIN) {
199202
node_id = process_opin_ipin_node(info, x, y, node_lookup);
200-
} else if (info.side == Side::LEFT || info.side == Side::RIGHT || info.side == Side::TOP || info.side == Side::BOTTOM) {
203+
} else if (info.side == e_sw_template_side::LEFT ||
204+
info.side == e_sw_template_side::RIGHT ||
205+
info.side == e_sw_template_side::TOP ||
206+
info.side == e_sw_template_side::BOTTOM) {
201207
node_id = process_channel_node(info, x, y, node_lookup, prev_seg_index,
202208
prev_side, prev_seg_type, prev_ptc_number,
203209
false);
@@ -269,8 +275,8 @@ RRNodeId CRRConnectionBuilder::process_opin_ipin_node(const SegmentInfo& info,
269275
Coordinate x,
270276
Coordinate y,
271277
const std::unordered_map<NodeHash, RRNodeId, NodeHasher>& node_lookup) const {
272-
VTR_ASSERT(info.side == Side::OPIN || info.side == Side::IPIN);
273-
e_rr_type node_type = (info.side == Side::OPIN) ? e_rr_type::OPIN : e_rr_type::IPIN;
278+
VTR_ASSERT(info.side == e_sw_template_side::OPIN || info.side == e_sw_template_side::IPIN);
279+
e_rr_type node_type = (info.side == e_sw_template_side::OPIN) ? e_rr_type::OPIN : e_rr_type::IPIN;
274280
NodeHash hash = std::make_tuple(node_type,
275281
std::to_string(info.seg_index),
276282
x, x, y, y);
@@ -288,12 +294,12 @@ RRNodeId CRRConnectionBuilder::process_channel_node(const SegmentInfo& info,
288294
Coordinate y,
289295
const std::unordered_map<NodeHash, RRNodeId, NodeHasher>& node_lookup,
290296
int& prev_seg_index,
291-
Side& prev_side,
297+
e_sw_template_side& prev_side,
292298
std::string& prev_seg_type,
293299
int& prev_ptc_number,
294300
bool is_vertical) const {
295301
// Check grid boundaries
296-
if ((info.side == Side::RIGHT && x == fpga_grid_x_) || (info.side == Side::TOP && y == fpga_grid_y_)) {
302+
if ((info.side == e_sw_template_side::RIGHT && x == fpga_grid_x_) || (info.side == e_sw_template_side::TOP && y == fpga_grid_y_)) {
297303
return RRNodeId::INVALID();
298304
}
299305

@@ -361,25 +367,25 @@ void CRRConnectionBuilder::calculate_segment_coordinates(const SegmentInfo& info
361367
// Calculate initial coordinates based on side
362368
if (is_vertical) {
363369
switch (info.side) {
364-
case Side::LEFT:
370+
case e_sw_template_side::LEFT:
365371
x_high = x + (seg_length - tap);
366372
x_low = x - (tap - 1);
367373
y_high = y;
368374
y_low = y;
369375
break;
370-
case Side::RIGHT:
376+
case e_sw_template_side::RIGHT:
371377
x_high = x + tap;
372378
x_low = x + tap + 1 - seg_length;
373379
y_high = y;
374380
y_low = y;
375381
break;
376-
case Side::TOP:
382+
case e_sw_template_side::TOP:
377383
x_high = x;
378384
x_low = x;
379385
y_high = y + tap;
380386
y_low = y + 1 - seg_length + tap;
381387
break;
382-
case Side::BOTTOM:
388+
case e_sw_template_side::BOTTOM:
383389
x_high = x;
384390
x_low = x;
385391
y_high = y + seg_length - tap;
@@ -392,25 +398,25 @@ void CRRConnectionBuilder::calculate_segment_coordinates(const SegmentInfo& info
392398
}
393399
} else {
394400
switch (info.side) {
395-
case Side::LEFT:
401+
case e_sw_template_side::LEFT:
396402
x_high = x + tap - 1;
397403
x_low = x - seg_length + tap;
398404
y_high = y;
399405
y_low = y;
400406
break;
401-
case Side::RIGHT:
407+
case e_sw_template_side::RIGHT:
402408
x_high = x + seg_length;
403409
x_low = x + 1;
404410
y_high = y;
405411
y_low = y;
406412
break;
407-
case Side::TOP:
413+
case e_sw_template_side::TOP:
408414
x_high = x;
409415
x_low = x;
410416
y_high = y + seg_length;
411417
y_low = y + 1;
412418
break;
413-
case Side::BOTTOM:
419+
case e_sw_template_side::BOTTOM:
414420
x_high = x;
415421
x_low = x;
416422
y_high = y;
@@ -437,19 +443,19 @@ void CRRConnectionBuilder::calculate_segment_coordinates(const SegmentInfo& info
437443
physical_length = (x_high - x_low) + (y_high - y_low) + 1;
438444
}
439445

440-
Direction CRRConnectionBuilder::get_direction_for_side(Side side,
446+
Direction CRRConnectionBuilder::get_direction_for_side(e_sw_template_side side,
441447
bool is_vertical) const {
442448
if (is_vertical) {
443-
return (side == Side::RIGHT || side == Side::TOP) ? Direction::DEC_DIR
449+
return (side == e_sw_template_side::RIGHT || side == e_sw_template_side::TOP) ? Direction::DEC_DIR
444450
: Direction::INC_DIR;
445451
} else {
446-
return (side == Side::RIGHT || side == Side::TOP) ? Direction::INC_DIR
452+
return (side == e_sw_template_side::RIGHT || side == e_sw_template_side::TOP) ? Direction::INC_DIR
447453
: Direction::DEC_DIR;
448454
}
449455
}
450456

451-
std::string CRRConnectionBuilder::get_segment_type_label(Side side) const {
452-
return (side == Side::LEFT || side == Side::RIGHT) ? "CHANX" : "CHANY";
457+
std::string CRRConnectionBuilder::get_segment_type_label(e_sw_template_side side) const {
458+
return (side == e_sw_template_side::LEFT || side == e_sw_template_side::RIGHT) ? "CHANX" : "CHANY";
453459
}
454460

455461
std::string CRRConnectionBuilder::get_ptc_sequence(int seg_index,

vpr/src/route/rr_graph_generation/tileable_rr_graph/crr_generator/crr_connection_builder.h

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,16 @@ class CRRConnectionBuilder {
127127

128128
// Segment processing helpers
129129
struct SegmentInfo {
130-
Side side;
130+
e_sw_template_side side;
131131
std::string seg_type;
132132
int seg_index;
133133
int tap;
134134

135135
SegmentInfo()
136-
: side(Side::INVALID)
136+
: side(e_sw_template_side::NUM_SIDES)
137137
, seg_index(-1)
138138
, tap(-1) {}
139-
SegmentInfo(Side s, const std::string& type, int index, int t = 1)
139+
SegmentInfo(e_sw_template_side s, const std::string& type, int index, int t = 1)
140140
: side(s)
141141
, seg_type(type)
142142
, seg_index(index)
@@ -145,15 +145,35 @@ class CRRConnectionBuilder {
145145

146146
SegmentInfo parse_segment_info(const DataFrame& df, size_t row_or_col, bool is_vertical) const;
147147

148-
RRNodeId process_opin_ipin_node(const SegmentInfo& info, Coordinate x, Coordinate y, const std::unordered_map<NodeHash, RRNodeId, NodeHasher>& node_lookup) const;
149-
150-
RRNodeId process_channel_node(const SegmentInfo& info, Coordinate x, Coordinate y, const std::unordered_map<NodeHash, RRNodeId, NodeHasher>& node_lookup, int& prev_seg_index, Side& prev_side, std::string& prev_seg_type, int& prev_ptc_number, bool is_vertical) const;
148+
RRNodeId process_opin_ipin_node(const SegmentInfo& info,
149+
Coordinate x,
150+
Coordinate y,
151+
const std::unordered_map<NodeHash, RRNodeId, NodeHasher>& node_lookup) const;
152+
153+
RRNodeId process_channel_node(const SegmentInfo& info,
154+
Coordinate x,
155+
Coordinate y,
156+
const std::unordered_map<NodeHash, RRNodeId, NodeHasher>& node_lookup,
157+
int& prev_seg_index,
158+
e_sw_template_side& prev_side,
159+
std::string& prev_seg_type,
160+
int& prev_ptc_number,
161+
bool is_vertical) const;
151162

152163
// Coordinate and direction calculations
153-
void calculate_segment_coordinates(const SegmentInfo& info, Coordinate x, Coordinate y, Coordinate& x_low, Coordinate& x_high, Coordinate& y_low, Coordinate& y_high, int& physical_length, int& truncated, bool is_vertical) const;
154-
155-
Direction get_direction_for_side(Side side, bool is_vertical) const;
156-
std::string get_segment_type_label(Side side) const;
164+
void calculate_segment_coordinates(const SegmentInfo& info,
165+
Coordinate x,
166+
Coordinate y,
167+
Coordinate& x_low,
168+
Coordinate& x_high,
169+
Coordinate& y_low,
170+
Coordinate& y_high,
171+
int& physical_length,
172+
int& truncated,
173+
bool is_vertical) const;
174+
175+
Direction get_direction_for_side(e_sw_template_side side, bool is_vertical) const;
176+
std::string get_segment_type_label(e_sw_template_side side) const;
157177

158178
// Return the switch id of an edge between two nodes
159179
int get_connection_delay_ps(const std::string& cell_value,

vpr/src/route/rr_graph_generation/tileable_rr_graph/crr_generator/data_frame_processor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
#include "vtr_log.h"
44

5-
#include <filesystem>
65
#include <algorithm>
6+
#include <fstream>
77

88
namespace crrgenerator {
99

0 commit comments

Comments
 (0)