libopenfpga/libfabrickey/src/read_xml_fabric_key.cpp
/********************************************************************
 * Parse XML codes about <fabric> to an object of FabricKey
 *******************************************************************/
Parse XML codes about  to an object of FabricKey
Parse XML codes about to an object of FabricKey
FabricKey read_xml_fabric_key(const char* key_fname) {
  vtr::ScopedStartFinishTimer timer("Read Fabric Key");
  FabricKey fabric_key;
  pugi::xml_document doc;
  pugiutil::loc_data loc_data;
  try {
    loc_data = pugiutil::load_xml(doc, key_fname);
    pugi::xml_node xml_root = get_single_child(doc, "fabric_key", loc_data);
    size_t num_regions = std::distance(xml_root.children().begin(), xml_root.children().end());
    fabric_key.reserve_regions(num_regions);
    for (size_t iregion = 0; iregion < num_regions; ++iregion) {
      fabric_key.create_region();
    }
    size_t num_keys = 0;
    for (pugi::xml_node xml_region : xml_root.children()) {
      if (xml_region.name() != std::string("region")) {
        bad_tag(xml_region, loc_data, xml_root, {"region"});
      }
      num_keys += std::distance(xml_region.children().begin(), xml_region.children().end());
    }
    fabric_key.reserve_keys(num_keys);
    for (size_t ikey = 0; ikey < num_keys; ++ikey) {
      fabric_key.create_key();
    }
    for (pugi::xml_node xml_region : xml_root.children()) {
      if (xml_region.name() != std::string("region")) {
        bad_tag(xml_region, loc_data, xml_root, {"region"});
      }
      read_xml_fabric_region(xml_region, loc_data, fabric_key);
    } 
  } catch (pugiutil::XmlError& e) {
    archfpga_throw(key_fname, e.line(),
                   "%s", e.what());
  }
  return fabric_key; 
}
FabricKey read_xml_fabric_key ( const char * key_fname ) { vtr :: ScopedStartFinishTimer timer ( " " ) ; FabricKey fabric_key ; pugi :: xml_document doc ; pugiutil :: loc_data loc_data ; try { loc_data = pugiutil :: load_xml ( doc , key_fname ) ; pugi :: xml_node xml_root = get_single_child ( doc , " " , loc_data ) ; size_t num_regions = std :: distance ( xml_root . children ( ) . begin ( ) , xml_root . children ( ) . end ( ) ) ; fabric_key . reserve_regions ( num_regions ) ; for ( size_t iregion = 0 ; iregion < num_regions ; ++ iregion ) { fabric_key . create_region ( ) ; } size_t num_keys = 0 ; for ( pugi :: xml_node xml_region : xml_root . children ( ) ) { if ( xml_region . name ( ) != std :: string ( " " ) ) { bad_tag ( xml_region , loc_data , xml_root , { " " } ) ; } num_keys += std :: distance ( xml_region . children ( ) . begin ( ) , xml_region . children ( ) . end ( ) ) ; } fabric_key . reserve_keys ( num_keys ) ; for ( size_t ikey = 0 ; ikey < num_keys ; ++ ikey ) { fabric_key . create_key ( ) ; } for ( pugi :: xml_node xml_region : xml_root . children ( ) ) { if ( xml_region . name ( ) != std :: string ( " " ) ) { bad_tag ( xml_region , loc_data , xml_root , { " " } ) ; } read_xml_fabric_region ( xml_region , loc_data , fabric_key ) ; } } catch ( pugiutil :: XmlError & e ) { archfpga_throw ( key_fname , e . line ( ) , " " , e . what ( ) ) ; } return fabric_key ; }
Parse XML codes about <fabric> to an object of FabricKey
Parse XML codes about <fabric > to an object of FabricKey
/* Parse the file */ /* Reserve memory space for the region */ /* Reserve memory space for the keys */ /* Error out if the XML child has an invalid name! */ /* Iterate over the children under this node,
     * each child should be named after circuit_model
     */ /* Error out if the XML child has an invalid name! */