From 66e5e141a17dd6cf9cc7ae82fc1e0b46f8379a18 Mon Sep 17 00:00:00 2001 From: tangxifan Date: Tue, 7 Jul 2020 10:19:34 -0600 Subject: [PATCH 1/2] improve fabric key loader to reduce runtime --- openfpga/src/fabric/build_top_module_memory.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/openfpga/src/fabric/build_top_module_memory.cpp b/openfpga/src/fabric/build_top_module_memory.cpp index dee342760..1650b84f3 100644 --- a/openfpga/src/fabric/build_top_module_memory.cpp +++ b/openfpga/src/fabric/build_top_module_memory.cpp @@ -426,8 +426,15 @@ int load_top_module_memory_modules_from_fabric_key(ModuleManager& module_manager std::pair instance_info(ModuleId::INVALID(), 0); /* If we have an alias, we try to find a instance in this name */ if (!fabric_key.key_alias(key).empty()) { - /* Find the module id and instance id */ - instance_info = find_module_manager_instance_module_info(module_manager, top_module, fabric_key.key_alias(key)); + /* If we have the key, we can quickly spot instance id. + * Otherwise, we have to exhaustively find the module id and instance id + */ + if (!fabric_key.key_name(key).empty()) { + instance_info.first = module_manager.find_module(fabric_key.key_name(key)); + instance_info.second = module_manager.instance_id(top_module, instance_info.first, fabric_key.key_alias(key)); + } else { + instance_info = find_module_manager_instance_module_info(module_manager, top_module, fabric_key.key_alias(key)); + } } else { /* If we do not have an alias, we use the name and value to build the info deck */ instance_info.first = module_manager.find_module(fabric_key.key_name(key)); From 65dfc545c112692ce70053d2cab0310fbe6bf8ea Mon Sep 17 00:00:00 2001 From: tangxifan Date: Tue, 7 Jul 2020 10:28:29 -0600 Subject: [PATCH 2/2] update documentation for fabric key --- docs/source/manual/arch_lang/fabric_key.rst | 116 ++++++++++++++------ 1 file changed, 80 insertions(+), 36 deletions(-) diff --git a/docs/source/manual/arch_lang/fabric_key.rst b/docs/source/manual/arch_lang/fabric_key.rst index 54ae5af90..4e0086aeb 100644 --- a/docs/source/manual/arch_lang/fabric_key.rst +++ b/docs/source/manual/arch_lang/fabric_key.rst @@ -23,48 +23,92 @@ A fabric key follows an XML format. As shown in the following XML code, the key - ``id`` indicates the sequence of the configurable memory block in the top-level FPGA fabric. - - ``name`` indicates the module name of the configurable memory block. + - ``name`` indicates the module name of the configurable memory block. This property becomes optional when ``alias`` is defined. - - ``value`` indicates the instance id of the configurable memory block in the top-level FPGA fabric. + - ``value`` indicates the instance id of the configurable memory block in the top-level FPGA fabric. This property becomes optional when ``alias`` is defined. - - ``alias`` indicates the instance name of the configurable memory block in the top-level FPGA fabric. If a valid alias is specified, the ``value`` will not be considered. + - ``alias`` indicates the instance name of the configurable memory block in the top-level FPGA fabric. If a valid alias is specified, the ``name`` and ``value`` are not required. + +.. note:: For fast loading of fabric key, strongly recommend to use pairs ``name`` and ``alias`` or ``name`` and ``value`` in the fabric key file. Using only ``alias`` may cause long parsing time for fabric key. The following is an example of a fabric key generate by OpenFPGA for a 2 :math:`\times` 2 FPGA. +This key contains only ``alias`` which is easy to craft. .. code-block:: xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +The following shows another example of a fabric key generate by OpenFPGA for a 2 :math:`\times` 2 FPGA. +This key contains only ``name`` and ``value`` which is fast to parse. + +.. code-block:: xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +