def build_fsm_spec_4_state(direction_logic_value):
    'Build an FSM spec with 4 states.\n\n    The FSM built has 2 inputs, 1 output, and 4 states. It acts like a \n    2-bit counter, where the output goes to high only if the FSM is in the \n    final state.\n\n    When the direction pin is low, the counter counts up; if it is high, the\n    counter counts down.\n\n    Parameters\n    ----------\n    direction_logic_value : int\n        The logic value of the direction pin.\n    Returns\n    -------\n    dict\n        The FSM spec that can be consumed by the FSM generator.\n    list\n        The output pattern corresponding to the direction value.\n    list\n        The state bit0 pattern corresponding to the direction value.\n    list\n        The state bit1 pattern corresponding to the direction value.\n\n    '
    (out, rst, direction) = list(pin_dict.keys())[0:3]
    fsm_spec_4_state = {'inputs': [('rst', rst), ('direction', direction)], 'outputs': [('test', out)], 'states': ['S0', 'S1', 'S2', 'S3'], 'transitions': [['00', 'S0', 'S1', '0'], ['01', 'S0', 'S3', '0'], ['00', 'S1', 'S2', '0'], ['01', 'S1', 'S0', '0'], ['00', 'S2', 'S3', '0'], ['01', 'S2', 'S1', '0'], ['00', 'S3', 'S0', '1'], ['01', 'S3', 'S2', '1'], ['1-', '*', 'S0', '']]}
    if (not direction_logic_value):
        output_pattern = [0, 0, 0, 1]
        state_bit0_pattern = [0, 1, 0, 1]
        state_bit1_pattern = [0, 0, 1, 1]
    else:
        output_pattern = [0, 1, 0, 0]
        state_bit0_pattern = [0, 1, 0, 1]
        state_bit1_pattern = [0, 1, 1, 0]
    return (fsm_spec_4_state, output_pattern, state_bit0_pattern, state_bit1_pattern)
Build an FSM spec with 4 states.

The FSM built has 2 inputs, 1 output, and 4 states. It acts like a 
2-bit counter, where the output goes to high only if the FSM is in the 
final state.

When the direction pin is low, the counter counts up; if it is high, the
counter counts down.

Parameters
----------
direction_logic_value : int
    The logic value of the direction pin.
Returns
-------
dict
    The FSM spec that can be consumed by the FSM generator.
list
    The output pattern corresponding to the direction value.
list
    The state bit0 pattern corresponding to the direction value.
list
    The state bit1 pattern corresponding to the direction value.
def build_fsm_spec_4_state(direction_logic_value):
    'Build an FSM spec with 4 states.\n\n    The FSM built has 2 inputs, 1 output, and 4 states. It acts like a \n    2-bit counter, where the output goes to high only if the FSM is in the \n    final state.\n\n    When the direction pin is low, the counter counts up; if it is high, the\n    counter counts down.\n\n    Parameters\n    ----------\n    direction_logic_value : int\n        The logic value of the direction pin.\n    Returns\n    -------\n    dict\n        The FSM spec that can be consumed by the FSM generator.\n    list\n        The output pattern corresponding to the direction value.\n    list\n        The state bit0 pattern corresponding to the direction value.\n    list\n        The state bit1 pattern corresponding to the direction value.\n\n    '
    (out, rst, direction) = list(pin_dict.keys())[0:3]
    fsm_spec_4_state = {'inputs': [('rst', rst), ('direction', direction)], 'outputs': [('test', out)], 'states': ['S0', 'S1', 'S2', 'S3'], 'transitions': [['00', 'S0', 'S1', '0'], ['01', 'S0', 'S3', '0'], ['00', 'S1', 'S2', '0'], ['01', 'S1', 'S0', '0'], ['00', 'S2', 'S3', '0'], ['01', 'S2', 'S1', '0'], ['00', 'S3', 'S0', '1'], ['01', 'S3', 'S2', '1'], ['1-', '*', 'S0', ]]}
    if (not direction_logic_value):
        output_pattern = [0, 0, 0, 1]
        state_bit0_pattern = [0, 1, 0, 1]
        state_bit1_pattern = [0, 0, 1, 1]
    else:
        output_pattern = [0, 1, 0, 0]
        state_bit0_pattern = [0, 1, 0, 1]
        state_bit1_pattern = [0, 1, 1, 0]
    return (fsm_spec_4_state, output_pattern, state_bit0_pattern, state_bit1_pattern)