vpr/src/route/rr_graph_reader.cpp
/* Node info are processed. Seg_id of nodes are processed separately when rr_index_data is allocated*/
Node info are processed. Seg_id of nodes are processed separately when rr_index_data is allocated
Node info are processed . Seg_id of nodes are processed separately when rr_index_data is allocated
void process_nodes(pugi::xml_node parent, const pugiutil::loc_data& loc_data) {
    auto& device_ctx = g_vpr_ctx.mutable_device();
    pugi::xml_node locSubnode, timingSubnode, segmentSubnode;
    pugi::xml_node rr_node;
    rr_node = get_first_child(parent, "node", loc_data);
    while (rr_node) {
        int inode = get_attribute(rr_node, "id", loc_data).as_int();
        t_rr_type node_type = NUM_RR_TYPES;
        const char* node_type_str = get_attribute(rr_node, "type", loc_data).as_string();
        if (strcmp(node_type_str, "CHANX") == 0) {
            node_type = CHANX;
        } else if (strcmp(node_type_str, "CHANY") == 0) {
            node_type = CHANY;
        } else if (strcmp(node_type_str, "SOURCE") == 0) {
            node_type = SOURCE;
        } else if (strcmp(node_type_str, "SINK") == 0) {
            node_type = SINK;
        } else if (strcmp(node_type_str, "OPIN") == 0) {
            node_type = OPIN;
        } else if (strcmp(node_type_str, "IPIN") == 0) {
            node_type = IPIN;
        } else {
            VPR_FATAL_ERROR(VPR_ERROR_OTHER,
                            "Valid inputs for class types are \"CHANX\", \"CHANY\",\"SOURCE\", \"SINK\",\"OPIN\", and \"IPIN\".");
        }
        const RRNodeId& node = device_ctx.rr_graph.create_node(node_type);
        if (device_ctx.rr_graph.node_type(node) == CHANX || device_ctx.rr_graph.node_type(node) == CHANY) {
            const char* correct_direction = get_attribute(rr_node, "direction", loc_data).as_string();
            if (strcmp(correct_direction, "INC_DIR") == 0) {
                device_ctx.rr_graph.set_node_direction(node, INC_DIRECTION);
            } else if (strcmp(correct_direction, "DEC_DIR") == 0) {
                device_ctx.rr_graph.set_node_direction(node, DEC_DIRECTION);
            } else if (strcmp(correct_direction, "BI_DIR") == 0) {
                device_ctx.rr_graph.set_node_direction(node, BI_DIRECTION);
            } else {
                VTR_ASSERT((strcmp(correct_direction, "NO_DIR") == 0));
                device_ctx.rr_graph.set_node_direction(node, NO_DIRECTION);
            }
        }
        device_ctx.rr_graph.set_node_capacity(node, get_attribute(rr_node, "capacity", loc_data).as_float());
        locSubnode = get_single_child(rr_node, "loc", loc_data);
        short x1, x2, y1, y2;
        x1 = get_attribute(locSubnode, "xlow", loc_data).as_float();
        x2 = get_attribute(locSubnode, "xhigh", loc_data).as_float();
        y1 = get_attribute(locSubnode, "ylow", loc_data).as_float();
        y2 = get_attribute(locSubnode, "yhigh", loc_data).as_float();
        if (device_ctx.rr_graph.node_type(node) == IPIN || device_ctx.rr_graph.node_type(node) == OPIN) {
            e_side side;
            std::string side_str = get_attribute(locSubnode, "side", loc_data).as_string();
            if (side_str == "LEFT") {
                side = LEFT;
            } else if (side_str == "RIGHT") {
                side = RIGHT;
            } else if (side_str == "TOP") {
                side = TOP;
            } else {
                VTR_ASSERT(side_str == "BOTTOM");
                side = BOTTOM;
            }
            device_ctx.rr_graph.set_node_side(node, side);
        }
        device_ctx.rr_graph.set_node_bounding_box(node, vtr::Rect<short>(x1, y1, x2, y2)); 
        device_ctx.rr_graph.set_node_ptc_num(node, get_attribute(locSubnode, "ptc", loc_data).as_int());
        timingSubnode = get_single_child(rr_node, "timing", loc_data, pugiutil::OPTIONAL);
        float R = 0.;
        float C = 0.;
        if (timingSubnode) {
            R = get_attribute(timingSubnode, "R", loc_data).as_float();
            C = get_attribute(timingSubnode, "C", loc_data).as_float();
        }
        device_ctx.rr_graph.set_node_rc_data_index(node, find_create_rr_rc_data(R, C));
        auto metadata = get_single_child(rr_node, "metadata", loc_data, pugiutil::OPTIONAL);
        if (metadata) {
            auto rr_node_meta = get_first_child(metadata, "meta", loc_data);
            while (rr_node_meta) {
                auto key = get_attribute(rr_node_meta, "name", loc_data).as_string();
                vpr::add_rr_node_metadata(inode, key, rr_node_meta.child_value());
                rr_node_meta = rr_node_meta.next_sibling(rr_node_meta.name());
            }
        }
        rr_node = rr_node.next_sibling(rr_node.name());
    }
}
void process_nodes ( pugi :: xml_node parent , const pugiutil :: loc_data & loc_data ) { auto & device_ctx = g_vpr_ctx . mutable_device ( ) ; pugi :: xml_node locSubnode , timingSubnode , segmentSubnode ; pugi :: xml_node rr_node ; rr_node = get_first_child ( parent , " " , loc_data ) ; while ( rr_node ) { int inode = get_attribute ( rr_node , " " , loc_data ) . as_int ( ) ; t_rr_type node_type = NUM_RR_TYPES ; const char * node_type_str = get_attribute ( rr_node , " " , loc_data ) . as_string ( ) ; if ( strcmp ( node_type_str , " " ) == 0 ) { node_type = CHANX ; } else if ( strcmp ( node_type_str , " " ) == 0 ) { node_type = CHANY ; } else if ( strcmp ( node_type_str , " " ) == 0 ) { node_type = SOURCE ; } else if ( strcmp ( node_type_str , " " ) == 0 ) { node_type = SINK ; } else if ( strcmp ( node_type_str , " " ) == 0 ) { node_type = OPIN ; } else if ( strcmp ( node_type_str , " " ) == 0 ) { node_type = IPIN ; } else { VPR_FATAL_ERROR ( VPR_ERROR_OTHER , " \" \" \" \" \" \" \" \" \" \" \" \" " ) ; } const RRNodeId & node = device_ctx . rr_graph . create_node ( node_type ) ; if ( device_ctx . rr_graph . node_type ( node ) == CHANX || device_ctx . rr_graph . node_type ( node ) == CHANY ) { const char * correct_direction = get_attribute ( rr_node , " " , loc_data ) . as_string ( ) ; if ( strcmp ( correct_direction , " " ) == 0 ) { device_ctx . rr_graph . set_node_direction ( node , INC_DIRECTION ) ; } else if ( strcmp ( correct_direction , " " ) == 0 ) { device_ctx . rr_graph . set_node_direction ( node , DEC_DIRECTION ) ; } else if ( strcmp ( correct_direction , " " ) == 0 ) { device_ctx . rr_graph . set_node_direction ( node , BI_DIRECTION ) ; } else { VTR_ASSERT ( ( strcmp ( correct_direction , " " ) == 0 ) ) ; device_ctx . rr_graph . set_node_direction ( node , NO_DIRECTION ) ; } } device_ctx . rr_graph . set_node_capacity ( node , get_attribute ( rr_node , " " , loc_data ) . as_float ( ) ) ; locSubnode = get_single_child ( rr_node , " " , loc_data ) ; short x1 , x2 , y1 , y2 ; x1 = get_attribute ( locSubnode , " " , loc_data ) . as_float ( ) ; x2 = get_attribute ( locSubnode , " " , loc_data ) . as_float ( ) ; y1 = get_attribute ( locSubnode , " " , loc_data ) . as_float ( ) ; y2 = get_attribute ( locSubnode , " " , loc_data ) . as_float ( ) ; if ( device_ctx . rr_graph . node_type ( node ) == IPIN || device_ctx . rr_graph . node_type ( node ) == OPIN ) { e_side side ; std :: string side_str = get_attribute ( locSubnode , " " , loc_data ) . as_string ( ) ; if ( side_str == " " ) { side = LEFT ; } else if ( side_str == " " ) { side = RIGHT ; } else if ( side_str == " " ) { side = TOP ; } else { VTR_ASSERT ( side_str == " " ) ; side = BOTTOM ; } device_ctx . rr_graph . set_node_side ( node , side ) ; } device_ctx . rr_graph . set_node_bounding_box ( node , vtr :: Rect < short > ( x1 , y1 , x2 , y2 ) ) ; device_ctx . rr_graph . set_node_ptc_num ( node , get_attribute ( locSubnode , " " , loc_data ) . as_int ( ) ) ; timingSubnode = get_single_child ( rr_node , " " , loc_data , pugiutil :: OPTIONAL ) ; float R = 0. ; float C = 0. ; if ( timingSubnode ) { R = get_attribute ( timingSubnode , " " , loc_data ) . as_float ( ) ; C = get_attribute ( timingSubnode , " " , loc_data ) . as_float ( ) ; } device_ctx . rr_graph . set_node_rc_data_index ( node , find_create_rr_rc_data ( R , C ) ) ; auto metadata = get_single_child ( rr_node , " " , loc_data , pugiutil :: OPTIONAL ) ; if ( metadata ) { auto rr_node_meta = get_first_child ( metadata , " " , loc_data ) ; while ( rr_node_meta ) { auto key = get_attribute ( rr_node_meta , " " , loc_data ) . as_string ( ) ; vpr :: add_rr_node_metadata ( inode , key , rr_node_meta . child_value ( ) ) ; rr_node_meta = rr_node_meta . next_sibling ( rr_node_meta . name ( ) ) ; } } rr_node = rr_node . next_sibling ( rr_node . name ( ) ) ; } }
Node info are processed.
Node info are processed .
//-------------- //------- //  <metadata> //    <meta name='grid_prefix' >CLBLL_L_</meta> //  </metadata>