Skip to content

Commit bbdd2cc

Browse files
committed
[vpr][route][area] pass the most freq used IPIN switch type to get_cblock_trans
1 parent b5c4bdc commit bbdd2cc

File tree

1 file changed

+35
-11
lines changed

1 file changed

+35
-11
lines changed

vpr/src/route/rr_graph_generation/rr_graph_area.cpp

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ static const e_trans_area_eq trans_area_eq = AREA_IMPROVED_NMOS_ONLY;
2424

2525
/************************ Subroutines local to this module *******************/
2626

27-
static void count_bidir_routing_transistors(int num_switch, RRSwitchId wire_to_ipin_switch, float R_minW_nmos, float R_minW_pmos, const float trans_sram_bit);
27+
static void count_bidir_routing_transistors(int num_switch, float R_minW_nmos, float R_minW_pmos, const float trans_sram_bit);
2828

2929
static void count_unidir_routing_transistors(std::vector<t_segment_inf>& segment_inf,
30-
RRSwitchId wire_to_ipin_switch,
3130
float R_minW_nmos,
3231
float R_minW_pmos,
3332
const float trans_sram_bit,
@@ -54,7 +53,6 @@ static float trans_per_R(float Rtrans, float R_minW_trans);
5453

5554
void count_routing_transistors(enum e_directionality directionality,
5655
int num_switch,
57-
RRSwitchId wire_to_ipin_switch,
5856
std::vector<t_segment_inf>& segment_inf,
5957
float R_minW_nmos,
6058
float R_minW_pmos,
@@ -75,19 +73,18 @@ void count_routing_transistors(enum e_directionality directionality,
7573
const float trans_sram_bit = 4.;
7674

7775
if (directionality == BI_DIRECTIONAL) {
78-
count_bidir_routing_transistors(num_switch, wire_to_ipin_switch, R_minW_nmos, R_minW_pmos, trans_sram_bit);
76+
count_bidir_routing_transistors(num_switch, R_minW_nmos, R_minW_pmos, trans_sram_bit);
7977
} else {
8078
VTR_ASSERT(directionality == UNI_DIRECTIONAL);
8179
count_unidir_routing_transistors(segment_inf,
82-
wire_to_ipin_switch,
8380
R_minW_nmos,
8481
R_minW_pmos,
8582
trans_sram_bit,
8683
is_flat);
8784
}
8885
}
8986

90-
static void count_bidir_routing_transistors(int num_switch, RRSwitchId wire_to_ipin_switch, float R_minW_nmos, float R_minW_pmos, const float trans_sram_bit) {
87+
static void count_bidir_routing_transistors(int num_switch, float R_minW_nmos, float R_minW_pmos, const float trans_sram_bit) {
9188
/* Tri-state buffers are designed as a buffer followed by a pass transistor. *
9289
* I make Rbuffer = Rpass_transitor = 1/2 Rtri-state_buffer. *
9390
* I make the pull-up and pull-down sides of the buffer the same strength -- *
@@ -164,6 +161,8 @@ static void count_bidir_routing_transistors(int num_switch, RRSwitchId wire_to_i
164161

165162
sharable_switch_trans = alloc_and_load_sharable_switch_trans(num_switch,
166163
R_minW_nmos, R_minW_pmos);
164+
165+
std::unordered_map<RRSwitchId, size_t> ipin_switch_count;
167166

168167
for (const RRNodeId from_rr_node : device_ctx.rr_graph.nodes()) {
169168
size_t from_node = (size_t)from_rr_node;
@@ -206,6 +205,11 @@ static void count_bidir_routing_transistors(int num_switch, RRSwitchId wire_to_i
206205
break;
207206

208207
case e_rr_type::IPIN:
208+
RRSwitchId switch_id = RRSwitchId(rr_graph.edge_switch(RRNodeId(from_node), iedge));
209+
if (ipin_switch_count.find(switch_id) == ipin_switch_count.end()) {
210+
ipin_switch_count[switch_id] = 0;
211+
}
212+
ipin_switch_count[switch_id]++;
209213
num_inputs_to_cblock[to_node]++;
210214
max_inputs_to_cblock = std::max(max_inputs_to_cblock, num_inputs_to_cblock[to_node]);
211215

@@ -285,8 +289,16 @@ static void count_bidir_routing_transistors(int num_switch, RRSwitchId wire_to_i
285289

286290
/* Now add in the input connection block transistors. */
287291

288-
input_cblock_trans = get_cblock_trans(num_inputs_to_cblock, wire_to_ipin_switch,
289-
max_inputs_to_cblock, trans_sram_bit);
292+
// Get most frequent ipin switch
293+
RRSwitchId most_frequent_ipin_switch = std::max_element(ipin_switch_count.begin(),
294+
ipin_switch_count.end(),
295+
[](const auto& a, const auto& b) {
296+
return a.second < b.second;
297+
})->first;
298+
input_cblock_trans = get_cblock_trans(num_inputs_to_cblock,
299+
most_frequent_ipin_switch,
300+
max_inputs_to_cblock,
301+
trans_sram_bit);
290302

291303
ntrans_sharing += input_cblock_trans;
292304
ntrans_no_sharing += input_cblock_trans;
@@ -301,7 +313,6 @@ static void count_bidir_routing_transistors(int num_switch, RRSwitchId wire_to_i
301313
}
302314

303315
static void count_unidir_routing_transistors(std::vector<t_segment_inf>& /*segment_inf*/,
304-
RRSwitchId wire_to_ipin_switch,
305316
float R_minW_nmos,
306317
float R_minW_pmos,
307318
const float trans_sram_bit,
@@ -357,6 +368,7 @@ static void count_unidir_routing_transistors(std::vector<t_segment_inf>& /*segme
357368
cblock_counted[k] = 0;
358369

359370
ntrans = 0;
371+
std::unordered_map<RRSwitchId, size_t> ipin_switch_count;
360372
for (const RRNodeId from_rr_node : device_ctx.rr_graph.nodes()) {
361373
size_t from_node = size_t(from_rr_node);
362374
from_rr_type = rr_graph.node_type(from_rr_node);
@@ -424,6 +436,11 @@ static void count_unidir_routing_transistors(std::vector<t_segment_inf>& /*segme
424436
break;
425437

426438
case e_rr_type::IPIN:
439+
RRSwitchId switch_id = RRSwitchId(rr_graph.edge_switch(RRNodeId(from_node), iedge));
440+
if (ipin_switch_count.find(switch_id) == ipin_switch_count.end()) {
441+
ipin_switch_count[switch_id] = 0;
442+
}
443+
ipin_switch_count[switch_id]++;
427444
num_inputs_to_cblock[to_node]++;
428445
max_inputs_to_cblock = std::max(max_inputs_to_cblock, num_inputs_to_cblock[to_node]);
429446
iseg = seg_index_of_cblock(rr_graph, from_rr_type, size_t(to_node));
@@ -471,8 +488,15 @@ static void count_unidir_routing_transistors(std::vector<t_segment_inf>& /*segme
471488

472489
/* Now add in the input connection block transistors. */
473490

474-
input_cblock_trans = get_cblock_trans(num_inputs_to_cblock, wire_to_ipin_switch,
475-
max_inputs_to_cblock, trans_sram_bit);
491+
// Get most frequent ipin switch
492+
RRSwitchId most_frequent_ipin_switch = std::max_element(ipin_switch_count.begin(), ipin_switch_count.end(), [](const auto& a, const auto& b) {
493+
return a.second < b.second;
494+
})->first;
495+
496+
input_cblock_trans = get_cblock_trans(num_inputs_to_cblock,
497+
most_frequent_ipin_switch,
498+
max_inputs_to_cblock,
499+
trans_sram_bit);
476500

477501
delete[] cblock_counted;
478502

0 commit comments

Comments
 (0)