@pytest.mark.skipif((not flag), reason='need correct overlay to run')
def test_fsm_num_samples():
    'Test for the Finite State Machine Generator class.\n\n    In this test, the pattern generated by the FSM will be compared with the \n    one specified. We will test a minimum number of (FSM period + 1) samples,\n    and a maximum number of samples. 10MHz and 100MHz clocks are tested\n    for each case.\n\n    '
    ol.download()
    (rst, direction) = list(pin_dict.keys())[1:3]
    print('\nConnect {} to GND, and {} to VCC.'.format(rst, direction))
    input('Hit enter after done ...')
    (fsm_spec_4_state, output_pattern, _, _) = build_fsm_spec_4_state(1)
    fsm_period = len(fsm_spec_4_state['states'])
    for num_samples in [fsm_period, MAX_NUM_TRACE_SAMPLES]:
        test_tile = np.array(output_pattern)
        golden_test_array = np.tile(test_tile, ceil((num_samples / 4)))
        for fsm_frequency_mhz in [10, 100]:
            fsm_generator = FSMGenerator(mb_info)
            assert (fsm_generator.status == 'RESET')
            fsm_generator.trace(use_analyzer=True, num_analyzer_samples=num_samples)
            fsm_generator.setup(fsm_spec_4_state, frequency_mhz=fsm_frequency_mhz)
            assert (fsm_generator.status == 'READY')
            assert ('bram_data_buf' not in fsm_generator.logictools_controller.buffers), 'bram_data_buf is not freed after use.'
            fsm_generator.run()
            assert (fsm_generator.status == 'RUNNING')
            test_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']
            test_array = np.array(bitstring_to_int(wave_to_bitstring(test_string)))
            assert np.array_equal(test_array, golden_test_array[:num_samples]), 'Data pattern not correct when running at {}MHz.'.format(fsm_frequency_mhz)
            fsm_generator.stop()
            assert (fsm_generator.status == 'READY')
            fsm_generator.reset()
            assert (fsm_generator.status == 'RESET')
            del fsm_generator
Test for the Finite State Machine Generator class.

In this test, the pattern generated by the FSM will be compared with the 
one specified. We will test a minimum number of (FSM period + 1) samples,
and a maximum number of samples. 10MHz and 100MHz clocks are tested
for each case.
@pytest.mark.skipif((not flag), reason='need correct overlay to run')
def test_fsm_num_samples():
    'Test for the Finite State Machine Generator class.\n\n    In this test, the pattern generated by the FSM will be compared with the \n    one specified. We will test a minimum number of (FSM period + 1) samples,\n    and a maximum number of samples. 10MHz and 100MHz clocks are tested\n    for each case.\n\n    '
    ol.download()
    (rst, direction) = list(pin_dict.keys())[1:3]
    print('\nConnect {} to GND, and {} to VCC.'.format(rst, direction))
    input('Hit enter after done ...')
    (fsm_spec_4_state, output_pattern, _, _) = build_fsm_spec_4_state(1)
    fsm_period = len(fsm_spec_4_state['states'])
    for num_samples in [fsm_period, MAX_NUM_TRACE_SAMPLES]:
        test_tile = np.array(output_pattern)
        golden_test_array = np.tile(test_tile, ceil((num_samples / 4)))
        for fsm_frequency_mhz in [10, 100]:
            fsm_generator = FSMGenerator(mb_info)
            assert (fsm_generator.status == 'RESET')
            fsm_generator.trace(use_analyzer=True, num_analyzer_samples=num_samples)
            fsm_generator.setup(fsm_spec_4_state, frequency_mhz=fsm_frequency_mhz)
            assert (fsm_generator.status == 'READY')
            assert ('bram_data_buf' not in fsm_generator.logictools_controller.buffers), 'bram_data_buf is not freed after use.'
            fsm_generator.run()
            assert (fsm_generator.status == 'RUNNING')
            test_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']
            test_array = np.array(bitstring_to_int(wave_to_bitstring(test_string)))
            assert np.array_equal(test_array, golden_test_array[:num_samples]), 'Data pattern not correct when running at {}MHz.'.format(fsm_frequency_mhz)
            fsm_generator.stop()
            assert (fsm_generator.status == 'READY')
            fsm_generator.reset()
            assert (fsm_generator.status == 'RESET')
            del fsm_generator