From 088198c8610b676f91e370a0c59ddae2c4bc2f7a Mon Sep 17 00:00:00 2001 From: tangxifan Date: Fri, 13 Nov 2020 10:56:00 -0700 Subject: [PATCH] [Tool] enhance error checking in fabric key parser --- openfpga/src/fabric/build_top_module.cpp | 1 + openfpga/src/fabric/build_top_module_memory.cpp | 16 ++++++++++++++++ openfpga/src/fabric/build_top_module_memory.h | 2 ++ 3 files changed, 19 insertions(+) diff --git a/openfpga/src/fabric/build_top_module.cpp b/openfpga/src/fabric/build_top_module.cpp index 80d6e768c..5d2d87aaa 100644 --- a/openfpga/src/fabric/build_top_module.cpp +++ b/openfpga/src/fabric/build_top_module.cpp @@ -381,6 +381,7 @@ int build_top_module(ModuleManager& module_manager, } status = load_top_module_memory_modules_from_fabric_key(module_manager, top_module, + circuit_lib, config_protocol, fabric_key); if (CMD_EXEC_FATAL_ERROR == status) { return status; diff --git a/openfpga/src/fabric/build_top_module_memory.cpp b/openfpga/src/fabric/build_top_module_memory.cpp index 91275b3bd..422a73ff2 100644 --- a/openfpga/src/fabric/build_top_module_memory.cpp +++ b/openfpga/src/fabric/build_top_module_memory.cpp @@ -523,6 +523,8 @@ void shuffle_top_module_configurable_children(ModuleManager& module_manager, ********************************************************************/ int load_top_module_memory_modules_from_fabric_key(ModuleManager& module_manager, const ModuleId& top_module, + const CircuitLibrary& circuit_lib, + const ConfigProtocol& config_protocol, const FabricKey& fabric_key) { /* Ensure a clean start */ module_manager.clear_configurable_children(top_module); @@ -574,6 +576,20 @@ int load_top_module_memory_modules_from_fabric_key(ModuleManager& module_manager return CMD_EXEC_FATAL_ERROR; } + /* If the the child has not configuration bits, error out */ + if (0 == find_module_num_config_bits(module_manager, instance_info.first, + circuit_lib, config_protocol.memory_model(), + config_protocol.type())) { + if (!fabric_key.key_alias(key).empty()) { + VTR_LOG_ERROR("Invalid key alias '%s' which has zero configuration bits!\n", + fabric_key.key_alias(key).c_str()); + } else { + VTR_LOG_ERROR("Invalid key name '%s' which has zero configuration bits!\n", + fabric_key.key_name(key).c_str()); + } + return CMD_EXEC_FATAL_ERROR; + } + /* Now we can add the child to configurable children of the top module */ module_manager.add_configurable_child(top_module, instance_info.first, diff --git a/openfpga/src/fabric/build_top_module_memory.h b/openfpga/src/fabric/build_top_module_memory.h index 7e93ca85a..e1d495fd4 100644 --- a/openfpga/src/fabric/build_top_module_memory.h +++ b/openfpga/src/fabric/build_top_module_memory.h @@ -44,6 +44,8 @@ void shuffle_top_module_configurable_children(ModuleManager& module_manager, int load_top_module_memory_modules_from_fabric_key(ModuleManager& module_manager, const ModuleId& top_module, + const CircuitLibrary& circuit_lib, + const ConfigProtocol& config_protocol, const FabricKey& fabric_key); vtr::vector find_top_module_regional_num_config_bit(const ModuleManager& module_manager,