11#include " crr_edge_builder.h"
22#include " globals.h"
33
4+ #include " physical_types.h"
45#include " crr_connection_builder.h"
56
6- static RRSwitchId find_crr_switch_id (const int delay_ps) {
7- const auto & arch_switches = g_vpr_ctx.device ().arch_switch_inf ;
7+ static t_arch_switch_inf create_crr_switch (const int delay_ps) {
88 std::string switch_name;
99 if (delay_ps == 0 ) {
1010 switch_name = " sw_zero" ;
1111 } else {
1212 switch_name = " sw_" + std::to_string (delay_ps);
1313 }
14- for (int sw_id = 0 ; sw_id < (int )arch_switches.size (); sw_id++) {
15- if (arch_switches[sw_id].name == switch_name) {
16- return RRSwitchId (sw_id);
14+ t_arch_switch_inf arch_switch_inf;
15+ arch_switch_inf.set_type (e_switch_type::MUX);
16+ arch_switch_inf.name = switch_name;
17+ arch_switch_inf.R = 0 .;
18+ arch_switch_inf.Cin = 0 .;
19+ arch_switch_inf.Cout = 0 ;
20+ arch_switch_inf.set_Tdel (t_arch_switch_inf::UNDEFINED_FANIN, delay_ps);
21+ arch_switch_inf.power_buffer_type = POWER_BUFFER_TYPE_NONE;
22+ arch_switch_inf.mux_trans_size = 0 .;
23+ arch_switch_inf.buf_size_type = e_buffer_size::ABSOLUTE;
24+ arch_switch_inf.buf_size = 0 .;
25+ arch_switch_inf.intra_tile = false ;
26+
27+ return arch_switch_inf;
28+ }
29+
30+ static RRSwitchId find_or_create_crr_switch_id (const int delay_ps) {
31+ auto & all_sw_inf = g_vpr_ctx.mutable_device ().all_sw_inf ;
32+ std::string switch_name;
33+ int found_sw_id = -1 ;
34+ if (delay_ps == 0 ) {
35+ switch_name = " sw_zero" ;
36+ } else {
37+ switch_name = " sw_" + std::to_string (delay_ps);
38+ }
39+ for (int sw_id = 0 ; sw_id < (int )all_sw_inf.size (); sw_id++) {
40+ if (all_sw_inf[sw_id].name == switch_name) {
41+ found_sw_id = sw_id;
42+ break ;
1743 }
1844 }
19- return RRSwitchId::INVALID ();
45+
46+ if (found_sw_id == -1 ) {
47+ t_arch_switch_inf new_arch_switch_inf = create_crr_switch (delay_ps);
48+ found_sw_id = (int )all_sw_inf.size ();
49+ all_sw_inf.insert (std::make_pair (found_sw_id, new_arch_switch_inf));
50+ VTR_LOG (" Created new CRR switch: %s with ID: %d\n " , switch_name.c_str (), found_sw_id);
51+ }
52+ return RRSwitchId (found_sw_id);
2053}
2154
2255void build_crr_gsb_track_to_track_edges (RRGraphBuilder& rr_graph_builder,
@@ -27,7 +60,7 @@ void build_crr_gsb_track_to_track_edges(RRGraphBuilder& rr_graph_builder,
2760
2861 std::vector<crrgenerator::Connection> gsb_connections = connection_builder.get_tile_connections (gsb_x, gsb_y);
2962 for (const auto & connection : gsb_connections) {
30- RRSwitchId rr_switch_id = find_crr_switch_id (connection.delay_ps ());
63+ RRSwitchId rr_switch_id = find_or_create_crr_switch_id (connection.delay_ps ());
3164 VTR_ASSERT (rr_switch_id != RRSwitchId::INVALID ());
3265 rr_graph_builder.create_edge_in_cache (connection.src_node (), connection.sink_node (), rr_switch_id, false , connection.crr_id ());
3366 }
0 commit comments