add configurable children-related methods to module manager

This commit is contained in:
tangxifan 2020-06-11 21:44:25 -06:00
parent aaa52b6e89
commit 8a4ec85c39
2 changed files with 34 additions and 0 deletions

View File

@ -626,6 +626,18 @@ void ModuleManager::add_configurable_child(const ModuleId& parent_module,
configurable_child_instances_[parent_module].push_back(child_instance);
}
void ModuleManager::reserve_configurable_child(const ModuleId& parent_module,
const size_t& num_children) {
VTR_ASSERT ( valid_module_id(parent_module) );
/* Do reserve when the number of children is larger than current size of lists */
if (num_children > configurable_children_[parent_module].size()) {
configurable_children_[parent_module].reserve(num_children);
}
if (num_children > configurable_child_instances_[parent_module].size()) {
configurable_child_instances_[parent_module].reserve(num_children);
}
}
/* Add a net to the connection graph of the module */
ModuleNetId ModuleManager::create_module_net(const ModuleId& module) {
/* Validate the module id */
@ -741,6 +753,16 @@ ModuleNetSinkId ModuleManager::add_module_net_sink(const ModuleId& module, const
return net_sink;
}
/******************************************************************************
* Public Deconstructor
******************************************************************************/
void ModuleManager::clear_configurable_children(const ModuleId& parent_module) {
VTR_ASSERT(valid_module_id(parent_module));
configurable_children_[parent_module].clear();
configurable_child_instances_[parent_module].clear();
}
/******************************************************************************
* Private validators/invalidators
******************************************************************************/

View File

@ -156,6 +156,11 @@ class ModuleManager {
void set_child_instance_name(const ModuleId& parent_module, const ModuleId& child_module, const size_t& instance_id, const std::string& instance_name);
/* Add a configurable child module to module */
void add_configurable_child(const ModuleId& module, const ModuleId& child_module, const size_t& child_instance);
/* Reserved a number of configurable children
* for memory efficiency
*/
void reserve_configurable_child(const ModuleId& module, const size_t& num_children);
/* Add a net to the connection graph of the module */
ModuleNetId create_module_net(const ModuleId& module);
/* Set the name of net */
@ -169,6 +174,13 @@ class ModuleManager {
ModuleNetSinkId add_module_net_sink(const ModuleId& module, const ModuleNetId& net,
const ModuleId& sink_module, const size_t& instance_id,
const ModulePortId& sink_port, const size_t& sink_pin);
public: /* Public deconstructors */
/* This is a strong function which will remove all the configurable children
* under a given parent module
* It is mainly used by loading fabric keys
* Do NOT use unless you know what you are doing!!!
*/
void clear_configurable_children(const ModuleId& parent_module);
public: /* Public validators/invalidators */
bool valid_module_id(const ModuleId& module) const;
bool valid_module_port_id(const ModuleId& module, const ModulePortId& port) const;