OpenFPGA/libopenfpga/libarchopenfpga/src/read_xml_openfpga_arch.cpp

57 lines
1.8 KiB
C++
Raw Normal View History

2020-01-14 09:33:48 -06:00
/********************************************************************
* This file includes the top-level function of this library
* which reads an XML modeling OpenFPGA architecture to the associated
* data structures
*******************************************************************/
#include <string>
/* Headers from pugi XML library */
#include "pugixml.hpp"
#include "pugixml_util.hpp"
/* Headers from libarchfpga */
#include "arch_error.h"
#include "read_xml_util.h"
#include "read_xml_circuit_library.h"
#include "read_xml_openfpga_arch.h"
2020-01-14 09:33:48 -06:00
/********************************************************************
* Top-level function to parse an XML file and load data to :
* 1. circuit library
*******************************************************************/
OpenFPGAArch read_xml_openfpga_arch(const char* arch_file_name) {
OpenFPGAArch openfpga_arch;
2020-01-14 09:33:48 -06:00
pugi::xml_node Next;
/* Parse the file */
pugi::xml_document doc;
pugiutil::loc_data loc_data;
try {
loc_data = pugiutil::load_xml(doc, arch_file_name);
/* Root node should be <circuit_settings> */
auto xml_circuit_settings = get_single_child(doc, "openfpga_architecture", loc_data);
2020-01-14 09:33:48 -06:00
/* Parse circuit_models to circuit library
* under the node <module_circuit_models>
*/
auto xml_circuit_models = get_single_child(xml_circuit_settings, "circuit_library", loc_data);
openfpga_arch.circuit_lib = read_xml_circuit_library(xml_circuit_models, loc_data);
2020-01-14 09:33:48 -06:00
/* Build the internal links for the circuit library */
openfpga_arch.circuit_lib.build_model_links();
/* Build the timing graph inside the circuit library */
openfpga_arch.circuit_lib.build_timing_graphs();
2020-01-14 09:33:48 -06:00
} catch (pugiutil::XmlError& e) {
archfpga_throw(arch_file_name, e.line(),
"%s", e.what());
}
return openfpga_arch;
2020-01-14 09:33:48 -06:00
}