vpr/src/route/rr_graph_reader.cpp
/* Reads in the switch information and adds it to device_ctx.rr_switch_inf as specified*/
Reads in the switch information and adds it to device_ctx.rr_switch_inf as specified
Reads in the switch information and adds it to device_ctx . rr_switch_inf as specified
void process_switches(pugi::xml_node parent, const pugiutil::loc_data& loc_data) {
    auto& device_ctx = g_vpr_ctx.mutable_device();
    pugi::xml_node Switch, SwitchSubnode;
    Switch = get_first_child(parent, "switch", loc_data);
    while (Switch) {
        int iSwitch = get_attribute(Switch, "id", loc_data).as_int();
        auto& rr_switch = device_ctx.rr_switch_inf[iSwitch];
        const char* name = get_attribute(Switch, "name", loc_data, pugiutil::OPTIONAL).as_string(nullptr);
        bool found_arch_name = false;
        if (name != nullptr) {
            for (int i = 0; i < device_ctx.num_arch_switches; ++i) {
                if (strcmp(name, device_ctx.arch_switch_inf[i].name) == 0) {
                    name = device_ctx.arch_switch_inf[i].name;
                    found_arch_name = true;
                    break;
                }
            }
        }
        if (name != nullptr && !found_arch_name) {
            VPR_FATAL_ERROR(VPR_ERROR_ROUTE, "Switch name '%s' not found in architecture\n", name);
        }
        rr_switch.name = name;
        std::string switch_type_str = get_attribute(Switch, "type", loc_data).as_string();
        SwitchType switch_type = SwitchType::INVALID;
        if (switch_type_str == "tristate") {
            switch_type = SwitchType::TRISTATE;
        } else if (switch_type_str == "mux") {
            switch_type = SwitchType::MUX;
        } else if (switch_type_str == "pass_gate") {
            switch_type = SwitchType::PASS_GATE;
        } else if (switch_type_str == "short") {
            switch_type = SwitchType::SHORT;
        } else if (switch_type_str == "buffer") {
            switch_type = SwitchType::BUFFER;
        } else {
            VPR_FATAL_ERROR(VPR_ERROR_ROUTE, "Invalid switch type '%s'\n", switch_type_str.c_str());
        }
        rr_switch.set_type(switch_type);
        SwitchSubnode = get_single_child(Switch, "timing", loc_data, pugiutil::OPTIONAL);
        if (SwitchSubnode) {
            rr_switch.R = get_attribute(SwitchSubnode, "R", loc_data).as_float();
            rr_switch.Cin = get_attribute(SwitchSubnode, "Cin", loc_data).as_float();
            rr_switch.Cout = get_attribute(SwitchSubnode, "Cout", loc_data).as_float();
            rr_switch.Cinternal = get_attribute(SwitchSubnode, "Cinternal", loc_data).as_float();
            rr_switch.Tdel = get_attribute(SwitchSubnode, "Tdel", loc_data).as_float();
        } else {
            rr_switch.R = 0;
            rr_switch.Cin = 0;
            rr_switch.Cout = 0;
            rr_switch.Cinternal = 0;
            rr_switch.Tdel = 0;
        }
        SwitchSubnode = get_single_child(Switch, "sizing", loc_data);
        rr_switch.mux_trans_size = get_attribute(SwitchSubnode, "mux_trans_size", loc_data).as_float();
        rr_switch.buf_size = get_attribute(SwitchSubnode, "buf_size", loc_data).as_float();
        Switch = Switch.next_sibling(Switch.name());
    }
    device_ctx.rr_graph.reserve_switches(device_ctx.rr_switch_inf.size());
    for (size_t iswitch = 0; iswitch < device_ctx.rr_switch_inf.size(); ++iswitch) {
        device_ctx.rr_graph.create_switch(device_ctx.rr_switch_inf[iswitch]);
    }
}
void process_switches ( pugi :: xml_node parent , const pugiutil :: loc_data & loc_data ) { auto & device_ctx = g_vpr_ctx . mutable_device ( ) ; pugi :: xml_node Switch , SwitchSubnode ; Switch = get_first_child ( parent , " " , loc_data ) ; while ( Switch ) { int iSwitch = get_attribute ( Switch , " " , loc_data ) . as_int ( ) ; auto & rr_switch = device_ctx . rr_switch_inf [ iSwitch ] ; const char * name = get_attribute ( Switch , " " , loc_data , pugiutil :: OPTIONAL ) . as_string ( nullptr ) ; bool found_arch_name = false ; if ( name != nullptr ) { for ( int i = 0 ; i < device_ctx . num_arch_switches ; ++ i ) { if ( strcmp ( name , device_ctx . arch_switch_inf [ i ] . name ) == 0 ) { name = device_ctx . arch_switch_inf [ i ] . name ; found_arch_name = true ; break ; } } } if ( name != nullptr && ! found_arch_name ) { VPR_FATAL_ERROR ( VPR_ERROR_ROUTE , " \n " , name ) ; } rr_switch . name = name ; std :: string switch_type_str = get_attribute ( Switch , " " , loc_data ) . as_string ( ) ; SwitchType switch_type = SwitchType :: INVALID ; if ( switch_type_str == " " ) { switch_type = SwitchType :: TRISTATE ; } else if ( switch_type_str == " " ) { switch_type = SwitchType :: MUX ; } else if ( switch_type_str == " " ) { switch_type = SwitchType :: PASS_GATE ; } else if ( switch_type_str == " " ) { switch_type = SwitchType :: SHORT ; } else if ( switch_type_str == " " ) { switch_type = SwitchType :: BUFFER ; } else { VPR_FATAL_ERROR ( VPR_ERROR_ROUTE , " \n " , switch_type_str . c_str ( ) ) ; } rr_switch . set_type ( switch_type ) ; SwitchSubnode = get_single_child ( Switch , " " , loc_data , pugiutil :: OPTIONAL ) ; if ( SwitchSubnode ) { rr_switch . R = get_attribute ( SwitchSubnode , " " , loc_data ) . as_float ( ) ; rr_switch . Cin = get_attribute ( SwitchSubnode , " " , loc_data ) . as_float ( ) ; rr_switch . Cout = get_attribute ( SwitchSubnode , " " , loc_data ) . as_float ( ) ; rr_switch . Cinternal = get_attribute ( SwitchSubnode , " " , loc_data ) . as_float ( ) ; rr_switch . Tdel = get_attribute ( SwitchSubnode , " " , loc_data ) . as_float ( ) ; } else { rr_switch . R = 0 ; rr_switch . Cin = 0 ; rr_switch . Cout = 0 ; rr_switch . Cinternal = 0 ; rr_switch . Tdel = 0 ; } SwitchSubnode = get_single_child ( Switch , " " , loc_data ) ; rr_switch . mux_trans_size = get_attribute ( SwitchSubnode , " " , loc_data ) . as_float ( ) ; rr_switch . buf_size = get_attribute ( SwitchSubnode , " " , loc_data ) . as_float ( ) ; Switch = Switch . next_sibling ( Switch . name ( ) ) ; } device_ctx . rr_graph . reserve_switches ( device_ctx . rr_switch_inf . size ( ) ) ; for ( size_t iswitch = 0 ; iswitch < device_ctx . rr_switch_inf . size ( ) ; ++ iswitch ) { device_ctx . rr_graph . create_switch ( device_ctx . rr_switch_inf [ iswitch ] ) ; } }
Reads in the switch information and adds it to device_ctx.rr_switch_inf as specified
Reads in the switch information and adds it to device_ctx . rr_switch_inf as specified
/* Add the switch to RRGraph local data */ // Create the switches