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.

skidl.node.Group

alias of Node

class skidl.node.Node(name=None, tag=None, circuit=None, **attrs)[source]

Bases: PinMixin, 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.

erc_desc()[source]

Create description of SubCircuit for ERC and other error reporting.

Returns:

A string description in the form “name”

Return type:

str

finalize()[source]

Exit the creation of an instance of a subcircuit class and return to the parent Node in the hierarchy.

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:

tuple

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:

tuple

initialize(*args, **kwargs)[source]

Initialize an instance of a subcircuit class and place it as a child of the currently active Node.

This method creates a Node object without calling its __init__ method, allowing for custom initialization or deserialization scenarios.

Parameters:
  • *args – Positional arguments to pass to the Node __init__ function.

  • **kwargs – Keyword arguments to pass to the Node __init__ function.

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:

Node

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:

str

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:

tuple

skidl.node.SubCircuit

alias of Node

skidl.node.subcircuit

alias of Node