add openfpga read xml executable and start min unit test
This commit is contained in:
parent
d6c69ea7c6
commit
db503ffebf
|
@ -232,6 +232,12 @@ set_target_properties(libvpr vpr_shell
|
||||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/vpr7_x2p/vpr"
|
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/vpr7_x2p/vpr"
|
||||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/vpr7_x2p/vpr")
|
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/vpr7_x2p/vpr")
|
||||||
|
|
||||||
|
set_target_properties(libarchopenfpga read_arch_openfpga
|
||||||
|
PROPERTIES
|
||||||
|
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/libopenfpga/libarchopenfpga"
|
||||||
|
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/libopenfpga/libarchopenfpga"
|
||||||
|
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/libopenfpga/libarchopenfpga")
|
||||||
|
|
||||||
set_target_properties(libvpr8 vpr8
|
set_target_properties(libvpr8 vpr8
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/vpr"
|
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/vpr"
|
||||||
|
|
|
@ -72,12 +72,40 @@ e_circuit_model_type string_to_circuit_model_type(const std::string& type_string
|
||||||
return NUM_CIRCUIT_MODEL_TYPES;
|
return NUM_CIRCUIT_MODEL_TYPES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/********************************************************************
|
||||||
|
* Parse XML codes of a circuit model to circuit library
|
||||||
|
*******************************************************************/
|
||||||
|
static
|
||||||
|
void read_xml_circuit_model(pugi::xml_node& model_xml,
|
||||||
|
const pugiutil::loc_data& loc_data,
|
||||||
|
CircuitLibrary& circuit_lib) {
|
||||||
|
/* Find the type of the circuit model
|
||||||
|
* so that we can add a new circuit model to circuit library
|
||||||
|
*/
|
||||||
|
const char* type_attr = get_attribute(model_xml, "type", loc_data).value();
|
||||||
|
|
||||||
|
/* Translate the type of circuit model to enumerate */
|
||||||
|
e_circuit_model_type model_type = string_to_circuit_model_type(std::string(type_attr));
|
||||||
|
|
||||||
|
if (NUM_CIRCUIT_MODEL_TYPES == model_type) {
|
||||||
|
archfpga_throw(loc_data.filename_c_str(), loc_data.line(model_xml),
|
||||||
|
"Invalid 'type' attribute '%s'\n",
|
||||||
|
type_attr);
|
||||||
|
}
|
||||||
|
|
||||||
|
CircuitModelId model = circuit_lib.add_model(model_type);
|
||||||
|
|
||||||
|
/* Find the name of the circuit model */
|
||||||
|
const char* name_attr = get_attribute(model_xml, "name", loc_data).value();
|
||||||
|
circuit_lib.set_model_name(model, std::string(name_attr));
|
||||||
|
}
|
||||||
|
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
* Parse XML codes about circuit models to circuit library
|
* Parse XML codes about circuit models to circuit library
|
||||||
*******************************************************************/
|
*******************************************************************/
|
||||||
static
|
static
|
||||||
CircuitLibrary read_xml_circuit_models(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
|
||||||
|
@ -87,26 +115,7 @@ CircuitLibrary read_xml_circuit_models(pugi::xml_node& Node,
|
||||||
if (model_xml.name() != std::string("circuit_model")) {
|
if (model_xml.name() != std::string("circuit_model")) {
|
||||||
bad_tag(model_xml, loc_data, Node, {"circuit_model"});
|
bad_tag(model_xml, loc_data, Node, {"circuit_model"});
|
||||||
}
|
}
|
||||||
|
read_xml_circuit_model(model_xml, loc_data, circuit_lib);
|
||||||
/* Find the type of the circuit model
|
|
||||||
* so that we can add a new circuit model to circuit library
|
|
||||||
*/
|
|
||||||
const char* type_attr = get_attribute(model_xml, "type", loc_data).value();
|
|
||||||
|
|
||||||
/* Translate the type of circuit model to enumerate */
|
|
||||||
e_circuit_model_type model_type = string_to_circuit_model_type(std::string(type_attr));
|
|
||||||
|
|
||||||
if (NUM_CIRCUIT_MODEL_TYPES == model_type) {
|
|
||||||
archfpga_throw(loc_data.filename_c_str(), loc_data.line(Node),
|
|
||||||
"Invalid 'type' attribute '%s'\n",
|
|
||||||
type_attr);
|
|
||||||
}
|
|
||||||
|
|
||||||
CircuitModelId model = circuit_lib.add_model(model_type);
|
|
||||||
|
|
||||||
/* Find the name of the circuit model */
|
|
||||||
const char* name_attr = get_attribute(model_xml, "name", loc_data).value();
|
|
||||||
circuit_lib.set_model_name(model, std::string(name_attr));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return circuit_lib;
|
return circuit_lib;
|
||||||
|
@ -135,7 +144,7 @@ CircuitSettings read_xml_openfpga_arch(const char* arch_file_name) {
|
||||||
* under the node <module_circuit_models>
|
* under the node <module_circuit_models>
|
||||||
*/
|
*/
|
||||||
auto xml_module_circuit_models = get_single_child(xml_circuit_settings, "module_circuit_models", loc_data);
|
auto xml_module_circuit_models = get_single_child(xml_circuit_settings, "module_circuit_models", loc_data);
|
||||||
circuit_settings.circuit_lib = read_xml_circuit_models(xml_module_circuit_models, loc_data);
|
circuit_settings.circuit_lib = read_xml_module_circuit_models(xml_module_circuit_models, loc_data);
|
||||||
|
|
||||||
} catch (pugiutil::XmlError& e) {
|
} catch (pugiutil::XmlError& e) {
|
||||||
archfpga_throw(arch_file_name, e.line(),
|
archfpga_throw(arch_file_name, e.line(),
|
||||||
|
|
|
@ -3,11 +3,15 @@
|
||||||
* 1. parser of data structures
|
* 1. parser of data structures
|
||||||
* 2. writer of data structures
|
* 2. writer of data structures
|
||||||
*******************************************************************/
|
*******************************************************************/
|
||||||
|
#include "vtr_log.h"
|
||||||
|
|
||||||
#include "read_openfpga_xml.h"
|
#include "read_openfpga_xml.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_setting = read_xml_openfpga_arch(argv[1]);
|
const CircuitSettings& circuit_settings = read_xml_openfpga_arch(argv[1]);
|
||||||
|
VTR_LOG("Parsed %s circuit models from XML into circuit library.\n",
|
||||||
|
circuit_settings.circuit_lib.num_models());
|
||||||
|
|
||||||
/* Check the circuit library */
|
/* Check the circuit library */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue