Module
- class hal_py.Module
Bases:
hal_py.DataContainer
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.
- assign_gate(self: hal_py.Module, gate: hal_py.Gate) bool
Assign a gate to the module. The gate is removed from its previous module in the process.
- Parameters
gate (hal_py.Gate) – The gate to assign.
- Returns
True
on success,False
otherwise.- Return type
- assign_gates(self: hal_py.Module, gates: List[hal_py.Gate]) bool
Assign a list of gates to the module. The gates are removed from their previous module in the process.
- Parameters
gates (list[hal_py.Gate]) – The gates to assign.
- Returns
True
on success,False
otherwise.- Return type
- assign_pin_to_group(self: hal_py.Module, pin_group: hal_py.ModulePinGroup, pin: hal_py.ModulePin, delete_empty_groups: bool = True) bool
Assign a pin to a pin group.
- Parameters
pin_group (hal_py.ModulePinGroup) – The new pin group.
pin (hal_py.ModulePin) – The pin to be added.
delete_empty_groups (bool) – Set
True
to delete groups that are empty after the pin has been assigned to the new group,False
to keep empty groups. Defaults toTrue
.
- Returns
True
on success,False
otherwise.- Return type
- contains_gate(self: hal_py.Module, gate: hal_py.Gate, recursive: bool = False) bool
Check whether a gate is contained in the module. If
recursive
isTrue
, gates in submodules are considered as well.- Parameters
gate (hal_py.Gate) – The gate to check for.
recursive (bool) –
True
to also consider gates in submodules,False
otherwise.
- Returns
True
if the gate is contained in the module,False
otherwise.- Return type
- contains_module(self: hal_py.Module, other: hal_py.Module, recusive: bool = False) bool
Checks whether another module is a submodule of this module. If recursive is set to
True
, all indirect submodules are also included.- Parameters
other (hal_py.Module) – Other module to check for.
recursive (bool) – Set
True
to include indirect submodules as well,False
otherwise.
- Returns
True
if the other module is a submodule,False
otherwise.- Return type
- contains_net(self: hal_py.Module, net: hal_py.Net, recursive: bool = False) bool
Check whether a net is contained in the module. If
recursive
is set toTrue
, nets in submodules are considered as well.- Parameters
net (hal_py.Net) – The net to check for.
recursive (bool) –
True
to also consider nets in submodules,False
otherwise.
- Returns
True
if the net is contained in the module,False
otherwise.- Return type
- create_pin(*args, **kwargs)
Overloaded function.
create_pin(self: hal_py.Module, id: int, name: str, net: hal_py.Net, type: hal_py.PinType = <PinType.none: 0>, create_group: bool = True, force_name: bool = False) -> hal_py.ModulePin
Manually assign a module pin 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
hal_py.Module.update_net
. Ifcreate_group
is set toFalse
, the pin will not be added to a pin group.WARNING: can only be used when automatic net checks have been disabled using
hal_py.Netlist.enable_automatic_net_checks
.- param int id
The ID of the pin.
- param str name
The name of the pin.
- param hal_py.Net net
The net that the pin is being assigned to.
- param hal_py.PinType type
The type of the pin. Defaults to
hal_py.PinType.none
.- param bool create_group
Set
True
to automatically create a pin group and assign the pin,False
otherwise. Defaults toTrue
.- param bool 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 toFalse
.- returns
The module pin on success,
None
otherwise.- rtype
hal_py.ModulePin or None
create_pin(self: hal_py.Module, name: str, net: hal_py.Net, type: hal_py.PinType = <PinType.none: 0>, create_group: bool = True, force_name: bool = False) -> hal_py.ModulePin
Manually assign a module pin 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
hal_py.Module.update_net
. Ifcreate_group
is set toFalse
, the pin will not be added to a pin group.WARNING: can only be used when automatic net checks have been disabled using
hal_py.Netlist.enable_automatic_net_checks
.- param str name
The name of the pin.
- param hal_py.Net net
The net that the pin is being assigned to.
- param hal_py.PinType type
The type of the pin. Defaults to
hal_py.PinType.none
.- param bool create_group
Set
True
to automatically create a pin group and assign the pin,False
otherwise. Defaults toTrue
.- param bool 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 toFalse
.- returns
The module pin on success,
None
otherwise.- rtype
hal_py.ModulePin or None
- create_pin_group(*args, **kwargs)
Overloaded function.
create_pin_group(self: hal_py.Module, id: int, name: str, pins: List[hal_py.ModulePin], direction: hal_py.PinDirection = <PinDirection.none: 0>, type: hal_py.PinType = <PinType.none: 0>, ascending: bool = True, start_index: int = 0, delete_empty_groups: bool = True, force_name: bool = False) -> hal_py.ModulePinGroup
Create a new pin group with the given name. All pins to be added to the pin group must have the same direction and type.
- param int id
The ID of the pin group.
- param str name
The name of the pin group.
- param list[hal_py.ModulePin] pins
The pins to be assigned to the pin group. Defaults to an empty list.
- param hal_py.PinDirection direction
The direction of the pin group, if any. Defaults to
hal_py.PinDirection.none
.- param hal_py.PinType type
The type of the pin group, if any. Defaults to
hal_py.PinType.none
.- param bool ascending
Set
True
for ascending pin order (from 0 to n-1),False
otherwise (from n-1 to 0). Defaults toTrue
.- param int start_index
The start index of the pin group. Defaults to
0
.- param bool 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 toTrue
.- param bool 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 toFalse
.- returns
The pin group on success,
None
otherwise.- rtype
hal_py.ModulePinGroup or None
create_pin_group(self: hal_py.Module, name: str, pins: List[hal_py.ModulePin], direction: hal_py.PinDirection = <PinDirection.none: 0>, type: hal_py.PinType = <PinType.none: 0>, ascending: bool = True, start_index: int = 0, delete_empty_groups: bool = True, force_name: bool = False) -> hal_py.ModulePinGroup
Create a new pin group with the given name. All pins to be added to the pin group must have the same direction and type.
- param str name
The name of the pin group.
- param list[hal_py.ModulePin] pins
The pins to be assigned to the pin group. Defaults to an empty list.
- param hal_py.PinDirection direction
The direction of the pin group, if any. Defaults to
hal_py.PinDirection.none
.- param hal_py.PinType type
The type of the pin group, if any. Defaults to
hal_py.PinType.none
.- param bool ascending
Set
True
for ascending pin order (from 0 to n-1),False
otherwise (from n-1 to 0). Defaults toTrue
.- param int start_index
The start index of the pin group. Defaults to
0
.- param bool 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 toTrue
.- param bool 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 toFalse
.- returns
The pin group on success,
None
otherwise.- rtype
hal_py.ModulePinGroup or None
- property data
A dict from ((1) category, (2) key) to ((1) type, (2) value) containing all stored data entries.
- delete_data(self: hal_py.DataContainer, category: str, key: str, log_with_info_level: bool = False) bool
Delete a data entry.
- delete_pin_group(self: hal_py.Module, pin_group: hal_py.ModulePinGroup) bool
Delete the given pin group.
- Parameters
pin_group (hal_py.ModulePinGroup) – The pin group to be deleted.
- Returns
True
on success,False
otherwise.- Return type
- property gates
The list of all gates contained within the module.
- Type
- get_data(self: hal_py.DataContainer, category: str, key: str) Tuple[str, str]
Get the data entry specified by the given category and key.
- get_data_map(self: hal_py.DataContainer) Dict[Tuple[str, str], Tuple[str, str]]
Get a dict from ((1) category, (2) key) to ((1) type, (2) value) containing all stored data entries.
- get_gate_by_id(self: hal_py.Module, id: int, recursive: bool = False) hal_py.Gate
Get a gate specified by the given ID. If
recursive
isTrue
, gates in submodules are considered as well.- Parameters
- Returns
The gate if found, None otherwise.
- Return type
hal_py.Gate or None
- get_gates(*args, **kwargs)
Overloaded function.
get_gates(self: hal_py.Module) -> List[hal_py.Gate]
Get all gates contained within the module.
- returns
A list of gates.
- rtype
list[hal_py.Gate]
get_gates(self: hal_py.Module, filter: Callable[[hal_py.Gate], bool] = None, recursive: bool = False) -> List[hal_py.Gate]
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
isTrue
, gates in submodules are considered as well.- param lambda filter
Filter function to be evaluated on each gate.
- param bool recursive
True
to also consider gates in submodules,False
otherwise. Defaults toFalse
.- returns
A list of gates.
- rtype
list[hal_py.Gate]
- get_grouping(self: hal_py.Module) hal::Grouping
Get the grouping in which this module is contained.
- Returns
The grouping.
- Return type
- get_id(self: hal_py.Module) int
Get the unique ID of the module.
- Returns
The unique id.
- Return type
- get_input_nets(self: hal_py.Module) Set[hal_py.Net]
Get all nets that are either a global input to the netlist or have at least one source outside of the module.
- Returns
A set of input nets.
- Return type
- get_input_pin_names(self: hal_py.Module) List[str]
Get an ordered list of the names of all input pins of the module (including inout pins).
- get_input_pins(self: hal_py.Module) List[hal_py.ModulePin]
Get an ordered list of all input pins of the module (including inout pins).
- Returns
An ordered list of input pins.
- Return type
- get_internal_nets(self: hal_py.Module) Set[hal_py.Net]
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
A set of internal nets.
- Return type
- get_name(self: hal_py.Module) str
Get the name of the module.
- Returns
The name.
- Return type
- get_netlist(self: hal_py.Module) hal_py.Netlist
Get the netlist this module is associated with.
- Returns
The netlist.
- Return type
- get_nets(*args, **kwargs)
Overloaded function.
get_nets(self: hal_py.Module) -> Set[hal_py.Net]
Get all nets that have at least one source or one destination within the module.
- returns
An unordered set of nets.
- rtype
set[hal_py.Net]
get_nets(self: hal_py.Module, filter: Callable[[hal_py.Net], bool], recursive: bool = False) -> Set[hal_py.Net]
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
isTrue
, nets in submodules are considered as well.- param lambda filter
Filter function to be evaluated on each net.
- param bool recursive
True
to also consider nets in submodules,False
otherwise.- returns
An unordered set of nets.
- rtype
set[hal_py.Net]
- get_output_nets(self: hal_py.Module) Set[hal_py.Net]
Get all nets that are either a global output to the netlist or have at least one destination outside of the module.
- Returns
A set of output nets.
- Return type
- get_output_pin_names(self: hal_py.Module) List[str]
Get an ordered list of the names of all output pins of the module (including inout pins).
- get_output_pins(self: hal_py.Module) List[hal_py.ModulePin]
Get an ordered list of all output pins of the module (including inout pins).
- Returns
An ordered list of output pins.
- Return type
- get_parent_module(self: hal_py.Module) hal_py.Module
Get the parent module of this module. For the top module, None is returned.
- Returns
The parent module.
- Return type
- get_parent_modules(self: hal_py.Module, filter: Callable[[hal_py.Module], bool] = None, recursive: bool = True) List[hal_py.Module]
Get all parents of this module. If
recursive
is set toTrue
, 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
filter (lambda) – An optional filter.
recursive (bool) – Set
True
to include indirect parents as well,False
otherwise.
- Returns
A list of parent modules.
- Return type
- get_pin_by_id(self: hal_py.Module, id: int) hal_py.ModulePin
Get the pin corresponding to the given ID.
- Parameters
id (int) – The ID of the pin.
- Returns
The pin on success,
None
otherwise.- Return type
- get_pin_by_name(self: hal_py.Module, name: str) hal_py.ModulePin
Get the pin corresponding to the given name.
- Parameters
name (str) – The name of the pin.
- Returns
The pin on success,
None
otherwise.- Return type
- get_pin_by_net(self: hal_py.Module, net: hal_py.Net) hal_py.ModulePin
Get the pin that passes through the specified net.
- Parameters
net (hal_py.Net) – The net.
- Returns
The pin on success,
None
otherwise.- Return type
- get_pin_group_by_id(self: hal_py.Module, id: int) hal_py.ModulePinGroup
Get the pin group corresponding to the given ID.
- Parameters
id (int) – The ID of the pin group.
- Returns
The pin group on success,
None
otherwise.- Return type
- get_pin_group_by_name(self: hal_py.Module, name: str) hal_py.ModulePinGroup
Get the pin group corresponding to the given name.
- Parameters
name (str) – The name of the pin group.
- Returns
The pin group on success,
None
otherwise.- Return type
- get_pin_groups(self: hal_py.Module, filter: Callable[[hal_py.ModulePinGroup], bool] = None) List[hal_py.ModulePinGroup]
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
filter (lambda) – An optional filter.
- Returns
A list of pin groups.
- Return type
- get_pin_names(self: hal_py.Module, filter: Callable[[hal_py.ModulePin], bool] = None) List[str]
Get an ordered list 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.
- get_pins(self: hal_py.Module, filter: Callable[[hal_py.ModulePin], bool] = None) List[hal_py.ModulePin]
Get the (ordered) pins of the module. The optional filter is evaluated on every candidate such that the result only contains those matching the specified condition.
- Parameters
filter (lambda) – An optional filter.
- Returns
A list of pins.
- Return type
- get_submodule_depth(self: hal_py.Module) int
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.
- Return type
- get_submodules(self: hal_py.Module, filter: Callable[[hal_py.Module], bool] = None, recursive: bool = False) List[hal_py.Module]
Get all direct submodules of this module. If
recursive
is set toTrue
, 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
filter (lambda) – An optional filter.
recursive (bool) – Set
True
to include indirect submodules as well,False
otherwise.
- Returns
A list of submodules.
- Return type
- get_type(self: hal_py.Module) str
Get the type of the module.
- Returns
The type.
- Return type
- get_unique_pin_group_id(self: hal_py.Module) int
Get a spare pin group ID. The value of 0 is reserved and represents an invalid ID.
- Returns
The pin group ID.
- Return type
- get_unique_pin_id(self: hal_py.Module) int
Get a spare pin ID. The value of 0 is reserved and represents an invalid ID.
- Returns
The pin ID.
- Return type
- has_data(self: hal_py.DataContainer, category: str, key: str) bool
Determine whether an entry of given category and key exists.
- property input_nets
A set of all nets that are either a global input to the netlist or have at least one source outside of the module.
- Type
- property input_pin_names
An ordered list of the names of all input pins of the module (including inout pins).
- property input_pins
An ordered list of all input pins of the module (including inout pins).
- Type
- property internal_nets
A set of 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.
- Type
- is_input_net(self: hal_py.Module, net: hal_py.Net) bool
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
net (hal_py.Net) – The net.
- Returns
True
if the net is an input net,False
otherwise.- Return type
- is_internal_net(self: hal_py.Module, net: hal_py.Net) bool
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
net (hal_py.Net) – The net.
- Returns
True
if the net is an internal net,False
otherwise.- Return type
- is_output_net(self: hal_py.Module, net: hal_py.Net) bool
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
net (hal_py.Net) – The net.
- Returns
True
if the net is an output net,False
otherwise.- Return type
- is_parent_module_of(self: hal_py.Module, module: hal_py.Module, recursive: bool = False) bool
Check if the module is a parent of the specified module.
- Parameters
module (hal_py.Module) – The module.
recursive (bool) – Set
True
to check recursively,False
otherwise.
- Returns
True
if the module is a parent of the specified module,False
otherwise.- Return type
- is_submodule_of(self: hal_py.Module, module: hal_py.Module, recursive: bool = False) bool
Check if the module is a submodule of the specified module.
- Parameters
module (hal_py.Module) – The module.
recursive (bool) – Set
True
to check recursively,False
otherwise.
- Returns
True
if the module is a submodule of the specified module,False
otherwise.
- is_top_module(self: hal_py.Module) bool
Returns true only if the module is the top module of the netlist.
- Returns
True
if the module is the top module,False
otherwise.- Return type
- move_pin_group(self: hal_py.Module, pin_group: hal_py.ModulePinGroup, new_index: int) bool
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
pin_group (hal_py.ModulePinGroup) – The pin group to be moved.
new_index (int) – The index to which the pin group is moved.
- Returns
True
on success,False
otherwise.- Return type
- move_pin_within_group(self: hal_py.Module, pin_group: hal_py.ModulePinGroup, pin: hal_py.ModulePin, new_index: int) bool
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
pin_group (hal_py.ModulePinGroup) – The pin group.
pin (hal_py.ModulePin) – The pin to be moved.
new_index (int) – The index to which the pin is moved.
- Returns
True
on success,False
otherwise.- Return type
- property netlist
The netlist this module is associated with.
- Type
- property nets
An unordered set of all nets that have at least one source or one destination within the module.
- Type
- property output_nets
A set of all nets that are either a global output to the netlist or have at least one destination outside of the module.
- Type
- property output_pin_names
An ordered list of the names of all output pins of the module (including inout pins).
- property output_pins
An ordered list of all output pins of the module (including inout pins).
- Type
- property parent_module
The parent module of this module. Is set to None for the top module, but cannot be set to None by the user.
- Type
- property parent_modules
The parent modules of this module.
- Type
- property pin_groups
All pin_groups of the module.
- Type
- property pins
The (ordered) pins of the module.
- Type
- remove_gate(self: hal_py.Module, gate: hal_py.Gate) bool
Remove a gate from the module. Automatically moves the gate to the top module of the netlist.
- Parameters
gate (hal_py.Gate) – The gate to remove.
- Returns
True
on success,False
otherwise.- Return type
- remove_gates(self: hal_py.Module, gates: List[hal_py.Gate]) bool
Remove a list of gates from the module. Automatically moves the gates to the top module of the netlist.
- Parameters
gates (list[hal_py.Gate]) – The gates to remove.
- Returns
True
on success,False
otherwise.- Return type
- remove_pin_from_group(self: hal_py.Module, pin_group: hal_py.ModulePinGroup, pin: hal_py.ModulePin, delete_empty_groups: bool = True) bool
Remove a pin from a pin group. The pin will be moved to a new group that goes by the pin’s name.
- Parameters
pin_group (hal_py.ModulePinGroup) – The old pin group.
pin (hal_py.ModulePin) – The pin to be removed.
delete_empty_groups (bool) – Set
True
to delete the group of it is empty after the pin has been removed,False
to keep the empty group. Defaults toTrue
.
- Returns
True
on success,False
otherwise.- Return type
- set_data(self: hal_py.DataContainer, category: str, key: str, data_type: str, value: str, log_with_info_level: bool = False) bool
Add a data entry.<br> May overwrite an existing entry.
- Parameters
- Returns
True on success, false otherwise.
- Return type
- set_name(self: hal_py.Module, name: str) None
Set the name of the module.
- Parameters
name (str) – The new name.
- set_parent_module(self: hal_py.Module, new_parent: hal_py.Module) bool
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
new_parent (hal_py.Module) – The new parent module.
- Returns
True
if the parent was changed,False
otherwise.- Return type
- set_pin_group_direction(self: hal_py.Module, pin_group: hal_py.ModulePinGroup, new_direction: hal_py.PinDirection) bool
Set the direction of the given pin group.
- Parameters
pin_group (hal_py.ModulePinGroup) – The pin group.
new_direction (hal_py.PinDirection) – The direction to be assigned to the pin group.
- Returns
True
on success,False
otherwise.- Return type
- set_pin_group_name(self: hal_py.Module, pin_group: hal_py.ModulePinGroup, new_name: str, force_name: bool = False) bool
Set the name of the given pin group.
- Parameters
pin_group (hal_py.ModulePinGroup) – The pin group.
new_name (str) – The name to be assigned to the pin group.
force_name (bool) – 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 toFalse
.
- Returns
True
on success,False
otherwise.- Return type
- set_pin_group_type(self: hal_py.Module, pin_group: hal_py.ModulePinGroup, new_type: hal_py.PinType) bool
Set the type of the given pin group.
- Parameters
pin_group (hal_py.ModulePinGroup) – The pin group.
new_type (hal_py.PinType) – The type to be assigned to the pin group.
- Returns
True
on success,False
otherwise.- Return type
- set_pin_name(self: hal_py.Module, pin: hal_py.ModulePin, new_name: str, force_name: bool = False) bool
Set the name of the given pin.
- Parameters
pin (hal_py.ModulePin) – The pin.
new_name (str) – The name to be assigned to the pin.
force_name (bool) – Set
True
to enforce the name,False
otherwise. If a pin with the same name already exists, the existing pin will be renamed. Defaults toFalse
.
- Returns
True
on success,False
otherwise.- Return type
- set_pin_type(self: hal_py.Module, pin: hal_py.ModulePin, new_type: hal_py.PinType) bool
Set the type of the given pin.
- Parameters
pin (hal_py.ModulePin) – The pin.
new_type (hal_py.PinType) – The type to be assigned to the pin.
- Returns
True
on success,False
otherwise.- Return type
- set_type(self: hal_py.Module, type: str) None
Set the type of the module.
- Parameters
type (str) – The new type.
- property submodule_depth
The depth of the module within the module hierarchie (0 = top module, 1 = direct child of top module, …).
- Type
- property submodules
A list of all direct submodules of this module.
- Type
- update_nets(self: hal_py.Module) None
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: can only be used when automatic net checks have been disabled using hal_py.Netlist.enable_automatic_net_checks.
- Returns
True
on success,False
otherwise.- Return type