Skip to content

Commit b892b6e

Browse files
add doxygen comments for load_rr_switch_inf() and alloc_rr_switch_inf()
1 parent 6b95998 commit b892b6e

File tree

1 file changed

+36
-32
lines changed

1 file changed

+36
-32
lines changed

vpr/src/route/rr_graph_generation/rr_graph_switch_utils.cpp

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,46 @@
88
#include "vpr_error.h"
99
#include "vpr_types.h"
1010

11+
//
12+
// Static Function Declarations
13+
//
14+
15+
/**
16+
* @brief Populate rr_switch entries for all fanin variants.
17+
*
18+
* Iterates over each architecture switch and its fanins, creates the
19+
* corresponding rr_switch entries, and fills the fanin --> rr_switch mapping.
20+
*/
1121
static void load_rr_switch_inf(RRGraphBuilder& rr_graph_builder,
1222
std::vector<std::map<int, int>>& switch_fanin_remap,
1323
const std::map<int, t_arch_switch_inf>& arch_sw_inf,
1424
const float R_minW_nmos,
1525
const float R_minW_pmos,
1626
const t_arch_switch_fanin& arch_switch_fanins);
1727

28+
/**
29+
* @brief Allocate rr_switch storage and determine fanin variants.
30+
*
31+
* Builds the list of fanins observed for each architecture switch and resizes
32+
* the rr_switch array accordingly.
33+
*/
1834
static void alloc_rr_switch_inf(RRGraphBuilder& rr_graph_builder,
1935
t_arch_switch_fanin& arch_switch_fanins,
2036
const std::map<int, t_arch_switch_inf>& arch_sw_map);
2137

22-
/* load the global device_ctx.rr_switch_inf variable. also keep track of, for each arch switch, what
23-
* index of the rr_switch_inf array each version of its fanin has been mapped to (through switch_fanin map) */
38+
//
39+
// Static Function Definitions
40+
//
41+
2442
static void load_rr_switch_inf(RRGraphBuilder& rr_graph_builder,
2543
std::vector<std::map<int, int>>& switch_fanin_remap,
2644
const std::map<int, t_arch_switch_inf>& arch_sw_inf,
2745
const float R_minW_nmos,
2846
const float R_minW_pmos,
2947
const t_arch_switch_fanin& arch_switch_fanins) {
30-
if (!switch_fanin_remap.empty()) {
31-
// at this stage, we rebuild the rr_graph (probably in binary search)
32-
// so old device_ctx.switch_fanin_remap is obsolete
33-
switch_fanin_remap.clear();
34-
}
35-
48+
switch_fanin_remap.clear();
3649
switch_fanin_remap.resize(arch_sw_inf.size());
50+
3751
for (const int arch_sw_id : arch_sw_inf | std::views::keys) {
3852
for (auto fanin_rrswitch : arch_switch_fanins[arch_sw_id]) {
3953
// the fanin value is in it->first, and we'll need to set what index this i_arch_switch/fanin
@@ -56,8 +70,6 @@ static void load_rr_switch_inf(RRGraphBuilder& rr_graph_builder,
5670
}
5771
}
5872

59-
/* Allocates space for the global device_ctx.rr_switch_inf variable and returns the
60-
* number of rr switches that were allocated */
6173
static void alloc_rr_switch_inf(RRGraphBuilder& rr_graph_builder,
6274
t_arch_switch_fanin& arch_switch_fanins,
6375
const std::map<int, t_arch_switch_inf>& arch_sw_map) {
@@ -71,16 +83,18 @@ static void alloc_rr_switch_inf(RRGraphBuilder& rr_graph_builder,
7183
rr_graph_builder.resize_switches(num_rr_switches);
7284
}
7385

74-
// This function is same as create_rr_switch_from_arch_switch() in terms of functionality. It is tuned for clients functions in routing resource graph builder
86+
//
87+
// Non-static Function Definitions
88+
//
89+
7590
void load_rr_switch_from_arch_switch(RRGraphBuilder& rr_graph_builder,
7691
const std::map<int, t_arch_switch_inf>& arch_sw_inf,
7792
int arch_switch_idx,
7893
int rr_switch_idx,
7994
int fanin,
8095
const float R_minW_nmos,
8196
const float R_minW_pmos) {
82-
// figure out, by looking at the arch switch's Tdel map, what the delay of the new
83-
// rr switch should be
97+
// figure out, by looking at the arch switch's Tdel map, what the delay of the new rr switch should be
8498
double rr_switch_Tdel = arch_sw_inf.at(arch_switch_idx).Tdel(fanin);
8599

86100
// copy over the arch switch to rr_switch_inf[rr_switch_idx], but with the changed Tdel value
@@ -92,29 +106,24 @@ void load_rr_switch_from_arch_switch(RRGraphBuilder& rr_graph_builder,
92106
rr_graph_builder.rr_switch()[RRSwitchId(rr_switch_idx)].Tdel = rr_switch_Tdel;
93107
rr_graph_builder.rr_switch()[RRSwitchId(rr_switch_idx)].mux_trans_size = arch_sw_inf.at(arch_switch_idx).mux_trans_size;
94108
if (arch_sw_inf.at(arch_switch_idx).buf_size_type == BufferSize::AUTO) {
95-
//Size based on resistance
109+
// Size based on resistance
96110
rr_graph_builder.rr_switch()[RRSwitchId(rr_switch_idx)].buf_size = trans_per_buf(arch_sw_inf.at(arch_switch_idx).R, R_minW_nmos, R_minW_pmos);
97111
} else {
98112
VTR_ASSERT(arch_sw_inf.at(arch_switch_idx).buf_size_type == BufferSize::ABSOLUTE);
99-
//Use the specified size
113+
// Use the specified size
100114
rr_graph_builder.rr_switch()[RRSwitchId(rr_switch_idx)].buf_size = arch_sw_inf.at(arch_switch_idx).buf_size;
101115
}
102116
rr_graph_builder.rr_switch()[RRSwitchId(rr_switch_idx)].name = arch_sw_inf.at(arch_switch_idx).name;
103117
rr_graph_builder.rr_switch()[RRSwitchId(rr_switch_idx)].power_buffer_type = arch_sw_inf.at(arch_switch_idx).power_buffer_type;
104118
rr_graph_builder.rr_switch()[RRSwitchId(rr_switch_idx)].power_buffer_size = arch_sw_inf.at(arch_switch_idx).power_buffer_size;
105119
}
106120

107-
/* This function creates a routing switch for the usage of routing resource graph, based on a routing switch defined in architecture file.
108-
*
109-
* Since users can specify a routing switch whose buffer size is automatically tuned for routing architecture, the function here sets a definite buffer size, as required by placers and routers.
110-
*/
111121
t_rr_switch_inf create_rr_switch_from_arch_switch(const t_arch_switch_inf& arch_sw_inf,
112122
const float R_minW_nmos,
113123
const float R_minW_pmos) {
114124
t_rr_switch_inf rr_switch_inf;
115125

116-
// figure out, by looking at the arch switch's Tdel map, what the delay of the new
117-
// rr switch should be
126+
// figure out, by looking at the arch switch's Tdel map, what the delay of the new rr switch should be
118127
double rr_switch_Tdel = arch_sw_inf.Tdel(0);
119128

120129
// copy over the arch switch to rr_switch_inf[rr_switch_idx], but with the changed Tdel value
@@ -126,11 +135,11 @@ t_rr_switch_inf create_rr_switch_from_arch_switch(const t_arch_switch_inf& arch_
126135
rr_switch_inf.Tdel = rr_switch_Tdel;
127136
rr_switch_inf.mux_trans_size = arch_sw_inf.mux_trans_size;
128137
if (arch_sw_inf.buf_size_type == BufferSize::AUTO) {
129-
//Size based on resistance
138+
// Size based on resistance
130139
rr_switch_inf.buf_size = trans_per_buf(arch_sw_inf.R, R_minW_nmos, R_minW_pmos);
131140
} else {
132141
VTR_ASSERT(arch_sw_inf.buf_size_type == BufferSize::ABSOLUTE);
133-
//Use the specified size
142+
// Use the specified size
134143
rr_switch_inf.buf_size = arch_sw_inf.buf_size;
135144
}
136145
rr_switch_inf.name = arch_sw_inf.name;
@@ -190,10 +199,6 @@ void alloc_and_load_rr_switch_inf(RRGraphBuilder& rr_graph_builder,
190199
arch_switch_fanins);
191200

192201
// next, walk through rr nodes again and remap their switch indices to rr_switch_inf
193-
194-
/* switch indices of each rr_node original point into the global device_ctx.arch_switch_inf array.
195-
* now we want to remap these indices to point into the global device_ctx.rr_switch_inf array
196-
* which contains switch info at different fan-in values */
197202
rr_graph_builder.remap_rr_node_switch_indices(arch_switch_fanins);
198203

199204
// now we need to set the wire_to_rr_ipin_switch variable which points the detailed routing architecture
@@ -207,11 +212,10 @@ void alloc_and_load_rr_switch_inf(RRGraphBuilder& rr_graph_builder,
207212
VPR_FATAL_ERROR(VPR_ERROR_ARCH,
208213
"Not currently allowing an ipin cblock switch to have multiple fan-ins");
209214
} else {
210-
//This likely indicates that no connection block has been constructed, indicating significant issues with
211-
//the generated RR graph.
212-
//
213-
//Instead of throwing an error we issue a warning. This means that check_rr_graph() etc. will run to give more information
214-
//and allow graphics to be brought up for users to debug their architectures.
215+
// This likely indicates that no connection block has been constructed, indicating significant issues with
216+
// the generated RR graph.
217+
// Instead of throwing an error we issue a warning. This means that check_rr_graph() etc. will run to give more information
218+
// and allow graphics to be brought up for users to debug their architectures.
215219
(*wire_to_rr_ipin_switch) = UNDEFINED;
216220
VTR_LOG_WARN("No switch found for the ipin cblock in RR graph. Check if there is an error in arch file, or if no connection blocks are being built in RR graph\n");
217221
}

0 commit comments

Comments
 (0)