diff --git a/libopenfpga/libarchopenfpga/arch/sample_arch.xml b/libopenfpga/libarchopenfpga/arch/sample_arch.xml
index a5f5c9adf..09dff4a9b 100644
--- a/libopenfpga/libarchopenfpga/arch/sample_arch.xml
+++ b/libopenfpga/libarchopenfpga/arch/sample_arch.xml
@@ -32,10 +32,10 @@
-
-
-
-
+
+
+
+
diff --git a/libopenfpga/libarchopenfpga/src/read_xml_openfpga_arch.cpp b/libopenfpga/libarchopenfpga/src/read_xml_openfpga_arch.cpp
index af66f78ad..8b7506f36 100644
--- a/libopenfpga/libarchopenfpga/src/read_xml_openfpga_arch.cpp
+++ b/libopenfpga/libarchopenfpga/src/read_xml_openfpga_arch.cpp
@@ -51,6 +51,8 @@ openfpga::Arch read_xml_openfpga_arch(const char* arch_file_name) {
/* Parse technology library */
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);
+ /* Build the internal link for technology library */
+ openfpga_arch.tech_lib.link_models_to_variations();
/* Second node should be */
auto xml_simulation_settings = get_single_child(doc, "openfpga_simulation_setting", loc_data);
diff --git a/libopenfpga/libarchopenfpga/src/read_xml_technology_library.cpp b/libopenfpga/libarchopenfpga/src/read_xml_technology_library.cpp
index 6db188744..f7e40a969 100644
--- a/libopenfpga/libarchopenfpga/src/read_xml_technology_library.cpp
+++ b/libopenfpga/libarchopenfpga/src/read_xml_technology_library.cpp
@@ -193,6 +193,20 @@ void read_xml_device_model(pugi::xml_node& xml_device_model,
}
}
+/********************************************************************
+ * Parse XML codes of a 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 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 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
+ */
+ 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 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);
+ read_xml_variation_lib(xml_variation_lib, loc_data, tech_lib);
return tech_lib;
}
diff --git a/libopenfpga/libarchopenfpga/src/technology_library.cpp b/libopenfpga/libarchopenfpga/src/technology_library.cpp
index e3680465d..1638d13e1 100644
--- a/libopenfpga/libarchopenfpga/src/technology_library.cpp
+++ b/libopenfpga/libarchopenfpga/src/technology_library.cpp
@@ -461,6 +461,7 @@ TechnologyVariationId TechnologyLibrary::add_variation(const std::string& name)
/* This is a legal name. we can create a new id */
TechnologyVariationId variation = TechnologyVariationId(variation_ids_.size());
+ variation_ids_.push_back(variation);
variation_names_.push_back(name);
variation_abs_values_.push_back(0.);
variation_num_sigmas_.push_back(size_t(-1));