skidl.node module¶
Node class for storing circuit hierarchy.
This module provides the Node class which represents a hierarchical structure for organizing circuit components. Nodes can have parent-child relationships and contain parts, allowing for structured circuit design and organization.
- class skidl.node.Node(name=None, tag=None, circuit=None, **attrs)[source]¶
Bases:
SkidlBaseObject
Data structure for holding information about a node in the circuit hierarchy.
A Node represents a hierarchical container that can hold circuit parts and maintain parent-child relationships with other nodes. This enables organized circuit design with clear structural relationships.
- add_child(child)[source]¶
Add a child node to this node.
Establishes a parent-child relationship between this node and the provided child node. Ensures the child has a unique name among siblings.
- Parameters:
child (Node) – The child node to add to this node.
- property hiernodes¶
Return a tuple of the chain of nodes from the top-most node to this one (self).
This property traverses up the hierarchy from the current node to the root, then reverses the order to provide a path from root to current node.
- Returns:
- A tuple of Node objects representing the hierarchical path
from the root node to this node, inclusive.
- Return type:
- property hiertuple¶
Return a tuple of the node’s hierarchy path names from top-most node to this one (self).
This provides a string representation of the hierarchical path by extracting the names from each node in the hierarchy chain.
- Returns:
- A tuple of strings representing the names of nodes in the
hierarchical path from root to this node.
- Return type:
- property netclasses¶
Return a list of net classes assigned to this node and its ancestors.
Aggregates net classes from this node and all ancestor nodes in the hierarchy.
- Returns:
Combined net classes from this node and its ancestors.
- Return type:
NetClasses
- property partclasses¶
Return a list of part classes assigned to this node and its ancestors.
Aggregates part classes from this node and all ancestor nodes in the hierarchy.
- Returns:
Combined part classes from this node and its ancestors.
- Return type:
PartClasses
- spin_off(**kwargs)[source]¶
Create a new node for the purpose of spinning off a subcircuit.
Creates a copy of this node with potentially modified attributes, typically used when creating instances of a node template.
- Parameters:
**kwargs – Keyword arguments to override node attributes.
- Returns:
A new Node instance based on this node.
- Return type:
- property tag_or_name¶
Return the tag of the node if it exists, otherwise return the name.
This property provides a way to access the node’s identifier, preferring the tag over the name if both are present.
- Returns:
The tag or name of the node.
- Return type:
- to_tuple()[source]¶
Convert the node and its children to a tuple representation.
Creates a nested tuple structure representing this node and all its children, including their names, tags, parts, and hierarchical structure.
- Returns:
A tuple containing (name, tag, parts_refs, children_tuples).
- Return type: