netlist_carpentry.core.graph.module_graph
¶
Wrapper module for networkx.MultiDiGraph, with customizations specifically for using the MultiDiGraph class for module graphs in digital circuits.
Classes:
ModuleGraph
¶
Bases: BaseGraph
Methods:
-
node_type–Returns the node type of the given node.
-
node_subtype–The node type specification (subtype) of the given node.
-
all_edges–Returns a set of all edges (both incoming and outgoing) connected to the given node in the graph.
node_type
¶
node_type(node_name: str) -> NODE_TYPES
Returns the node type of the given node.
The node type is the EType name of the element modeled by the node.
In this context, a node represents either an instance or a module port.
Thus, the node_type is either INSTANCE or PORT.
Returns:
-
NODE_TYPES–Literal['INSTANCE', 'PORT']: Whether this node is an instance (
INSTANCE) or a module port (PORT).
node_subtype
¶
The node type specification (subtype) of the given node.
In the graph context, the node type is either "PORT" or "INSTANCE"
(depending on what the node models).
In contrast, the subtype further specifies the role of the node.
For ports, the subtype is the port direction, i.e. input, output or inout.
For instances, the subtype is the instance type, e.g. for a node modeling an AND gate,
this method returns §and, and for a submodule node, this method returns the name of
the instantiated module (NOT the instance name).
Parameters:
Returns:
-
str(str) –The subtype (port direction for module ports, instance type for instances) of the given node.
all_edges
¶
Returns a set of all edges (both incoming and outgoing) connected to the given node in the graph.
Each tuple in the returned set follows the structure (edge_start, edge_end, edge_key). Accordingly,
for all incoming edges, edge_end is node_name and for all outgoing edges, edge_start is node_name.
The edge_key determines the ports over which both nodes are connected. The edge_key follows the structure
{port_name_edge_start}§{port_name_edge_end}. The section sign (§) is used to divide between both ports.
This character depends on the config entry CFG.nc_identifier_internal.
Parameters:
Returns: