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:
objectRepresents 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)#
- class Condition(channel_measurement, level)[source]#
Bases:
objectRepresents a condition for a truth table entry, combining a channel measurement with a level.
- Parameters:
channel_measurement (ChannelMeasurement) – The channel measurement.
level (str) – The level (must be one of
LEVEL_OPTIONS).
- __init__(channel_measurement, level)#
-
channel_measurement:
ChannelMeasurement#
- class TruthTable(default_trigger_address=0, overwrite_conflict=False)[source]#
Bases:
objectTruth table manager class.
- __init__(default_trigger_address=0, overwrite_conflict=False)[source]#
Initialize the TruthTable.
- Parameters:
- 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:
- 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:
- classmethod from_config(entries, default_trigger_address=0, overwrite_conflict=False)[source]#
Builds a TruthTable from a list of dictionaries.
- Parameters:
- Return type:
- Returns:
TruthTable The constructed truth table.
Notes
Each dictionary is expected to have the format:
{ "conditions": [ {"channel": int, "measurement": str, "level": str}, ... ], "trigger": int }