diff --git a/libopenfpga/libfabrickey/src/read_xml_fabric_key.cpp b/libopenfpga/libfabrickey/src/read_xml_fabric_key.cpp index f509ddc79..24e0d8255 100644 --- a/libopenfpga/libfabrickey/src/read_xml_fabric_key.cpp +++ b/libopenfpga/libfabrickey/src/read_xml_fabric_key.cpp @@ -129,7 +129,7 @@ FabricKey read_xml_fabric_key(const char* key_fname) { if (xml_region.name() != std::string("region")) { bad_tag(xml_region, loc_data, xml_root, {"region"}); } - num_keys += std::distance(xml_root.children().begin(), xml_root.children().end()); + num_keys += std::distance(xml_region.children().begin(), xml_region.children().end()); } fabric_key.reserve_keys(num_keys); diff --git a/openfpga/src/fabric/fabric_key_writer.cpp b/openfpga/src/fabric/fabric_key_writer.cpp index 83a83c965..e3920370b 100644 --- a/openfpga/src/fabric/fabric_key_writer.cpp +++ b/openfpga/src/fabric/fabric_key_writer.cpp @@ -65,6 +65,11 @@ int write_fabric_key_to_xml_file(const ModuleManager& module_manager, num_keys -= 1; } + /* FIXME: create a region for the keys. Later down the road, we will create multiple regions */ + fabric_key.reserve_regions(1); + FabricRegionId region = fabric_key.create_region(); + fabric_key.reserve_region_keys(region, num_keys); + fabric_key.reserve_keys(num_keys); for (size_t ichild = 0; ichild < num_keys; ++ichild) { @@ -78,6 +83,9 @@ int write_fabric_key_to_xml_file(const ModuleManager& module_manager, if (false == module_manager.instance_name(top_module, child_module, child_instance).empty()) { fabric_key.set_key_alias(key, module_manager.instance_name(top_module, child_module, child_instance)); } + + /* Add keys to the region */ + fabric_key.add_key_to_region(region, key); } VTR_LOGV(verbose,