Skip to content

netlist_carpentry.core.enums.direction

Enum for the direction of a port in a digital circuit (input, output, inout, unknown).

Classes:

  • Direction

    Enum for the direction of a port (or a directed element in general) in a digital circuit.

Direction

Bases: Enum

Enum for the direction of a port (or a directed element in general) in a digital circuit.

A port is a connection point in a circuit that can be connected to another element within the circuit. The direction of a port refers to the direction of data flow between the two connected elements.

The direction of a port can be either input, output, or both input and output (inout).

Methods:

  • get

    Retrieves a Direction enum member by its string value.

Attributes:

  • IN

    This port direction refers to an input port.

  • OUT

    This port direction refers to an output port.

  • IN_OUT

    This port direction refers to a port that can be used as both an input and an output port.

  • UNKNOWN

    This port direction refers to a port that has an unknown direction or unset.

  • is_input (bool) –

    Returns True if this port direction is input or inout.

  • is_output (bool) –

    Returns True if this port direction is output or inout.

  • is_defined (bool) –

    Returns True if this port direction is input, output or inout; and False if it is unknown or no direction is specified.

IN class-attribute instance-attribute

IN = 'input'

This port direction refers to an input port.

OUT class-attribute instance-attribute

OUT = 'output'

This port direction refers to an output port.

IN_OUT class-attribute instance-attribute

IN_OUT = 'inout'

This port direction refers to a port that can be used as both an input and an output port.

UNKNOWN class-attribute instance-attribute

UNKNOWN = 'unknown'

This port direction refers to a port that has an unknown direction or unset.

is_input property

is_input: bool

Returns True if this port direction is input or inout.

is_output property

is_output: bool

Returns True if this port direction is output or inout.

is_defined property

is_defined: bool

Returns True if this port direction is input, output or inout; and False if it is unknown or no direction is specified.

get classmethod

get(value: str) -> Direction

Retrieves a Direction enum member by its string value.

If the provided string does not match any existing Direction values, it returns the UNKNOWN Direction instead of raising an exception.

Parameters:

  • value

    (str) –

    The string value to look up in the Direction enum.

Returns:

  • Direction ( Direction ) –

    The corresponding Direction enum member, or UNKNOWN if no match is found.

Example
>>> Direction.get('input')
<Direction.IN: 'input'>
>>> Direction.get('invalid_value')
<Direction.UNKNOWN: 'unknown'>