HAL
hal::Module Class Reference

#include <module.h>

Inheritance diagram for hal::Module:
Inheritance graph
Collaboration diagram for hal::Module:
Collaboration graph

Public Member Functions

bool operator== (const Module &other) const
 
bool operator!= (const Module &other) const
 
ssize_t get_hash () const
 
u32 get_id () const
 
std::string get_name () const
 
void set_name (const std::string &name)
 
std::string get_type () const
 
void set_type (const std::string &type)
 
Groupingget_grouping () const
 
int get_submodule_depth () const
 
Moduleget_parent_module () const
 
std::vector< Module * > get_parent_modules (const std::function< bool(Module *)> &filter=nullptr, bool recursive=true) const
 
bool set_parent_module (Module *new_parent)
 
bool is_parent_module_of (const Module *module, bool recursive=false) const
 
std::vector< Module * > get_submodules (const std::function< bool(Module *)> &filter=nullptr, bool recursive=false) const
 
bool is_submodule_of (const Module *module, bool recursive=false) const
 
bool contains_module (const Module *other, bool recursive=false) const
 
bool is_top_module () const
 
Netlistget_netlist () const
 
void update_nets ()
 
bool contains_net (Net *net, bool recursive=false) const
 
const std::unordered_set< Net * > & get_nets () const
 
std::unordered_set< Net * > get_nets (const std::function< bool(Net *)> &filter, bool recursive=false) const
 
const std::unordered_set< Net * > & get_input_nets () const
 
const std::unordered_set< Net * > & get_output_nets () const
 
const std::unordered_set< Net * > & get_internal_nets () const
 
bool is_input_net (Net *net) const
 
bool is_output_net (Net *net) const
 
bool is_internal_net (Net *net) const
 
u32 get_unique_pin_id ()
 
u32 get_unique_pin_group_id ()
 
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)
 
Result< ModulePin * > create_pin (const std::string &name, Net *net, PinType type=PinType::none, bool create_group=true, bool force_name=false)
 
std::vector< ModulePin * > get_pins (const std::function< bool(ModulePin *)> &filter=nullptr) const
 
std::vector< std::string > get_pin_names (const std::function< bool(ModulePin *)> &filter=nullptr) const
 
std::vector< ModulePin * > get_input_pins () const
 
std::vector< std::string > get_input_pin_names () const
 
std::vector< ModulePin * > get_output_pins () const
 
std::vector< std::string > get_output_pin_names () const
 
std::vector< PinGroup< ModulePin > * > get_pin_groups (const std::function< bool(PinGroup< ModulePin > *)> &filter=nullptr) const
 
ModulePinget_pin_by_id (const u32 id) const
 
ModulePinget_pin_by_name (const std::string &name) const
 
ModulePinget_pin_by_net (Net *net) const
 
PinGroup< ModulePin > * get_pin_group_by_id (const u32 id) const
 
PinGroup< ModulePin > * get_pin_group_by_name (const std::string &name) const
 
bool set_pin_name (ModulePin *pin, const std::string &new_name, bool force_name=false)
 
bool set_pin_type (ModulePin *pin, PinType new_type)
 
Result< PinGroup< ModulePin > * > create_pin_group (const u32 id, const std::string &name, const std::vector< ModulePin * > pins={}, PinDirection direction=PinDirection::none, PinType type=PinType::none, bool ascending=true, u32 start_index=0, bool delete_empty_groups=true, bool force_name=false)
 
Result< PinGroup< ModulePin > * > create_pin_group (const std::string &name, const std::vector< ModulePin * > pins={}, PinDirection direction=PinDirection::none, PinType type=PinType::none, bool ascending=true, u32 start_index=0, bool delete_empty_groups=true, bool force_name=false)
 
bool delete_pin_group (PinGroup< ModulePin > *pin_group)
 
bool move_pin_group (PinGroup< ModulePin > *pin_group, u32 new_index)
 
bool set_pin_group_name (PinGroup< ModulePin > *pin_group, const std::string &new_name, bool force_name=false)
 
bool set_pin_group_type (PinGroup< ModulePin > *pin_group, PinType new_type)
 
bool set_pin_group_direction (PinGroup< ModulePin > *pin_group, PinDirection new_direction)
 
bool assign_pin_to_group (PinGroup< ModulePin > *pin_group, ModulePin *pin, bool delete_empty_groups=true)
 
bool move_pin_within_group (PinGroup< ModulePin > *pin_group, ModulePin *pin, u32 new_index)
 
bool remove_pin_from_group (PinGroup< ModulePin > *pin_group, ModulePin *pin, bool delete_empty_groups=true)
 
bool assign_gate (Gate *gate)
 
bool assign_gates (const std::vector< Gate * > &gates)
 
bool remove_gate (Gate *gate)
 
bool remove_gates (const std::vector< Gate * > &gates)
 
bool contains_gate (Gate *gate, bool recursive=false) const
 
Gateget_gate_by_id (const u32 id, bool recursive=false) const
 
const std::vector< Gate * > & get_gates () const
 
std::vector< Gate * > get_gates (const std::function< bool(Gate *)> &filter, bool recursive=false) const
 
EventHandlerget_event_handler () const
 
- Public Member Functions inherited from hal::DataContainer
 DataContainer ()=default
 
virtual ~DataContainer ()=default
 
bool operator== (const DataContainer &other) const
 
bool operator!= (const DataContainer &other) const
 
bool set_data (const std::string &category, const std::string &key, const std::string &data_type, const std::string &value, const bool log_with_info_level=false)
 
bool has_data (const std::string &category, const std::string &key) const
 
std::tuple< std::string, std::string > get_data (const std::string &category, const std::string &key) const
 
bool delete_data (const std::string &category, const std::string &key, const bool log_with_info_level=false)
 
const std::map< std::tuple< std::string, std::string >, std::tuple< std::string, std::string > > & get_data_map () const
 
void set_data_map (const std::map< std::tuple< std::string, std::string >, std::tuple< std::string, std::string >> &map)
 

Friends

class NetlistInternalManager
 

Additional Inherited Members

- Protected Attributes inherited from hal::DataContainer
std::map< std::tuple< std::string, std::string >, std::tuple< std::string, std::string > > m_data
 

Detailed Description

A module is a container for gates and their associated nets that enables hierarchization within the netlist.
Each gate can only be in one module at a time. Nets are only loosely associated with modules.

Definition at line 65 of file module.h.

Member Function Documentation

◆ assign_gate()

bool hal::Module::assign_gate ( Gate gate)

Assign a gate to the module.
The gate is removed from its previous module in the process.

Parameters
[in]gate- The gate to assign.
Returns
true on success, false otherwise.

Definition at line 322 of file module.cpp.

Referenced by hal::module_init(), and hal::NetlistModificationDecorator::replace_gate().

◆ assign_gates()

bool hal::Module::assign_gates ( const std::vector< Gate * > &  gates)

Assign a vector of gates to the module.
The gates are removed from their previous module in the process.

Parameters
[in]gates- The gates to assign.
Returns
true on success, false otherwise.

Definition at line 327 of file module.cpp.

Referenced by hal::Netlist::create_module(), hal::ActionAddItemsToObject::exec(), and hal::module_init().

◆ assign_pin_to_group()

bool hal::Module::assign_pin_to_group ( PinGroup< ModulePin > *  pin_group,
ModulePin pin,
bool  delete_empty_groups = true 
)

Assign a pin to a pin group.

Parameters
[in]pin_group- The new pin group.
[in]pin- The pin to be added.
[in]delete_empty_groups- Set true to delete groups that are empty after the pin has been assigned to the new group, false to keep empty groups. Defaults to true.
Returns
true on success, false otherwise.

Definition at line 1402 of file module.cpp.

References hal::PinGroup< T >::assign_pin(), hal::PinGroup< T >::contains_pin(), hal::BasePin< T >::get_group(), hal::BasePin< T >::get_id(), hal::PinGroup< T >::get_id(), hal::BasePin< T >::get_name(), hal::PinGroup< T >::get_name(), hal::GroupDelete, log_warning, hal::PinAssignToGroup, hal::PinChangedEvent::send(), and hal::PinChangedEventScope::send_events().

Referenced by create_pin_group(), and hal::ActionPingroup::exec().

◆ contains_gate()

bool hal::Module::contains_gate ( Gate gate,
bool  recursive = false 
) const

Check whether a gate is contained in the module.
If recursive is true, gates in submodules are considered as well.

Parameters
[in]gate- The gate to check for.
[in]recursive- Set to true to also consider gates in submodules, false otherwise.
Returns
true if the gate is contained in the module, false otherwise.

Definition at line 350 of file module.cpp.

Referenced by hal::module_init(), and remove_gates().

◆ contains_module()

bool hal::Module::contains_module ( const Module other,
bool  recursive = false 
) const

Checks whether another module is a submodule of this module.
If recursive is set to true, all indirect submodules are also included.

Parameters
[in]other- Other module to check for.
[in]recursive- Set true to include indirect submodules as well, false otherwise.
Returns
true if the other module is a submodule, false otherwise.

Definition at line 307 of file module.cpp.

References is_parent_module_of().

Referenced by hal::module_init().

◆ contains_net()

bool hal::Module::contains_net ( Net net,
bool  recursive = false 
) const

Check whether a net is contained in the module.
If recursive is set to true, nets in submodules are considered as well.

Parameters
[in]net- The net to check for.
[in]recursive- True to also consider nets in submodules, false otherwise.
Returns
true if the net is contained in the module, false otherwise.

Definition at line 483 of file module.cpp.

References net.

Referenced by hal::module_init().

◆ create_pin() [1/2]

Result< ModulePin * > hal::Module::create_pin ( 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. The ID of the pin is set automatically. Checks whether the given direction matches the actual properties of the net, i.e., checks whether the net actually is an input and/or output to the module. Hence, make sure to update the module nets beforehand using Module::update_nets. If create_group is set to false, the pin will not be added to a pin group.

Warning
{WARNING: can only be used when automatic net checks have been disabled using Netlist::enable_automatic_net_checks.}
Parameters
[in]name- The name of the pin.
[in]net- The net that the pin is being assigned to.
[in]type- The type of the pin. Defaults to PinType::none.
[in]create_group- Set true to automatically create a pin group and assign the pin, false otherwise. Defaults to true.
[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.

Definition at line 866 of file module.cpp.

References create_pin(), get_unique_pin_id(), name, net, and type.

◆ create_pin() [2/2]

Result< ModulePin * > hal::Module::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. Checks whether the given direction matches the actual properties of the net, i.e., checks whether the net actually is an input and/or output to the module. Hence, make sure to update the module nets beforehand using Module::update_nets. If create_group is set to false, the pin will not be added to a pin group.

Warning
{WARNING: can only be used when automatic net checks have been disabled using Netlist::enable_automatic_net_checks.}
Parameters
[in]id- The ID of the pin.
[in]name- The name of the pin.
[in]net- The net that the pin is being assigned to.
[in]type- The type of the pin. Defaults to PinType::none.
[in]create_group- Set true to automatically create a pin group and assign the pin, false otherwise. Defaults to true.
[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.

Definition at line 787 of file module.cpp.

References direction, ERR, ERR_APPEND, get_unique_pin_group_id(), hal::GroupCreate, hal::inout, hal::input, is_input_net(), is_output_net(), name, net, hal::output, hal::PinCreate, hal::PinChangedEvent::send(), and type.

Referenced by hal::SubgraphNetlistDecorator::copy_subgraph_netlist(), and create_pin().

◆ create_pin_group() [1/2]

Result< PinGroup< ModulePin > * > hal::Module::create_pin_group ( const std::string &  name,
const std::vector< ModulePin * >  pins = {},
PinDirection  direction = PinDirection::none,
PinType  type = PinType::none,
bool  ascending = true,
u32  start_index = 0,
bool  delete_empty_groups = true,
bool  force_name = false 
)

Create a new pin group with the given name. The ID of the pin group is set automatically.

Parameters
[in]name- The name of the pin group.
[in]pins- The pins to be assigned to the pin group. Defaults to an empty vector.
[in]direction- The direction of the pin group, if any. Defaults to PinDirection::none.
[in]type- The type of the pin group, if any. Defaults to PinType::none.
[in]ascending- Set true for ascending pin order (from 0 to n-1), false otherwise (from n-1 to 0). Defaults to true.
[in]start_index- The start index of the pin group. Defaults to 0.
[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.
[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.

Definition at line 1308 of file module.cpp.

References ascending, create_pin_group(), direction, get_unique_pin_group_id(), name, pins, start_index, and type.

◆ create_pin_group() [2/2]

Result< PinGroup< ModulePin > * > hal::Module::create_pin_group ( const u32  id,
const std::string &  name,
const std::vector< ModulePin * >  pins = {},
PinDirection  direction = PinDirection::none,
PinType  type = PinType::none,
bool  ascending = true,
u32  start_index = 0,
bool  delete_empty_groups = true,
bool  force_name = false 
)

Create a new pin group with the given name.

Parameters
[in]id- The ID of the pin group.
[in]name- The name of the pin group.
[in]pins- The pins to be assigned to the pin group. Defaults to an empty vector.
[in]direction- The direction of the pin group, if any. Defaults to PinDirection::none.
[in]type- The type of the pin group, if any. Defaults to PinType::none.
[in]ascending- Set true for ascending pin order (from 0 to n-1), false otherwise (from n-1 to 0). Defaults to true.
[in]start_index- The start index of the pin group. Defaults to 0.
[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.
[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.

Definition at line 1251 of file module.cpp.

References ascending, assign_pin_to_group(), delete_pin_group(), direction, ERR, ERR_APPEND, hal::PinGroup< T >::get_id(), hal::GroupCreate, name, OK, pins, hal::PinChangedEvent::send(), hal::PinChangedEventScope::send_events(), start_index, and type.

Referenced by create_pin_group(), delete_pin_group(), hal::ActionPingroup::exec(), and remove_pin_from_group().

◆ delete_pin_group()

bool hal::Module::delete_pin_group ( PinGroup< ModulePin > *  pin_group)

Delete the given pin group.

Parameters
[in]pin_group- The pin group to be deleted.
Returns
true on success, false otherwise.

Definition at line 1320 of file module.cpp.

References create_pin_group(), hal::PinGroup< T >::get_id(), hal::PinGroup< T >::get_name(), hal::PinGroup< T >::get_pins(), hal::GroupCreate, hal::GroupDelete, log_warning, hal::PinAssignToGroup, hal::PinChangedEvent::send(), and hal::PinChangedEventScope::send_events().

Referenced by create_pin_group(), and hal::ActionPingroup::exec().

◆ get_event_handler()

EventHandler * hal::Module::get_event_handler ( ) const

Get the event handler connected to module

Returns
The event handler;

Definition at line 1899 of file module.cpp.

Referenced by hal::PinChangedEvent::send().

◆ get_gate_by_id()

Gate * hal::Module::get_gate_by_id ( const u32  id,
bool  recursive = false 
) const

Get a gate specified by the given ID.
If recursive is true, gates in submodules are considered as well.

Parameters
[in]id- The unique ID of the gate.
[in]recursive- Set to true to also consider gates in submodules, false otherwise.
Returns
The gate on success, a nullptr otherwise.

Definition at line 370 of file module.cpp.

Referenced by hal::module_init().

◆ get_gates() [1/2]

◆ get_gates() [2/2]

std::vector< Gate * > hal::Module::get_gates ( const std::function< bool(Gate *)> &  filter,
bool  recursive = false 
) const

Get all gates contained within the module. The filter is evaluated on every candidate such that the result only contains those matching the specified condition. If recursive is true, gates in submodules are considered as well.

Parameters
[in]filter- Filter function to be evaluated on each gate.
[in]recursive- Set to true to also consider gates in submodules, false otherwise. Defaults to false.
Returns
A vector of gates.

Definition at line 396 of file module.cpp.

References test_plugin::g.

◆ get_grouping()

◆ get_hash()

ssize_t hal::Module::get_hash ( ) const

Hash function for python binding

Returns
Pybind11 compatible hash

Definition at line 77 of file module.cpp.

Referenced by hal::module_init().

◆ get_id()

u32 hal::Module::get_id ( ) const

Get the unique ID of the module.

Returns
The unique id.

Definition at line 82 of file module.cpp.

Referenced by hal::ActionPingroup::addPinsToExistingGroup(), hal::ActionPingroup::addPinsToNewGroup(), hal::ModuleModel::addRecursively(), hal::GuiApiClasses::View::addTo(), hal::NetlistRelay::addToModuleDialog(), hal::ModuleSelectModel::appendEntries(), hal::Grouping::contains_module(), hal::NetlistRelay::debugHandleFileOpened(), hal::NetlistModificationDecorator::delete_modules(), hal::ActionPingroup::deletePinGroup(), hal::GuiApi::deselectModule(), hal::dumpPingroups(), hal::ActionAddItemsToObject::exec(), hal::ActionCreateObject::exec(), hal::ActionDeleteObject::exec(), hal::gui_utility::firstCommonAncestor(), hal::GuiApiClasses::View::foldModule(), hal::Grouping::get_module_ids(), hal::GuiApiClasses::View::getIds(), hal::ModulePinsTreeModel::getNetFromItem(), hal::ModulePinsTreeModel::getRepresentedModuleId(), hal::GuiApiClasses::View::getValidObjects(), hal::SelectionDetailsWidget::groupingUnassignActionFactory(), hal::event_log::handle_grouping_event(), hal::event_log::handle_module_event(), hal::GraphContextManager::handleModuleColorChanged(), hal::GraphContextManager::handleModuleCreated(), hal::GraphContextManager::handleModuleGateAssigned(), hal::GraphContextManager::handleModuleGateRemoved(), hal::GraphContextManager::handleModuleNameChanged(), hal::GraphContextManager::handleModulePortsChanged(), hal::ModuleTableModel::handleModulePortsChanged(), hal::GraphContextManager::handleModuleRemoved(), hal::ModuleTableModel::handleModuleRemoved(), hal::GraphContextManager::handleModuleSubmoduleAdded(), hal::GraphContextManager::handleModuleSubmoduleRemoved(), hal::GraphContextManager::handleModuleTypeChanged(), hal::ModuleSelectPicker::handleSelectionChanged(), hal::GraphGraphicsView::handleShortestPath(), hal::ModulePinsTreeModel::mimeData(), hal::ShortestPath::module(), hal::module_init(), hal::ModuleSelectEntry::ModuleSelectEntry(), hal::GraphContext::nodeForGate(), hal::GraphContextManager::openModuleInView(), operator==(), hal::gui_utility::parentModules(), hal::ModuleModel::populateFromGatelist(), hal::GuiApiClasses::View::removeFrom(), hal::ActionPingroup::removePinsFromGroup(), hal::ModuleSelectExclude::selectionToString(), hal::GuiApi::selectModule(), set_parent_module(), hal::ModuleElementsTree::setModule(), hal::ModulePinsTree::setModule(), hal::DataTableWidget::setModule(), hal::GroupingsOfItemModel::setModule(), hal::GroupingsOfItemWidget::setModule(), hal::ModuleDetailsTabWidget::setModule(), hal::GraphNavigationWidget::setup(), hal::GuiApiClasses::View::unfoldModule(), hal::ModuleShader::update(), hal::ModuleModel::updateModuleParent(), and hal::ModuleModel::updateNetParent().

◆ get_input_nets()

const std::unordered_set< Net * > & hal::Module::get_input_nets ( ) const

Get all nets that are either a global input to the netlist or have at least one source outside of the module.

Returns
An unordered set of input nets.

Definition at line 540 of file module.cpp.

Referenced by hal::SubgraphNetlistDecorator::copy_subgraph_netlist(), hal::ModuleTableModel::handleModulePortsChanged(), hal::module_init(), hal::SelectionRelay::navigateDown(), hal::SelectionRelay::navigateUp(), and hal::GraphContext::updateNets().

◆ get_input_pin_names()

std::vector< std::string > hal::Module::get_input_pin_names ( ) const

Get an ordered vector of the names of all input pins of the module (including inout pins).

Returns
An ordered vector of input pin names.

Definition at line 938 of file module.cpp.

References direction, hal::BasePin< T >::get_direction(), get_pin_names(), hal::inout, and hal::input.

Referenced by hal::module_init().

◆ get_input_pins()

std::vector< ModulePin * > hal::Module::get_input_pins ( ) const

Get an ordered vector of all input pins of the module (including inout pins).

Returns
An ordered vector of input pins.

Definition at line 930 of file module.cpp.

References direction, hal::BasePin< T >::get_direction(), get_pins(), hal::inout, and hal::input.

Referenced by hal::module_init().

◆ get_internal_nets()

const std::unordered_set< Net * > & hal::Module::get_internal_nets ( ) const

Get all nets that have at least one source and one destination within the module, including its submodules. The result may contain nets that are also regarded as input or output nets.

Returns
An unordered set of internal nets.

Definition at line 550 of file module.cpp.

Referenced by hal::module_init().

◆ get_name()

◆ get_netlist()

Netlist * hal::Module::get_netlist ( ) const

Get the netlist this module is associated with.

Returns
The netlist.

Definition at line 317 of file module.cpp.

Referenced by hal::event_log::handle_module_event(), hal::module_init(), and set_parent_module().

◆ get_nets() [1/2]

const std::unordered_set< Net * > & hal::Module::get_nets ( ) const

Get all nets that have at least one source or one destination within the module.

Returns
An unordered set of nets.

Definition at line 503 of file module.cpp.

Referenced by hal::module_init(), and set_parent_module().

◆ get_nets() [2/2]

std::unordered_set< Net * > hal::Module::get_nets ( const std::function< bool(Net *)> &  filter,
bool  recursive = false 
) const

Get all nets that have at least one source or one destination within the module. The filter is evaluated on every candidate such that the result only contains those matching the specified condition. If recursive is true, nets in submodules are considered as well.

Parameters
[in]filter- Filter function to be evaluated on each net.
[in]recursive- true to also consider nets in submodules, false otherwise.
Returns
An unordered set of nets.

Definition at line 508 of file module.cpp.

References test::n.

◆ get_output_nets()

const std::unordered_set< Net * > & hal::Module::get_output_nets ( ) const

Get all nets that are either a global output to the netlist or have at least one destination outside of the module.

Returns
An unordered set of output nets.

Definition at line 545 of file module.cpp.

Referenced by hal::SubgraphNetlistDecorator::copy_subgraph_netlist(), hal::ModuleTableModel::handleModulePortsChanged(), hal::module_init(), hal::SelectionRelay::navigateDown(), hal::SelectionRelay::navigateUp(), hal::TEST_F(), and hal::GraphContext::updateNets().

◆ get_output_pin_names()

std::vector< std::string > hal::Module::get_output_pin_names ( ) const

Get an ordered vector of the names of all output pins of the module (including inout pins).

Returns
An ordered vector of output pin names.

Definition at line 954 of file module.cpp.

References direction, hal::BasePin< T >::get_direction(), get_pin_names(), hal::inout, and hal::output.

Referenced by hal::module_init().

◆ get_output_pins()

std::vector< ModulePin * > hal::Module::get_output_pins ( ) const

Get an ordered vector of all output pins of the module (including inout pins).

Returns
An ordered vector of output pins.

Definition at line 946 of file module.cpp.

References direction, hal::BasePin< T >::get_direction(), get_pins(), hal::inout, and hal::output.

Referenced by hal::module_init().

◆ get_parent_module()

◆ get_parent_modules()

std::vector< Module * > hal::Module::get_parent_modules ( const std::function< bool(Module *)> &  filter = nullptr,
bool  recursive = true 
) const

Get all parents of this module.
If recursive is set to true, all indirect parents are also included.
The optional filter is evaluated on every candidate such that the result only contains those matching the specified condition.

Parameters
[in]filter- An optional filter.
[in]recursive- Set true to include indirect parents as well, false otherwise.
Returns
A vector of parent modules.

Definition at line 130 of file module.cpp.

References get_parent_modules().

Referenced by hal::Gate::get_modules(), get_parent_modules(), and hal::module_init().

◆ get_pin_by_id()

ModulePin * hal::Module::get_pin_by_id ( const u32  id) const

Get the pin corresponding to the given ID.

Parameters
[in]id- The ID of the pin.
Returns
The pin on success, a nullptr otherwise.

Definition at line 983 of file module.cpp.

References log_warning.

Referenced by hal::ActionPingroup::addPinsToNewGroup(), hal::ActionPingroup::exec(), hal::ModulePinsTreeModel::getNetFromItem(), hal::ModulePinsTreeModel::handleModulePortsChanged(), hal::module_init(), and hal::ActionPingroup::removePinsFromGroup().

◆ get_pin_by_name()

ModulePin * hal::Module::get_pin_by_name ( const std::string &  name) const

Get the pin corresponding to the given name.

Parameters
[in]name- The name of the pin.
Returns
The pin on success, a nullptr otherwise.

Definition at line 1000 of file module.cpp.

References log_warning, and name.

Referenced by hal::module_init().

◆ get_pin_by_net()

ModulePin * hal::Module::get_pin_by_net ( Net net) const

Get the pin that passes through the specified net.

Parameters
[in]net- The net.
Returns
The pin on success, a nullptr otherwise.

Definition at line 1017 of file module.cpp.

References log_debug, log_warning, and net.

Referenced by hal::module_init(), and hal::TEST_F().

◆ get_pin_group_by_id()

PinGroup< ModulePin > * hal::Module::get_pin_group_by_id ( const u32  id) const

Get the pin group corresponding to the given ID.

Parameters
[in]id- The ID of the pin group.
Returns
The pin group on success, a nullptr otherwise.

Definition at line 1034 of file module.cpp.

References log_warning.

Referenced by hal::ActionPingroup::deletePinGroup(), hal::ActionPingroup::exec(), hal::ModulePinsTree::handleContextMenuRequested(), hal::ModulePinsTreeModel::handleModulePortsChanged(), hal::module_init(), and operator==().

◆ get_pin_group_by_name()

PinGroup< ModulePin > * hal::Module::get_pin_group_by_name ( const std::string &  name) const

Get the pin group corresponding to the given name.

Parameters
[in]name- The name of the pin group.
Returns
The pin group on success, a nullptr otherwise.

Definition at line 1051 of file module.cpp.

References log_warning, and name.

Referenced by hal::module_init().

◆ get_pin_groups()

std::vector< PinGroup< ModulePin > * > hal::Module::get_pin_groups ( const std::function< bool(PinGroup< ModulePin > *)> &  filter = nullptr) const

Get all pin groups of the module. The optional filter is evaluated on every candidate such that the result only contains those matching the specified condition.

Parameters
[in]filter- An optional filter.
Returns
A vector of pin groups.

Definition at line 962 of file module.cpp.

Referenced by hal::ActionPingroup::deletePinGroup(), hal::dumpPingroups(), hal::generateGroupName(), hal::module_init(), operator==(), hal::pinGroupIndex(), hal::PingroupSelectorDialog::PingroupSelectorDialog(), hal::ActionPingroup::removePinsFromGroup(), and hal::ModulePinsTreeModel::setModule().

◆ get_pin_names()

std::vector< std::string > hal::Module::get_pin_names ( const std::function< bool(ModulePin *)> &  filter = nullptr) const

Get an ordered vector of the names of all pins of the module. The optional filter is evaluated on every candidate such that the result only contains those matching the specified condition.

Parameters
[in]filter- An optional filter.
Returns
An ordered vector of pin names.

Definition at line 899 of file module.cpp.

References pins.

Referenced by get_input_pin_names(), get_output_pin_names(), and hal::module_init().

◆ get_pins()

std::vector< ModulePin * > hal::Module::get_pins ( const std::function< bool(ModulePin *)> &  filter = nullptr) const

Get an ordered vector of all pins of the module. The optional filter is evaluated on every candidate such that the result only contains those matching the specified condition.

Parameters
[in]filter- An optional filter.
Returns
An ordered vector of pins.

Definition at line 871 of file module.cpp.

References pins.

Referenced by get_input_pins(), get_output_pins(), hal::GraphicsModule::GraphicsModule(), hal::module_init(), hal::ModulePinsTreeModel::setModule(), and hal::TEST_F().

◆ get_submodule_depth()

int hal::Module::get_submodule_depth ( ) const

Get the depth of the module within the module hierarchie (0 = top module, 1 = direct child of top module, ...).

Returns
The depth within the module hierarchie.

Definition at line 159 of file module.cpp.

References get_parent_module().

Referenced by hal::module_init().

◆ get_submodules()

std::vector< Module * > hal::Module::get_submodules ( const std::function< bool(Module *)> &  filter = nullptr,
bool  recursive = false 
) const

Get all direct submodules of this module.
If recursive is set to true, all indirect submodules are also included.
The optional filter is evaluated on every candidate such that the result only contains those matching the specified condition.

Parameters
[in]filter- An optional filter.
[in]recursive- Set true to include indirect submodules as well, false otherwise.
Returns
A vector of submodules.

Definition at line 259 of file module.cpp.

Referenced by hal::ModuleModel::addRecursively(), hal::ModuleItem::appendExistingChildIfAny(), hal::dumpPingroups(), hal::ActionDeleteObject::exec(), hal::ActionFoldModule::exec(), hal::ActionUnfoldModule::exec(), hal::GuiApiClasses::View::foldModule(), hal::GraphContext::getModuleChildrenRecursively(), hal::GraphContextManager::handleModuleGateRemoved(), hal::GraphContext::isModuleUnfolded(), hal::module_init(), operator==(), set_parent_module(), hal::TEST_F(), and hal::GraphContext::unfoldModule().

◆ get_type()

◆ get_unique_pin_group_id()

u32 hal::Module::get_unique_pin_group_id ( )

Get a spare pin group ID.
The value of 0 is reserved and represents an invalid ID.

Returns
The pin group ID.

Definition at line 774 of file module.cpp.

Referenced by create_pin(), create_pin_group(), hal::module_init(), and remove_pin_from_group().

◆ get_unique_pin_id()

u32 hal::Module::get_unique_pin_id ( )

Get a spare pin ID.
The value of 0 is reserved and represents an invalid ID.

Returns
The pin ID.

Definition at line 761 of file module.cpp.

Referenced by create_pin(), and hal::module_init().

◆ is_input_net()

bool hal::Module::is_input_net ( Net net) const

Check whether the given net is an input of the module, i.e., whether the net is a global input to the netlist or has at least one source outside of the module.

Parameters
[in]net- The net.
Returns
true if the net is an input net, false otherwise.

Definition at line 555 of file module.cpp.

References net.

Referenced by create_pin(), hal::module_init(), and hal::TEST_F().

◆ is_internal_net()

bool hal::Module::is_internal_net ( Net net) const

Check whether the given net is an internal net of the module, i.e. whether the net has at least one source and one destination within the module.

Parameters
[in]net- The net.
Returns
true if the net is an internal net, false otherwise.

Definition at line 575 of file module.cpp.

References net.

Referenced by hal::module_init().

◆ is_output_net()

bool hal::Module::is_output_net ( Net net) const

Check whether the given net is an output of the module, i.e., whether the net is a global output to the netlist or has at least one destination outside of the module.

Parameters
[in]net- The net.
Returns
true if the net is an ouput net, false otherwise.

Definition at line 565 of file module.cpp.

References net.

Referenced by create_pin(), hal::module_init(), and hal::TEST_F().

◆ is_parent_module_of()

bool hal::Module::is_parent_module_of ( const Module module,
bool  recursive = false 
) const

Check if the module is a parent of the specified module.

Parameters
[in]module- The module.
[in]recursive- Set true to check recursively, false otherwise.
Returns
true if the module is a parent of the specified module, false otherwise.

Definition at line 238 of file module.cpp.

References hal::ShortestPath::module().

Referenced by contains_module(), and hal::module_init().

◆ is_submodule_of()

bool hal::Module::is_submodule_of ( const Module module,
bool  recursive = false 
) const

Check if the module is a submodule of the specified module.

Parameters
[in]module- The module.
[in]recursive- Set true to check recursively, false otherwise.
Returns
true if the module is a submodule of the specified module, false otherwise.

Definition at line 289 of file module.cpp.

References is_submodule_of(), and hal::ShortestPath::module().

Referenced by is_submodule_of(), and hal::module_init().

◆ is_top_module()

bool hal::Module::is_top_module ( ) const

Returns true only if the module is the top module of the netlist.

Returns
true if the module is the top module, false otherwise.

Definition at line 312 of file module.cpp.

Referenced by hal::NetlistModificationDecorator::delete_modules(), hal::module_init(), hal::NetlistModificationDecorator::replace_gate(), hal::ModuleInfoTable::setModule(), and hal::TEST_F().

◆ move_pin_group()

bool hal::Module::move_pin_group ( PinGroup< ModulePin > *  pin_group,
u32  new_index 
)

Move a pin group to another index within the module. The indices of some other pin groups will be incremented or decremented to make room for the moved pin group to be inserted at the desired position.

Parameters
[in]pin_group- The pin group to be moved.
[in]new_index- The index to which the pin group is moved.
Returns
true on success, false message otherwise.

Definition at line 1360 of file module.cpp.

References hal::PinGroup< T >::get_id(), hal::PinGroup< T >::get_name(), hal::GroupReorder, log_warning, and hal::PinChangedEvent::send().

Referenced by hal::ActionPingroup::exec().

◆ move_pin_within_group()

bool hal::Module::move_pin_within_group ( PinGroup< ModulePin > *  pin_group,
ModulePin pin,
u32  new_index 
)

Move a pin to another index within the given pin group. The indices of some other pins within the group will be incremented or decremented to make room for the moved pin to be inserted at the desired position.

Parameters
[in]pin_group- The pin group.
[in]pin- The pin to be moved.
[in]new_index- The index to which the pin is moved.
Returns
true on success, false otherwise.

Definition at line 1506 of file module.cpp.

References hal::BasePin< T >::get_id(), hal::PinGroup< T >::get_id(), hal::BasePin< T >::get_name(), hal::PinGroup< T >::get_name(), log_warning, hal::PinGroup< T >::move_pin(), hal::PinReorder, and hal::PinChangedEvent::send().

Referenced by hal::ActionPingroup::exec().

◆ operator!=()

bool hal::Module::operator!= ( const Module other) const

Check whether two modules are unequal. Does not check for parent module.

Parameters
[in]other- The module to compare against.
Returns
True if both modules are unequal, false otherwise.

Definition at line 72 of file module.cpp.

References operator==().

◆ operator==()

bool hal::Module::operator== ( const Module other) const

Check whether two modules are equal. Does not check for parent module.

Parameters
[in]other- The module to compare against.
Returns
True if both modules are equal, false otherwise.

Definition at line 26 of file module.cpp.

References get_gates(), get_id(), get_name(), get_pin_group_by_id(), get_pin_groups(), get_submodules(), get_type(), and log_debug.

Referenced by operator!=().

◆ remove_gate()

bool hal::Module::remove_gate ( Gate gate)

Remove a gate from the module.
Automatically moves the gate to the top module of the netlist.

Parameters
[in]gate- The gate to remove.
Returns
true on success, false otherwise.

Definition at line 332 of file module.cpp.

References remove_gates().

Referenced by hal::module_init().

◆ remove_gates()

bool hal::Module::remove_gates ( const std::vector< Gate * > &  gates)

Remove a vector of gates from the module.
Automatically moves the gates to the top module of the netlist.

Parameters
[in]gates- The gates to remove.
Returns
true on success, false otherwise.

Definition at line 337 of file module.cpp.

References contains_gate(), and hal::Netlist::get_top_module().

Referenced by hal::module_init(), and remove_gate().

◆ remove_pin_from_group()

bool hal::Module::remove_pin_from_group ( PinGroup< ModulePin > *  pin_group,
ModulePin pin,
bool  delete_empty_groups = true 
)

Remove a pin from a pin group. The pin will be moved to a new group that goes by the pin's name.

Parameters
[in]pin_group- The old pin group.
[in]pin- The pin to be removed.
[in]delete_empty_groups- Set true to delete the group of it is empty after the pin has been removed, false to keep the empty group. Defaults to true.
Returns
true on success, false otherwise.

Definition at line 1563 of file module.cpp.

References create_pin_group(), hal::BasePin< T >::get_direction(), hal::BasePin< T >::get_id(), hal::PinGroup< T >::get_id(), hal::BasePin< T >::get_name(), hal::PinGroup< T >::get_name(), hal::BasePin< T >::get_type(), get_unique_pin_group_id(), and log_warning.

◆ set_name()

void hal::Module::set_name ( const std::string &  name)

Set the name of the module.

Parameters
[in]name- The new name.

Definition at line 92 of file module.cpp.

References log_warning, name, hal::ModuleEvent::name_changed, hal::EventHandler::notify(), and hal::utils::trim().

Referenced by hal::ActionRenameObject::exec(), and hal::module_init().

◆ set_parent_module()

bool hal::Module::set_parent_module ( Module new_parent)

Set a new parent for this module.
If the new parent is a submodule of this module, the new parent is added as a direct submodule to the old parent first.

Parameters
[in]new_parent- The new parent module.
Returns
true if the parent was changed, false otherwise.

Definition at line 168 of file module.cpp.

References get_id(), hal::Netlist::get_id(), get_name(), get_netlist(), get_nets(), get_submodules(), log_error, net, hal::EventHandler::notify(), hal::ModuleEvent::parent_changed, set_parent_module(), hal::ModuleEvent::submodule_added, and hal::ModuleEvent::submodule_removed.

Referenced by hal::ActionAddItemsToObject::exec(), hal::module_init(), and set_parent_module().

◆ set_pin_group_direction()

bool hal::Module::set_pin_group_direction ( PinGroup< ModulePin > *  pin_group,
PinDirection  new_direction 
)

Set the direction of the given pin group.

Parameters
[in]pin_group- The pin group.
[in]new_direction- The direction to be assigned to the pin group.
Returns
true on success, false otherwise.

Definition at line 1224 of file module.cpp.

References hal::PinGroup< T >::get_direction(), hal::PinGroup< T >::get_id(), hal::PinGroup< T >::get_name(), hal::GroupTypeChange, log_warning, hal::PinChangedEvent::send(), and hal::PinGroup< T >::set_direction().

Referenced by hal::ActionPingroup::exec(), and hal::module_init().

◆ set_pin_group_name()

bool hal::Module::set_pin_group_name ( PinGroup< ModulePin > *  pin_group,
const std::string &  new_name,
bool  force_name = false 
)

Set the name of the given pin group.

Parameters
[in]pin_group- The pin group.
[in]new_name- The name to be assigned to the pin group.
[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.

Definition at line 1145 of file module.cpp.

References hal::PinGroup< T >::get_id(), hal::PinGroup< T >::get_name(), hal::GroupRename, log_warning, hal::PinChangedEvent::send(), and hal::PinGroup< T >::set_name().

Referenced by hal::ActionPingroup::exec(), hal::module_init(), and hal::TEST_F().

◆ set_pin_group_type()

bool hal::Module::set_pin_group_type ( PinGroup< ModulePin > *  pin_group,
PinType  new_type 
)

Set the type of the given pin group.

Parameters
[in]pin_group- The pin group.
[in]new_type- The type to be assigned to the pin group.
Returns
true on success, false otherwise.

Definition at line 1201 of file module.cpp.

References hal::PinGroup< T >::get_id(), hal::PinGroup< T >::get_name(), hal::PinGroup< T >::get_type(), hal::GroupTypeChange, log_warning, hal::PinChangedEvent::send(), and hal::PinGroup< T >::set_type().

Referenced by hal::ActionPingroup::exec(), and hal::module_init().

◆ set_pin_name()

bool hal::Module::set_pin_name ( ModulePin pin,
const std::string &  new_name,
bool  force_name = false 
)

Set the name of the given pin.

Parameters
[in]pin- The pin.
[in]new_name- The name to be assigned to the pin.
[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.

Definition at line 1068 of file module.cpp.

References hal::BasePin< T >::get_id(), hal::BasePin< T >::get_name(), log_warning, hal::PinRename, hal::PinChangedEvent::send(), and hal::BasePin< T >::set_name().

Referenced by hal::ActionPingroup::exec(), hal::module_init(), and hal::TEST_F().

◆ set_pin_type()

bool hal::Module::set_pin_type ( ModulePin pin,
PinType  new_type 
)

Set the type of the given pin.

Parameters
[in]pin- The pin.
[in]new_type- The type to be assigned to the pin.
Returns
true on success, false otherwise.

Definition at line 1122 of file module.cpp.

References hal::BasePin< T >::get_id(), hal::BasePin< T >::get_name(), hal::BasePin< T >::get_type(), log_warning, hal::PinTypeChange, hal::PinChangedEvent::send(), and hal::BasePin< T >::set_type().

Referenced by hal::ActionPingroup::exec(), and hal::module_init().

◆ set_type()

void hal::Module::set_type ( const std::string &  type)

Set the type of the module.

Parameters
[in]type- The new type.

Definition at line 111 of file module.cpp.

References hal::EventHandler::notify(), type, and hal::ModuleEvent::type_changed.

Referenced by hal::ActionSetObjectType::exec(), hal::module_init(), hal::ModuleItem::setModuleType(), and hal::TEST_F().

◆ update_nets()

void hal::Module::update_nets ( )

Iterates over all nets connected to at least one gate of the module to update the nets, internal nets, input nets, and output nets of the module. Has no effect on module pins.

Warning
{WARNING: can only be used when automatic net checks have been disabled using Netlist::enable_automatic_net_checks.}

Definition at line 434 of file module.cpp.

References get_gates(), and net.

Referenced by hal::SubgraphNetlistDecorator::copy_subgraph_netlist(), and hal::module_init().

Friends And Related Function Documentation

◆ NetlistInternalManager

friend class NetlistInternalManager
friend

Definition at line 691 of file module.h.


The documentation for this class was generated from the following files: