Truth Table API#

LEVEL_OPTIONS = ('low', 'mid', 'high', 'invalid')#

Built-in immutable sequence.

If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.

If the argument is a tuple, the return value is the same object.

MEASUREMENT_OPTIONS = ('count', 'digital')#

Built-in immutable sequence.

If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.

If the argument is a tuple, the return value is the same object.

class ChannelMeasurement(channel, measurement)[source]#

Bases: object

Represents a measurement on a specific channel.

Parameters:
  • channel (int) – The channel number (must be in 0…7).

  • measurement (str) – The measurement type (must be one of MEASUREMENT_OPTIONS).

__init__(channel, measurement)#
channel: int#
measurement: str#
class Condition(channel_measurement, level)[source]#

Bases: object

Represents a condition for a truth table entry, combining a channel measurement with a level.

Parameters:
__init__(channel_measurement, level)#
channel_measurement: ChannelMeasurement#
level: str#
class TruthTable(default_trigger_address=0, overwrite_conflict=False)[source]#

Bases: object

Truth table manager class.

MAX_INPUTS#

Maximum number of distinct input channels allowed.

Type:

int

MAX_TRIGGER_ADDRESSES#

Maximum number of distinct trigger addresses allowed.

Type:

int

__init__(default_trigger_address=0, overwrite_conflict=False)[source]#

Initialize the TruthTable.

Parameters:
  • default_trigger_address (int, optional) – The default trigger address. Must be in range 0…15.

  • overwrite_conflict (bool, optional) – Whether to overwrite existing LUT entries on conflict.

Raises:

ValueError – If the default trigger address is not in range 0…15.

add_conditions(conditions, trigger_address)[source]#

Adds a set of conditions with an associated trigger address to the truth table.

Parameters:
  • conditions (list[Condition]) – List of conditions to add.

  • trigger_address (int) – Trigger address to associate with these conditions. Must be in range 1…15.

Raises:

ValueError – If trigger_address is not in range 1…15. If number of distinct inputs exceeds MAX_INPUTS. If adding the trigger_address would exceed MAX_TRIGGER_ADDRESSES. If a conflict is detected in the LUT and overwriting is disabled.

Return type:

None

classmethod from_config(entries, default_trigger_address=0, overwrite_conflict=False)[source]#

Builds a TruthTable from a list of dictionaries.

Parameters:
  • entries (list of dict) – List of configuration dictionary entries.

  • default_trigger_address (int, optional) – Default trigger address.

  • overwrite_conflict (bool, optional) – Whether to overwrite conflicts in the LUT.

Return type:

TruthTable

Returns:

TruthTable The constructed truth table.

Notes

Each dictionary is expected to have the format:

{
    "conditions": [
        {"channel": int, "measurement": str, "level": str},
        ...
    ],
    "trigger": int
}
property lut: dict[str, Any]#

Returns the lookup table (LUT).

Returns:

dict A dictionary with keys: src and lut,

src - list of input configurations, lut - list of trigger addresses.

class TruthTableEntry(conditions, trigger_address)[source]#

Bases: object

Represents an entry in the truth table.

Parameters:
  • conditions (list[Condition]) – List of conditions that must be met.

  • trigger_address (int) – The trigger address associated with these conditions.

__init__(conditions, trigger_address)#
conditions: list[Condition]#
trigger_address: int#