'{0:03}'.format(func_id_2)] = copy.deepcopy(
                         list_of_necessary_patterns)

        else:
            string += "\t" + "x" * data_width

        scanning_test_f1 = format(
            int(scanning_test_f1, 2) | int(scanning_test_f1_f2, 2),
            'b').zfill(data_width)
        scanning_string += "\t" + str(scanning_test_f1_f2)

    #-------------------------------------------------------------------------------
    #	This part fixes the scanning test results for the current function pair
    #-------------------------------------------------------------------------------
    scanning_test_f1, list_of_necessary_patterns = package.run_scanning_optimization(
        scanning_test_f1, function_dict, func_id_1, debug, verbose,
        list_of_necessary_patterns)

    scanning_string += "\t" + str(scanning_test_f1)
    scanning_table_file.write(scanning_string + "\n")
    table_file.write(string + "\n")

    # Print patterns and functions.. This will be used to prepare test patterns for SAF testing in turbo tester
    # This should only be used for VLIW experiment. Modification will be needed for other processors
    if verbose:
        print "-----------------------------------------------------"
        print "function_1: ", func_id_1

    opcode = "{0:04b}".format((func_id_1 - 2))
    for j in list_of_necessary_patterns:
        saf_test_patterns_file.write(function_dict[j][0] +
                     '{0:03}'.format(func_id_2)] = copy.deepcopy(
                         final_set_of_patterns)
        else:
            scanning_test_f1_f2 = "0" * data_width
            string += "\t" + "x" * data_width

        scanning_test_f1 = format(
            int(scanning_test_f1, 2) | int(scanning_test_f1_f2, 2),
            'b').zfill(data_width)
        scanning_string += "\t" + str(scanning_test_f1_f2)

    #-------------------------------------------------------------------------------
    #	This part fixes the scanning test results for the current function pair
    #-------------------------------------------------------------------------------
    scanning_test_f1, best_solution = package.run_scanning_optimization(
        scanning_test_f1, function_dict, func_id_1, debug, verbose,
        best_solution)
    scanning_string += "\t" + str(scanning_test_f1)
    scanning_table_file.write(scanning_string + "\n")
    table_file.write(string + "\n")

print "reporting test length for functions:"

for func_id_1 in range(2, len_of_list):
    patterns_for_current_function = []
    #print "starting with list: ", final_set_of_patterns, "length:", len(final_set_of_patterns)
    for func2 in range(2, len_of_list):
        or_op = "0" * data_width
        if func2 != func_id_1:
            for j in final_set_of_patterns:
                #if j not in patterns_for_current_function: