reorganized the read XML openfpga arch
This commit is contained in:
parent
ca3ca14cc7
commit
82d83ddceb
|
@ -42,7 +42,7 @@
|
||||||
<io_nmos model_name="nch_25" chan_length="270e-9" min_width="320e-9"/>
|
<io_nmos model_name="nch_25" chan_length="270e-9" min_width="320e-9"/>
|
||||||
<io_pmos model_name="pch_25" chan_length="270e-9" min_width="320e-9"/>
|
<io_pmos model_name="pch_25" chan_length="270e-9" min_width="320e-9"/>
|
||||||
</transistors>
|
</transistors>
|
||||||
<module_circuit_models>
|
<circuit_library>
|
||||||
<circuit_model type="inv_buf" name="INVTX1" prefix="INVTX1" is_default="1">
|
<circuit_model type="inv_buf" name="INVTX1" prefix="INVTX1" is_default="1">
|
||||||
<design_technology type="cmos" topology="inverter" size="1" tapered="off"/>
|
<design_technology type="cmos" topology="inverter" size="1" tapered="off"/>
|
||||||
<port type="input" prefix="in" size="1"/>
|
<port type="input" prefix="in" size="1"/>
|
||||||
|
@ -256,5 +256,5 @@
|
||||||
<port type="output" prefix="cout" size="1"/>
|
<port type="output" prefix="cout" size="1"/>
|
||||||
<port type="output" prefix="sumout" size="1"/>
|
<port type="output" prefix="sumout" size="1"/>
|
||||||
</circuit_model>
|
</circuit_model>
|
||||||
</module_circuit_models>
|
</circuit_library>
|
||||||
</circuit_settings>
|
</circuit_settings>
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
#ifndef READ_OPENFPGA_XML_H
|
|
||||||
#define READ_OPENFPGA_XML_H
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include "circuit_library.h"
|
|
||||||
#include "circuit_settings.h"
|
|
||||||
|
|
||||||
CircuitSettings read_xml_openfpga_arch(const char* arch_file_name);
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -13,7 +13,7 @@
|
||||||
#include "arch_error.h"
|
#include "arch_error.h"
|
||||||
#include "read_xml_util.h"
|
#include "read_xml_util.h"
|
||||||
|
|
||||||
#include "read_openfpga_xml.h"
|
#include "read_xml_circuit_library.h"
|
||||||
|
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
* Convert string to the enumerate of model type
|
* Convert string to the enumerate of model type
|
||||||
|
@ -103,10 +103,10 @@ void read_xml_circuit_model(pugi::xml_node& model_xml,
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
* Parse XML codes about circuit models to circuit library
|
* Parse XML codes about circuit models to circuit library
|
||||||
*******************************************************************/
|
*******************************************************************/
|
||||||
static
|
CircuitLibrary read_xml_circuit_library(pugi::xml_node& Node,
|
||||||
CircuitLibrary read_xml_module_circuit_models(pugi::xml_node& Node,
|
const pugiutil::loc_data& loc_data) {
|
||||||
const pugiutil::loc_data& loc_data) {
|
|
||||||
CircuitLibrary circuit_lib;
|
CircuitLibrary circuit_lib;
|
||||||
|
|
||||||
/* Iterate over the children under this node,
|
/* Iterate over the children under this node,
|
||||||
* each child should be named after circuit_model
|
* each child should be named after circuit_model
|
||||||
*/
|
*/
|
||||||
|
@ -121,35 +121,3 @@ CircuitLibrary read_xml_module_circuit_models(pugi::xml_node& Node,
|
||||||
return circuit_lib;
|
return circuit_lib;
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************
|
|
||||||
* Top-level function to parse an XML file and load data to :
|
|
||||||
* 1. circuit library
|
|
||||||
*******************************************************************/
|
|
||||||
CircuitSettings read_xml_openfpga_arch(const char* arch_file_name) {
|
|
||||||
CircuitSettings circuit_settings;
|
|
||||||
|
|
||||||
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, "circuit_settings", loc_data);
|
|
||||||
|
|
||||||
/* Parse circuit_models to circuit library
|
|
||||||
* under the node <module_circuit_models>
|
|
||||||
*/
|
|
||||||
auto xml_module_circuit_models = get_single_child(xml_circuit_settings, "module_circuit_models", loc_data);
|
|
||||||
circuit_settings.circuit_lib = read_xml_module_circuit_models(xml_module_circuit_models, loc_data);
|
|
||||||
|
|
||||||
} catch (pugiutil::XmlError& e) {
|
|
||||||
archfpga_throw(arch_file_name, e.line(),
|
|
||||||
"%s", e.what());
|
|
||||||
}
|
|
||||||
|
|
||||||
return circuit_settings;
|
|
||||||
}
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
#ifndef READ_XML_CIRCUIT_LIBRARY_H
|
||||||
|
#define READ_XML_CIRCUIT_LIBRARY_H
|
||||||
|
|
||||||
|
/********************************************************************
|
||||||
|
* Include header files that are required by function declaration
|
||||||
|
*******************************************************************/
|
||||||
|
#include "pugixml_util.hpp"
|
||||||
|
#include "pugixml.hpp"
|
||||||
|
#include "circuit_library.h"
|
||||||
|
|
||||||
|
/********************************************************************
|
||||||
|
* Function declaration
|
||||||
|
*******************************************************************/
|
||||||
|
CircuitLibrary read_xml_circuit_library(pugi::xml_node& Node,
|
||||||
|
const pugiutil::loc_data& loc_data);
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,50 @@
|
||||||
|
/********************************************************************
|
||||||
|
* 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_circuit_settings.h"
|
||||||
|
|
||||||
|
/********************************************************************
|
||||||
|
* Top-level function to parse an XML file and load data to :
|
||||||
|
* 1. circuit library
|
||||||
|
*******************************************************************/
|
||||||
|
CircuitSettings read_xml_circuit_settings(const char* arch_file_name) {
|
||||||
|
CircuitSettings circuit_settings;
|
||||||
|
|
||||||
|
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, "circuit_settings", loc_data);
|
||||||
|
|
||||||
|
/* 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);
|
||||||
|
circuit_settings.circuit_lib = read_xml_circuit_library(xml_circuit_models, loc_data);
|
||||||
|
|
||||||
|
} catch (pugiutil::XmlError& e) {
|
||||||
|
archfpga_throw(arch_file_name, e.line(),
|
||||||
|
"%s", e.what());
|
||||||
|
}
|
||||||
|
|
||||||
|
return circuit_settings;
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
#ifndef READ_XML_CIRCUIT_SETTINGS_H
|
||||||
|
#define READ_XML_CIRCUIT_SETTINGS_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include "circuit_settings.h"
|
||||||
|
|
||||||
|
CircuitSettings read_xml_circuit_settings(const char* arch_file_name);
|
||||||
|
|
||||||
|
#endif
|
|
@ -5,11 +5,11 @@
|
||||||
*******************************************************************/
|
*******************************************************************/
|
||||||
#include "vtr_log.h"
|
#include "vtr_log.h"
|
||||||
|
|
||||||
#include "read_openfpga_xml.h"
|
#include "read_xml_circuit_settings.h"
|
||||||
|
|
||||||
int main(int argc, const char** argv) {
|
int main(int argc, const char** argv) {
|
||||||
/* Parse the circuit library from an XML file */
|
/* Parse the circuit library from an XML file */
|
||||||
const CircuitSettings& circuit_settings = read_xml_openfpga_arch(argv[1]);
|
const CircuitSettings& circuit_settings = read_xml_circuit_settings(argv[1]);
|
||||||
VTR_LOG("Parsed %lu circuit models from XML into circuit library.\n",
|
VTR_LOG("Parsed %lu circuit models from XML into circuit library.\n",
|
||||||
circuit_settings.circuit_lib.num_models());
|
circuit_settings.circuit_lib.num_models());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue