Skip to content

Commit

Permalink
Merge branch 'master' into feature/word_level_structures
Browse files Browse the repository at this point in the history
  • Loading branch information
SJulianS committed Oct 24, 2023
2 parents adcca15 + 4b35a0f commit 55bfe06
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 61 deletions.
24 changes: 16 additions & 8 deletions include/hal_core/netlist/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,10 @@ namespace hal
* @param[in] net - The net that the pin is being assigned to.
* @param[in] type - The type of the pin. Defaults to `PinType::none`.
* @param[in] create_group - Set `true` to automatically create a pin group and assign the pin, `false` otherwise. Defaults to `true`.
* @param[in] force_name - Set `true` to enforce the name, `false` otherwise. If a pin with the same name already exists, the existing pin will be renamed. Defaults to `false`.
* @returns The module pin on success, an error message otherwise.
*/
Result<ModulePin*> create_pin(const u32 id, const std::string& name, Net* net, PinType type = PinType::none, bool create_group = true);
Result<ModulePin*> create_pin(const u32 id, const std::string& name, Net* net, PinType type = PinType::none, bool create_group = true, bool force_name = false);

/**
* Manually create a module pin and assign it to a net.
Expand All @@ -355,9 +356,10 @@ namespace hal
* @param[in] net - The net that the pin is being assigned to.
* @param[in] type - The type of the pin. Defaults to `PinType::none`.
* @param[in] create_group - Set `true` to automatically create a pin group and assign the pin, `false` otherwise. Defaults to `true`.
* @param[in] force_name - Set `true` to enforce the name, `false` otherwise. If a pin with the same name already exists, the existing pin will be renamed. Defaults to `false`.
* @returns The module pin on success, an error message otherwise.
*/
Result<ModulePin*> create_pin(const std::string& name, Net* net, PinType type = PinType::none, bool create_group = true);
Result<ModulePin*> create_pin(const std::string& name, Net* net, PinType type = PinType::none, bool create_group = true, bool force_name = false);

/**
* Get an ordered vector of all pins of the module.
Expand Down Expand Up @@ -459,9 +461,10 @@ namespace hal
*
* @param[in] pin - The pin.
* @param[in] new_name - The name to be assigned to the pin.
* @param[in] force_name - Set `true` to enforce the name, `false` otherwise. If a pin with the same name already exists, that existing pin will be renamed. Defaults to `false`.
* @returns `true` on success, `false` otherwise.
*/
bool set_pin_name(ModulePin* pin, const std::string& new_name);
bool set_pin_name(ModulePin* pin, const std::string& new_name, bool force_name = false);

/**
* Set the type of the given pin.
Expand All @@ -483,6 +486,7 @@ namespace hal
* @param[in] ascending - Set `true` for ascending pin order (from 0 to n-1), `false` otherwise (from n-1 to 0). Defaults to `true`.
* @param[in] start_index - The start index of the pin group. Defaults to `0`.
* @param[in] delete_empty_groups - Set `true` to delete groups that are empty after the pins have been assigned to the new group, `false` to keep empty groups. Defaults to `true`.
* @param[in] force_name - Set `true` to enforce the name, `false` otherwise. If a pin group with the same name already exists, the existing pin group will be renamed. Defaults to `false`.
* @returns The pin group on success, an error message otherwise.
*/
Result<PinGroup<ModulePin>*> create_pin_group(const u32 id,
Expand All @@ -492,7 +496,8 @@ namespace hal
PinType type = PinType::none,
bool ascending = true,
u32 start_index = 0,
bool delete_empty_groups = true);
bool delete_empty_groups = true,
bool force_name = false);

/**
* Create a new pin group with the given name.
Expand All @@ -505,6 +510,7 @@ namespace hal
* @param[in] ascending - Set `true` for ascending pin order (from 0 to n-1), `false` otherwise (from n-1 to 0). Defaults to `true`.
* @param[in] start_index - The start index of the pin group. Defaults to `0`.
* @param[in] delete_empty_groups - Set `true` to delete groups that are empty after the pins have been assigned to the new group, `false` to keep empty groups. Defaults to `true`.
* @param[in] force_name - Set `true` to enforce the name, `false` otherwise. If a pin group with the same name already exists, the existing pin group will be renamed. Defaults to `false`.
* @returns The pin group on success, an error message otherwise.
*/
Result<PinGroup<ModulePin>*> create_pin_group(const std::string& name,
Expand All @@ -513,7 +519,8 @@ namespace hal
PinType type = PinType::none,
bool ascending = true,
u32 start_index = 0,
bool delete_empty_groups = true);
bool delete_empty_groups = true,
bool force_name = false);

/**
* Delete the given pin group.
Expand All @@ -538,9 +545,10 @@ namespace hal
*
* @param[in] pin_group - The pin group.
* @param[in] new_name - The name to be assigned to the pin group.
* @param[in] force_name - Set `true` to enforce the name, `false` otherwise. If a pin group with the same name already exists, the existing pin group will be renamed. Defaults to `false`.
* @returns `true` on success, `false` otherwise.
*/
bool set_pin_group_name(PinGroup<ModulePin>* pin_group, const std::string& new_name);
bool set_pin_group_name(PinGroup<ModulePin>* pin_group, const std::string& new_name, bool force_name = false);

/**
* Set the type of the given pin group.
Expand Down Expand Up @@ -735,9 +743,9 @@ namespace hal
Result<std::monostate> check_net(Net* net, bool recursive = false);
Result<ModulePin*> assign_pin_net(const u32 pin_id, Net* net, PinDirection direction, const std::string& name = "", PinType type = PinType::none);
Result<std::monostate> remove_pin_net(Net* net);
Result<ModulePin*> create_pin_internal(const u32 id, const std::string& name, Net* net, PinDirection direction, PinType type);
Result<ModulePin*> create_pin_internal(const u32 id, const std::string& name, Net* net, PinDirection direction, PinType type, bool force_name);
Result<std::monostate> delete_pin_internal(ModulePin* pin);
Result<PinGroup<ModulePin>*> create_pin_group_internal(const u32 id, const std::string& name, PinDirection direction, PinType type, bool ascending, u32 start_index);
Result<PinGroup<ModulePin>*> create_pin_group_internal(const u32 id, const std::string& name, PinDirection direction, PinType type, bool ascending, u32 start_index, bool force_name);
Result<std::monostate> delete_pin_group_internal(PinGroup<ModulePin>* pin_group);
};
} // namespace hal
12 changes: 8 additions & 4 deletions plugins/gui/src/graph_widget/graph_context_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,20 @@ namespace hal
void GraphContextManager::handleModuleRemoved(Module* m)
{
for (GraphContext* context : mContextTableModel->list())
if (context->modules().contains(m->get_id()))
{
if (context->getExclusiveModuleId() == m->get_id())
{
context->setExclusiveModuleId(0, false);
deleteGraphContext(context);
}
else if (context->modules().contains(m->get_id()))
{
if (context->getExclusiveModuleId() == m->get_id())
context->setExclusiveModuleId(0, false);

context->remove({m->get_id()}, {});

if (context->empty() || context->willBeEmptied())
deleteGraphContext(context);
}
}
}

void GraphContextManager::handleModuleNameChanged(Module* m) const
Expand Down
2 changes: 1 addition & 1 deletion plugins/gui/src/module_model/module_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ namespace hal
void ModuleModel::remove_module(const u32 id)
{
assert(id != 1);
assert(gNetlist->get_module_by_id(id));
// module was most likely already purged from netlist
assert(mModuleItems.contains(id));

ModuleItem* item = mModuleItems.value(id);
Expand Down
Loading

0 comments on commit 55bfe06

Please sign in to comment.