finish XML parser for technology library

This commit is contained in:
tangxifan 2020-01-17 17:43:55 -07:00
parent e54760c677
commit 8f2936af54
4 changed files with 41 additions and 4 deletions

View File

@ -32,10 +32,10 @@
</device_model> </device_model>
</device_library> </device_library>
<variation_library> <variation_library>
<variation name="logic_transistor_var" abs_variation="0.1" num_sigma="3"/> <variation name="logic_transistor_var" abs_deviation="0.1" num_sigma="3"/>
<variation name="io_transistor_var" abs_variation="0.1" num_sigma="3"/> <variation name="io_transistor_var" abs_deviation="0.1" num_sigma="3"/>
<variation name="mem_rram_var" abs_variation="0.1" num_sigma="3"/> <variation name="mem_rram_var" abs_deviation="0.1" num_sigma="3"/>
<variation name="logic_rram_var" abs_variation="0.1" num_sigma="3"/> <variation name="logic_rram_var" abs_deviation="0.1" num_sigma="3"/>
</variation_library> </variation_library>
</technology_library> </technology_library>
<circuit_library> <circuit_library>

View File

@ -51,6 +51,8 @@ openfpga::Arch read_xml_openfpga_arch(const char* arch_file_name) {
/* Parse technology library */ /* Parse technology library */
auto xml_tech_lib = get_single_child(xml_openfpga_arch, "technology_library", loc_data); auto xml_tech_lib = get_single_child(xml_openfpga_arch, "technology_library", loc_data);
openfpga_arch.tech_lib = read_xml_technology_library(xml_tech_lib, loc_data); openfpga_arch.tech_lib = read_xml_technology_library(xml_tech_lib, loc_data);
/* Build the internal link for technology library */
openfpga_arch.tech_lib.link_models_to_variations();
/* Second node should be <openfpga_simulation_setting> */ /* Second node should be <openfpga_simulation_setting> */
auto xml_simulation_settings = get_single_child(doc, "openfpga_simulation_setting", loc_data); auto xml_simulation_settings = get_single_child(doc, "openfpga_simulation_setting", loc_data);

View File

@ -193,6 +193,20 @@ void read_xml_device_model(pugi::xml_node& xml_device_model,
} }
} }
/********************************************************************
* Parse XML codes of a <variation> to an object of technology library
*******************************************************************/
static
void read_xml_device_variation(pugi::xml_node& xml_device_variation,
const pugiutil::loc_data& loc_data,
TechnologyLibrary& tech_lib) {
/* Get the name of this variation and add it to the technology library */
TechnologyVariationId variation = tech_lib.add_variation(get_attribute(xml_device_variation, "name", loc_data).as_string());
tech_lib.set_variation_abs_value(variation, get_attribute(xml_device_variation, "abs_deviation", loc_data).as_float(0.));
tech_lib.set_variation_num_sigma(variation, get_attribute(xml_device_variation, "num_sigma", loc_data).as_int(0.));
}
/******************************************************************** /********************************************************************
* Parse XML codes of a <device_library> to an object of technology library * Parse XML codes of a <device_library> to an object of technology library
*******************************************************************/ *******************************************************************/
@ -212,6 +226,25 @@ void read_xml_device_lib(pugi::xml_node& xml_device_lib,
} }
} }
/********************************************************************
* Parse XML codes of a <variation_library> to an object of technology library
*******************************************************************/
static
void read_xml_variation_lib(pugi::xml_node& xml_variation_lib,
const pugiutil::loc_data& loc_data,
TechnologyLibrary& tech_lib) {
/* Iterate over the children under this node,
* each child should be named after <variation>
*/
for (pugi::xml_node xml_device_variation : xml_variation_lib.children()) {
/* Error out if the XML child has an invalid name! */
if (xml_device_variation.name() != std::string("variation")) {
bad_tag(xml_device_variation, loc_data, xml_variation_lib, {"variation"});
}
read_xml_device_variation(xml_device_variation, loc_data, tech_lib);
}
}
/******************************************************************** /********************************************************************
* Parse XML codes about <technology_library> to an object of technology library * Parse XML codes about <technology_library> to an object of technology library
*******************************************************************/ *******************************************************************/
@ -240,6 +273,7 @@ TechnologyLibrary read_xml_technology_library(pugi::xml_node& Node,
} }
pugi::xml_node xml_variation_lib = get_first_child(Node, "variation_library", loc_data); pugi::xml_node xml_variation_lib = get_first_child(Node, "variation_library", loc_data);
read_xml_variation_lib(xml_variation_lib, loc_data, tech_lib);
return tech_lib; return tech_lib;
} }

View File

@ -461,6 +461,7 @@ TechnologyVariationId TechnologyLibrary::add_variation(const std::string& name)
/* This is a legal name. we can create a new id */ /* This is a legal name. we can create a new id */
TechnologyVariationId variation = TechnologyVariationId(variation_ids_.size()); TechnologyVariationId variation = TechnologyVariationId(variation_ids_.size());
variation_ids_.push_back(variation);
variation_names_.push_back(name); variation_names_.push_back(name);
variation_abs_values_.push_back(0.); variation_abs_values_.push_back(0.);
variation_num_sigmas_.push_back(size_t(-1)); variation_num_sigmas_.push_back(size_t(-1));