@pytest.mark.skipif((not flag), reason='need correct overlay to run')
def test_fsm_state_bits():
    'Test for the Finite State Machine Generator class.\n\n    This test is similar to the first test, but in this test,\n    we will test the case when the state bits are also used as outputs.\n\n    '
    ol.download()
    (rst, direction) = list(pin_dict.keys())[1:3]
    print('\nConnect both {} and {} to GND.'.format(rst, direction))
    input('Hit enter after done ...')
    (fsm_spec_4_state, output_pattern, state_bit0_pattern, state_bit1_pattern) = build_fsm_spec_4_state(0)
    fsm_period = len(fsm_spec_4_state['states'])
    golden_test_array = np.array(output_pattern)
    golden_state_bit0_array = np.array(state_bit0_pattern)
    golden_state_bit1_array = np.array(state_bit1_pattern)
    for fsm_frequency_mhz in [10, 100]:
        fsm_generator = FSMGenerator(mb_info)
        fsm_generator.trace(use_analyzer=True, num_analyzer_samples=fsm_period)
        fsm_generator.setup(fsm_spec_4_state, use_state_bits=True, frequency_mhz=fsm_frequency_mhz)
        fsm_generator.run()
        test_string = state_bit0_string = state_bit1_string = ''
        for wavegroup in fsm_generator.waveform.waveform_dict['signal']:
            if (wavegroup and (wavegroup[0] == 'analysis')):
                for wavelane in wavegroup[1:]:
                    if (wavelane['name'] == 'test'):
                        test_string = wavelane['wave']
                    if (wavelane['name'] == 'state_bit0'):
                        state_bit0_string = wavelane['wave']
                    if (wavelane['name'] == 'state_bit1'):
                        state_bit1_string = wavelane['wave']
        test_array = np.array(bitstring_to_int(wave_to_bitstring(test_string)))
        state_bit0_array = np.array(bitstring_to_int(wave_to_bitstring(state_bit0_string)))
        state_bit1_array = np.array(bitstring_to_int(wave_to_bitstring(state_bit1_string)))
        assert np.array_equal(golden_test_array, test_array), 'Data pattern not correct when running at {}MHz.'.format(fsm_frequency_mhz)
        assert np.array_equal(golden_state_bit0_array, state_bit0_array), 'State bit0 not correct when running at {}MHz.'.format(fsm_frequency_mhz)
        assert np.array_equal(golden_state_bit1_array, state_bit1_array), 'State bit1 not correct when running at {}MHz.'.format(fsm_frequency_mhz)
        fsm_generator.stop()
        fsm_generator.reset()
        del fsm_generator
Test for the Finite State Machine Generator class.

This test is similar to the first test, but in this test,
we will test the case when the state bits are also used as outputs.
@pytest.mark.skipif((not flag), reason='need correct overlay to run')
def test_fsm_state_bits():
    'Test for the Finite State Machine Generator class.\n\n    This test is similar to the first test, but in this test,\n    we will test the case when the state bits are also used as outputs.\n\n    '
    ol.download()
    (rst, direction) = list(pin_dict.keys())[1:3]
    print('\nConnect both {} and {} to GND.'.format(rst, direction))
    input('Hit enter after done ...')
    (fsm_spec_4_state, output_pattern, state_bit0_pattern, state_bit1_pattern) = build_fsm_spec_4_state(0)
    fsm_period = len(fsm_spec_4_state['states'])
    golden_test_array = np.array(output_pattern)
    golden_state_bit0_array = np.array(state_bit0_pattern)
    golden_state_bit1_array = np.array(state_bit1_pattern)
    for fsm_frequency_mhz in [10, 100]:
        fsm_generator = FSMGenerator(mb_info)
        fsm_generator.trace(use_analyzer=True, num_analyzer_samples=fsm_period)
        fsm_generator.setup(fsm_spec_4_state, use_state_bits=True, frequency_mhz=fsm_frequency_mhz)
        fsm_generator.run()
        test_string = state_bit0_string = state_bit1_string = 
        for wavegroup in fsm_generator.waveform.waveform_dict['signal']:
            if (wavegroup and (wavegroup[0] == 'analysis')):
                for wavelane in wavegroup[1:]:
                    if (wavelane['name'] == 'test'):
                        test_string = wavelane['wave']
                    if (wavelane['name'] == 'state_bit0'):
                        state_bit0_string = wavelane['wave']
                    if (wavelane['name'] == 'state_bit1'):
                        state_bit1_string = wavelane['wave']
        test_array = np.array(bitstring_to_int(wave_to_bitstring(test_string)))
        state_bit0_array = np.array(bitstring_to_int(wave_to_bitstring(state_bit0_string)))
        state_bit1_array = np.array(bitstring_to_int(wave_to_bitstring(state_bit1_string)))
        assert np.array_equal(golden_test_array, test_array), 'Data pattern not correct when running at {}MHz.'.format(fsm_frequency_mhz)
        assert np.array_equal(golden_state_bit0_array, state_bit0_array), 'State bit0 not correct when running at {}MHz.'.format(fsm_frequency_mhz)
        assert np.array_equal(golden_state_bit1_array, state_bit1_array), 'State bit1 not correct when running at {}MHz.'.format(fsm_frequency_mhz)
        fsm_generator.stop()
        fsm_generator.reset()
        del fsm_generator