Skip to content

Commit a5980f2

Browse files
move t_seg_details, t_chan_seg_details, and t_chan_details to rr_types.h
1 parent d747b16 commit a5980f2

File tree

4 files changed

+158
-178
lines changed

4 files changed

+158
-178
lines changed

vpr/src/base/vpr_types.h

Lines changed: 0 additions & 177 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,183 +1363,6 @@ struct t_det_routing_arch {
13631363
std::string write_rr_graph_filename;
13641364
};
13651365

1366-
/**
1367-
* @brief Lists detailed information about segmentation. [0 .. W-1].
1368-
*/
1369-
struct t_seg_details {
1370-
/**
1371-
* @brief Length (in clbs) of the segment.
1372-
*/
1373-
int length = 0;
1374-
1375-
/**
1376-
* @brief Index at which a segment starts in channel 0.
1377-
*/
1378-
int start = 0;
1379-
1380-
/**
1381-
* @brief True if this segment spans the entire channel.
1382-
*/
1383-
bool longline = false;
1384-
1385-
/**
1386-
* @brief [0..length]: true for every channel intersection, relative to the
1387-
* segment start, at which there is a switch box.
1388-
*/
1389-
std::unique_ptr<bool[]> sb;
1390-
1391-
/**
1392-
* @brief [0..length-1]: true for every logic block along the segment at
1393-
* which there is a connection box.
1394-
*/
1395-
std::unique_ptr<bool[]> cb;
1396-
1397-
/**
1398-
* @brief Index of the switch type that connects other wires to this segment.
1399-
* Note that this index is in relation to the switches from the architecture
1400-
* file, not the expanded list of switches that is built at the end of build_rr_graph.
1401-
*/
1402-
short arch_wire_switch = 0;
1403-
1404-
/**
1405-
* @brief Index of the switch type that connects output pins (OPINs) *to* this segment.
1406-
* Note that this index is in relation to the switches from the architecture
1407-
* file, not the expanded list of switches that is built at the end of build_rr_graph.
1408-
*/
1409-
short arch_opin_switch = 0;
1410-
1411-
/**
1412-
* @brief Index of the switch type that connects output pins (OPINs) *to* this segment
1413-
* from *another dice*. Note that this index is in relation to the switches from the
1414-
* architecture file, not the expanded list of switches that is built at the end of
1415-
* build_rr_graph.
1416-
*/
1417-
short arch_inter_die_switch = 0;
1418-
1419-
/**
1420-
* @brief Resistance of a routing track, per unit logic block length.
1421-
*/
1422-
float Rmetal = 0;
1423-
1424-
/**
1425-
* @brief Capacitance of a routing track, per unit logic block length.
1426-
*/
1427-
float Cmetal = 0;
1428-
1429-
bool twisted = false;
1430-
1431-
/**
1432-
* @brief Direction of the segment.
1433-
*/
1434-
enum Direction direction = Direction::NONE;
1435-
1436-
/**
1437-
* @brief Index of the first logic block in the group.
1438-
*/
1439-
int group_start = 0;
1440-
1441-
/**
1442-
* @brief Size of the group.
1443-
*/
1444-
int group_size = 0;
1445-
1446-
/**
1447-
* @brief index of the segment type used for this track.
1448-
* Note that this index will store the index of the segment
1449-
* relative to its **parallel** segment types, not all segments
1450-
* as stored in device_ctx. Look in rr_graph.cpp: build_rr_graph
1451-
* for details but here is an example: say our segment_inf_vec in
1452-
* device_ctx is as follows: [seg_a_x, seg_b_x, seg_a_y, seg_b_y]
1453-
* when building the rr_graph, static segment_inf_vectors will be
1454-
* created for each direction, thus you will have the following
1455-
* 2 vectors: X_vec =[seg_a_x,seg_b_x] and Y_vec = [seg_a_y,seg_b_y].
1456-
* As a result, e.g. seg_b_y::index == 1 (index in Y_vec)
1457-
* and != 3 (index in device_ctx segment_inf_vec).
1458-
*/
1459-
int index = 0;
1460-
1461-
/**
1462-
* @brief index is relative to the segment_inf vec as stored in device_ctx.
1463-
* Note that the above vector is **unifies** both x-parallel and
1464-
* y-parallel segments and is loaded up originally in read_xml_arch_file.cpp
1465-
*/
1466-
int abs_index = 0;
1467-
1468-
/**
1469-
* @brief Used for power
1470-
*/
1471-
float Cmetal_per_m = 0;
1472-
1473-
/**
1474-
* @brief Name of the segment type.
1475-
*/
1476-
std::string type_name;
1477-
};
1478-
1479-
class t_chan_seg_details {
1480-
public:
1481-
t_chan_seg_details() = default;
1482-
t_chan_seg_details(const t_seg_details* init_seg_details)
1483-
: length_(init_seg_details->length)
1484-
, seg_detail_(init_seg_details) {}
1485-
1486-
public:
1487-
int length() const { return length_; }
1488-
int seg_start() const { return seg_start_; }
1489-
int seg_end() const { return seg_end_; }
1490-
1491-
int start() const { return seg_detail_->start; }
1492-
bool longline() const { return seg_detail_->longline; }
1493-
1494-
int group_start() const { return seg_detail_->group_start; }
1495-
int group_size() const { return seg_detail_->group_size; }
1496-
1497-
bool cb(int pos) const { return seg_detail_->cb[pos]; }
1498-
bool sb(int pos) const { return seg_detail_->sb[pos]; }
1499-
1500-
float Rmetal() const { return seg_detail_->Rmetal; }
1501-
float Cmetal() const { return seg_detail_->Cmetal; }
1502-
float Cmetal_per_m() const { return seg_detail_->Cmetal_per_m; }
1503-
1504-
short arch_wire_switch() const { return seg_detail_->arch_wire_switch; }
1505-
short arch_opin_switch() const { return seg_detail_->arch_opin_switch; }
1506-
short arch_inter_die_switch() const { return seg_detail_->arch_inter_die_switch; }
1507-
1508-
Direction direction() const { return seg_detail_->direction; }
1509-
1510-
int index() const { return seg_detail_->index; }
1511-
int abs_index() const { return seg_detail_->abs_index; }
1512-
1513-
const vtr::string_view type_name() const {
1514-
return vtr::string_view(
1515-
seg_detail_->type_name.data(),
1516-
seg_detail_->type_name.size());
1517-
}
1518-
1519-
public: //Modifiers
1520-
void set_length(int new_len) { length_ = new_len; }
1521-
void set_seg_start(int new_start) { seg_start_ = new_start; }
1522-
void set_seg_end(int new_end) { seg_end_ = new_end; }
1523-
1524-
private:
1525-
//The only unique information about a channel segment is it's start/end
1526-
//and length. All other information is shared across segment types,
1527-
//so we use a flyweight to the t_seg_details which defines that info.
1528-
//
1529-
//To preserve the illusion of uniqueness we wrap all t_seg_details members
1530-
//so it appears transparent -- client code of this class doesn't need to
1531-
//know about t_seg_details.
1532-
int length_ = -1;
1533-
int seg_start_ = -1;
1534-
int seg_end_ = -1;
1535-
const t_seg_details* seg_detail_ = nullptr;
1536-
};
1537-
1538-
/* Defines a 3-D array of t_chan_seg_details data structures (one per-each horizontal and vertical channel)
1539-
* once allocated in rr_graph2.cpp, is can be accessed like: [0..grid.width()][0..grid.height()][0..num_tracks-1]
1540-
*/
1541-
typedef vtr::NdMatrix<t_chan_seg_details, 3> t_chan_details;
1542-
15431366
constexpr bool is_pin(e_rr_type type) { return (type == IPIN || type == OPIN); }
15441367
constexpr bool is_chan(e_rr_type type) { return (type == CHANX || type == CHANY); }
15451368
constexpr bool is_src_sink(e_rr_type type) { return (type == SOURCE || type == SINK); }

vpr/src/route/build_switchblocks.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@
141141
#include "physical_types.h"
142142
#include "parse_switchblocks.h"
143143
#include "vtr_expr_eval.h"
144+
#include "rr_types.h"
144145

145146
using vtr::FormulaParser;
146147
using vtr::t_formula_data;

vpr/src/route/build_switchblocks.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
#include "physical_types.h"
88
#include "vpr_types.h"
99
#include "device_grid.h"
10-
1110
#include "vtr_random.h"
11+
#include "rr_types.h"
1212

1313
/************ Classes, structs, typedefs ************/
1414

vpr/src/route/rr_types.h

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,160 @@ typedef std::vector<vtr::NdMatrix<std::vector<int>, 5>> t_pin_to_track_lookup;
2222

2323
typedef std::vector<vtr::NdMatrix<std::vector<int>, 5>> t_track_to_pin_lookup;
2424

25+
/**
26+
* @brief Lists detailed information about wire segments. [0 .. W-1].
27+
*/
28+
struct t_seg_details {
29+
/** @brief Length (in clbs) of the segment. */
30+
int length = 0;
31+
32+
/** @brief Index at which a segment starts in channel 0. */
33+
int start = 0;
34+
35+
/** @brief True if this segment spans the entire channel. */
36+
bool longline = false;
37+
38+
/** @brief [0..length]: true for every channel intersection, relative to the
39+
* segment start, at which there is a switch box.
40+
*/
41+
std::unique_ptr<bool[]> sb;
42+
43+
/** @brief [0..length-1]: true for every logic block along the segment at
44+
* which there is a connection box.
45+
*/
46+
std::unique_ptr<bool[]> cb;
47+
48+
/** @brief Index of the switch type that connects other wires to this segment.
49+
* Note that this index is in relation to the switches from the architecture
50+
* file, not the expanded list of switches that is built at the end of build_rr_graph.
51+
*/
52+
short arch_wire_switch = 0;
53+
54+
/** @brief Index of the switch type that connects output pins (OPINs) *to* this segment.
55+
* Note that this index is in relation to the switches from the architecture
56+
* file, not the expanded list of switches that is built at the end of build_rr_graph.
57+
*/
58+
short arch_opin_switch = 0;
59+
60+
/** @brief Index of the switch type that connects output pins (OPINs) *to* this segment
61+
* from *another dice*. Note that this index is in relation to the switches from the
62+
* architecture file, not the expanded list of switches that is built at the end of
63+
* build_rr_graph.
64+
*/
65+
short arch_inter_die_switch = 0;
66+
67+
/** @brief Resistance of a routing track, per unit logic block length. */
68+
float Rmetal = 0;
69+
70+
/** @brief Capacitance of a routing track, per unit logic block length. */
71+
float Cmetal = 0;
72+
73+
/** @brief Whether the segment is twisted. */
74+
bool twisted = false;
75+
76+
/** @brief Direction of the segment. */
77+
enum Direction direction = Direction::NONE;
78+
79+
/** @brief Index of the first logic block in the group. */
80+
int group_start = 0;
81+
82+
/** @brief Size of the group. */
83+
int group_size = 0;
84+
85+
/** @brief index of the segment type used for this track.
86+
* Note that this index will store the index of the segment
87+
* relative to its **parallel** segment types, not all segments
88+
* as stored in device_ctx. Look in rr_graph.cpp: build_rr_graph
89+
* for details but here is an example: say our segment_inf_vec in
90+
* device_ctx is as follows: [seg_a_x, seg_b_x, seg_a_y, seg_b_y]
91+
* when building the rr_graph, static segment_inf_vectors will be
92+
* created for each direction, thus you will have the following
93+
* 2 vectors: X_vec =[seg_a_x,seg_b_x] and Y_vec = [seg_a_y,seg_b_y].
94+
* As a result, e.g. seg_b_y::index == 1 (index in Y_vec)
95+
* and != 3 (index in device_ctx segment_inf_vec).
96+
*/
97+
int index = 0;
98+
99+
/** @brief index is relative to the segment_inf vec as stored in device_ctx.
100+
* Note that the above vector is **unifies** both x-parallel and
101+
* y-parallel segments and is loaded up originally in read_xml_arch_file.cpp
102+
*/
103+
int abs_index = 0;
104+
105+
/** @brief Used for power */
106+
float Cmetal_per_m = 0;
107+
108+
/** @brief Name of the segment type. */
109+
std::string type_name;
110+
};
111+
112+
class t_chan_seg_details {
113+
public:
114+
t_chan_seg_details() = default;
115+
t_chan_seg_details(const t_seg_details* init_seg_details)
116+
: length_(init_seg_details->length)
117+
, seg_detail_(init_seg_details) {}
118+
119+
public:
120+
int length() const { return length_; }
121+
int seg_start() const { return seg_start_; }
122+
int seg_end() const { return seg_end_; }
123+
124+
int start() const { return seg_detail_->start; }
125+
bool longline() const { return seg_detail_->longline; }
126+
127+
int group_start() const { return seg_detail_->group_start; }
128+
int group_size() const { return seg_detail_->group_size; }
129+
130+
bool cb(int pos) const { return seg_detail_->cb[pos]; }
131+
bool sb(int pos) const { return seg_detail_->sb[pos]; }
132+
133+
float Rmetal() const { return seg_detail_->Rmetal; }
134+
float Cmetal() const { return seg_detail_->Cmetal; }
135+
float Cmetal_per_m() const { return seg_detail_->Cmetal_per_m; }
136+
137+
short arch_wire_switch() const { return seg_detail_->arch_wire_switch; }
138+
short arch_opin_switch() const { return seg_detail_->arch_opin_switch; }
139+
short arch_inter_die_switch() const { return seg_detail_->arch_inter_die_switch; }
140+
141+
Direction direction() const { return seg_detail_->direction; }
142+
143+
int index() const { return seg_detail_->index; }
144+
int abs_index() const { return seg_detail_->abs_index; }
145+
146+
const vtr::string_view type_name() const {
147+
return vtr::string_view(
148+
seg_detail_->type_name.data(),
149+
seg_detail_->type_name.size());
150+
}
151+
152+
public: //Modifiers
153+
void set_length(int new_len) { length_ = new_len; }
154+
void set_seg_start(int new_start) { seg_start_ = new_start; }
155+
void set_seg_end(int new_end) { seg_end_ = new_end; }
156+
157+
private:
158+
//The only unique information about a channel segment is it's start/end
159+
//and length. All other information is shared across segment types,
160+
//so we use a flyweight to the t_seg_details which defines that info.
161+
//
162+
//To preserve the illusion of uniqueness we wrap all t_seg_details members
163+
//so it appears transparent -- client code of this class doesn't need to
164+
//know about t_seg_details.
165+
int length_ = -1;
166+
int seg_start_ = -1;
167+
int seg_end_ = -1;
168+
const t_seg_details* seg_detail_ = nullptr;
169+
};
170+
171+
/**
172+
* @typedef t_chan_details
173+
* @brief Defines a 3-D array of t_chan_seg_details structures (one for each horizontal and vertical channel).
174+
*
175+
* Once allocated in rr_graph2.cpp, it can be accessed as:
176+
* [0..grid.width()][0..grid.height()][0..num_tracks-1]
177+
*/
178+
typedef vtr::NdMatrix<t_chan_seg_details, 3> t_chan_details;
179+
180+
25181
#endif

0 commit comments

Comments
 (0)