Exemplo n.º 1
0
def get_unique_file(file_pattern, speak_out=False):
    if type(file_pattern) is str:
        files = glob.glob(file_pattern)
    else:
        files = list()
        file_dir, file_ext = file_pattern
        if not_exists(file_dir, "Base searching path"):
            return
        for foo in os.listdir(file_dir):
            foo_name, foo_ext = os.path.splitext(foo.lower())
            if foo_ext == file_ext:
                files.append(os.path.join(file_dir, foo))
    if not files:
        if speak_out:
            print_error("Not found file for %s" % str(file_pattern))
        return
    len_files = len(files)
    if len_files > 1:
        print_always("Warning. %d files found for %s" %
                     (len_files, str(file_pattern)))
    if len_files == 1:
        return files[0]
    else:
        '''
            special process for _lse.twr
        '''
        for f in files:
            if f.endswith('_lse.twr'):
                pass
            else:
                return f
Exemplo n.º 2
0
    def create_design_dict(self):
        raw_design_list = os.listdir(self.real_top_dir)
        if self.design:
            design_list = list()
            if self.design in raw_design_list:
                design_list.append(self.design)
            else:
                print_error("Not found design %s in %s" %
                            (self.design, self.real_top_dir))
                return 1
        else:
            design_list = raw_design_list[:]

        if not design_list:
            print_error("Not found any design in %s" % self.real_top_dir)
            return 1

        for a_design in design_list:
            design_dir = os.path.join(self.real_top_dir, a_design)
            info_files = glob.glob(os.path.join(design_dir, "*.info"))
            if not info_files:  # not a design name
                continue
            for qa_info in info_files:
                m = self.p_family.search(qa_info)
                if not m:
                    print_always("Warning. can not parse %s" % qa_info)
                    continue
                cur_family, cur_vendor = get_std_family_vendor(m.group(1))
                if not cur_family:
                    print_error("Unknown family %s in %s" %
                                (m.group(1), os.path.basename(qa_info)))
                    continue
                t_dict = dict(design=a_design, family=cur_family)

                add_it = 0
                if self.family:  # if family name defined
                    if self.family in self.ecp2_ecp2m:
                        if cur_family in self.ecp2_ecp2m:
                            add_it = 1
                    elif cur_family == self.family:
                        add_it = 1
                else:
                    if cur_vendor == self.vendor:
                        add_it = 1
                if add_it:
                    self.design_dict[qa_info] = t_dict
        if not self.design_dict:
            print_error("Not found info file for all designs")
            return 1

        wrap_debug(self.design_dict, "Design Dictionary:")
            def scan_sigal(job_dir, design):
                print_always('scanning %s' % design)
                design_path = os.path.join(job_dir, design)  # e60_ecp3/g64
                srr_file = ''
                for dir in os.listdir(
                        design_path):  # dir:Target_Fmax_is_060MHz
                    dir_scan = os.path.join(design_path, dir)
                    if (not re.search("Target", dir)
                        ) and os.path.isdir(dir_scan) and not srr_file:
                        srr_file = get_unique_file([dir_scan, ".srr"])
                for dir in os.listdir(
                        design_path):  # dir:Target_Fmax_is_060MHz
                    dir_scan = os.path.join(design_path, dir)
                    #if (not re.search("Target", dir)) and os.path.isdir(dir_scan) and not srr_file:
                    #    srr_file = get_unique_file([dir_scan, ".srr"])
                    if re.search("Target", dir) and os.path.isdir(dir_scan):
                        pass
                    else:
                        continue
                    recover = RecoverPath(dir_scan)
                    used_dir = ''
                    for f_d in os.listdir(dir_scan):
                        f_d_full = os.path.join(dir_scan, f_d)
                        if os.path.isdir(f_d_full):
                            if used_dir:
                                print 'Worning: There are two implementation in the design'
                            used_dir = f_d_full
                    #srr_file = get_unique_file([used_dir, ".srr"])
                    if not srr_file:
                        pass
                    else:
                        srr_file = os.path.join(design_path, dir, srr_file)
                        scan_time.scan_srr(srr_file)
                    mrp_file = get_unique_file([used_dir, ".mrp"])
                    if not_exists(mrp_file, "map report file"):

                        continue
                    scan_mrp.scan_report(mrp_file)
                    scan_time.scan_mrp(mrp_file)
                    twr_file = time_file = par_file = ""
                    target_fmax_for_time = '_'
                    #------------------------------------------------#
                    if 1:
                        useful_dir = used_dir
                        base_name = os.path.basename(useful_dir)
                        scan_time.reset_par_time_data()
                        target_fmax_for_match = target_fmax_re.search(dir)
                        if target_fmax_for_match:
                            target_fmax_for_time = target_fmax_for_match.group(
                                1)
                        twr_p = os.path.join(useful_dir,
                                             '*' + base_name + ".twr")
                        twr_file = get_unique_file(twr_p)
                        if not twr_file:
                            twr_file = get_unique_file([useful_dir, ".twr"])
                        time_file = os.path.join(useful_dir, time_file)
                        par_file = get_unique_file([useful_dir, ".par"])
                        if twr_file:
                            scan_twr.scan_report(twr_file)
                            scan_time.scan_report(time_file)
                            scan_time.scan_par(par_file)
                            #########################
                            #time_title = ['design']+scan_time.get_title2()
                            srr_data = scan_time.get_srr_time_data()
                            mrp_data = scan_time.get_mrp_time_data()
                            par_data = scan_time.get_par_time_data()
                            real_cpu_total = scan_time.get_total_time()
                            all_time_data = dict(srr_data.items() +
                                                 mrp_data.items() +
                                                 par_data.items() +
                                                 real_cpu_total.items())
                            data_list = []
                            for key in scan_time.get_title():
                                value = all_time_data.get(key, 'NA')
                                data_list.append(value)
                            data_list2 = [design] + [target_fmax_for_time
                                                     ] + data_list
                            lock.acquire()
                            append_file(report_file_time, ",".join(data_list2))

                            #########################
                            #data = [design] + scan_mrp.get_data() + \
                            #      scan_twr.get_data() + data_list
                            if all_time_data[
                                    'Complete'] == 'NA' or all_time_data[
                                        'Par_Done'] == 'NA':
                                data_list = ['_']*len(scan_mrp.get_data()) +['_']*len(scan_twr.get_data()) +\
                                            ['_']*len(data_list)
                            else:
                                data_list = scan_mrp.get_data() + \
                                  scan_twr.get_data() + data_list
                            data = [design] + data_list
                            append_file(report_file, ",".join(data))
                            data = [design]
                            append_file(
                                report_file_mrp,
                                ",".join([design] + scan_mrp.get_data()))
                            append_file(
                                report_file_twr,
                                ",".join([design] + scan_twr.get_data()))
                            #append_file(report_file_time,",".join([design]+ scan_time.get_data()))
                            scan_time.reset_par_time_data()
                            #lock.release()
                        if not twr_file:
                            srr_data = scan_time.get_srr_time_data()
                            mrp_data = scan_time.get_mrp_time_data()
                            par_data = scan_time.get_par_time_data()
                            real_cpu_total = scan_time.get_total_time()
                            all_time_data = dict(srr_data.items()+mrp_data.items()+par_data.items() + \
                                                  real_cpu_total.items() )
                            data_list = []
                            for key in scan_time.get_title():
                                value = all_time_data.get(key, 'NA')
                                data_list.append(value)
                            data_list2 = [design] + [target_fmax_for_time
                                                     ] + data_list
                            lock.acquire()
                            append_file(report_file_time, ",".join(data_list2))
                            #data = [design] + scan_mrp.get_data()+ data_list
                            if all_time_data[
                                    'Complete'] == 'NA' or all_time_data[
                                        'Par_Done'] == 'NA':
                                data = [design] + ['_'] * len(
                                    scan_mrp.get_data()) + ['_'
                                                            ] * len(data_list)
                            else:
                                data = [design
                                        ] + scan_mrp.get_data() + data_list
                            append_file(report_file, ",".join(data))
                            append_file(
                                report_file_mrp,
                                ",".join([design] + scan_mrp.get_data()))
                            scan_time.reset_par_time_data()
                    scan_mrp.scan_clocks(mrp_file)
                    clock_dict = scan_mrp.get_parse_line_clocks()
                    for key in clock_dict.keys():
                        line = design + ',' + key + ',' + clock_dict[key]
                        append_file(report_file_clock, line)
                    lock.release()
                    recover.run()
def scan_report():
    opt = option()
    job_dir = opt.job_dir
    need_design = opt.design
    syn = opt.synthesis
    #syn = ''
    family = opt.family
    report_name = opt.report_name #this is useless now
    for_pattern=''
    pap = opt.pap
    scan_mrp = tool_scan_lattice.ScanLatticeMrp()
    scan_twr = tool_scan_lattice.ScanLatticeTwr(pap)
    scan_time = tool_scan_lattice.ScanLatticeTime()
    target_fmax_re = re.compile(r"Target_Seed_is_(.+)")
    if family:
        for_pattern = '_'+family
    if syn:
        for_pattern = for_pattern + '_'+syn
    dir_pattern = re.compile(for_pattern)
    
    all_designs = []
    if os.path.isdir(job_dir):
        pass
    else:
        print 'The job_dir:%s is not a directory'%job_dir
        return
    for dir in os.listdir(job_dir):  # get all the design path
        dir2 =  os.path.join(job_dir,dir)
        if os.path.isdir(dir2):
            all_designs.append(dir)
        else:
            pass
    report_file_list = []

    
    if 1:
        root_dir = os.getcwd()
        dir = os.path.basename(opt.job_dir)
        if 1:
            scanner = (scan_mrp, scan_twr, scan_time)
            report_file = os.path.join(opt.job_dir,dir+'.csv')
            if report_file in report_file_list:
                pass
            else:
                report_file_list.append(report_file)
            if not_exists(report_file):
                title = ["Design"]
                for item in scanner: #mrp twr time
                    title += item.get_title()
                append_file(report_file, ",".join(title))
            if 1:
                report_name,subtex = os.path.splitext(report_file)
                report_file_mrp = report_name+'_mrp'+subtex
                if not_exists(report_file_mrp):
                    title = ["Design"]
                    #for item in scanner: #mrp twr time
                    title += (scanner[0]).get_title()
                    append_file(report_file_mrp, ",".join(title))
                report_file_twr = report_name+'_twr'+subtex
                if not_exists(report_file_twr):
                    title = ["Design"]
                    #for item in scanner: #mrp twr time
                    title += (scanner[1]).get_title()
                    append_file(report_file_twr, ",".join(title))
                report_file_time = report_name+'_time'+subtex
                if not_exists(report_file_time):
                    title = ["Design"] +['Target_seed']
                    #for item in scanner: #mrp twr time
                    title += (scanner[2]).get_title()
                    append_file(report_file_time, ",".join(title))
                report_file_clock = report_name+'_clock'+subtex
                append_file(report_file_clock, ",".join(['Design','Colck','Loads']))
        for design in all_designs:
            if need_design:
                if design == need_design:
                    pass
                else:
                    continue
            print_always( 'scanning %s'%design)
            design_path = os.path.join(job_dir,design)# e60_ecp3/g64
            srr_file = ''
            for dir in os.listdir(design_path): # dir:Target_Fmax_is_060MHz   
                dir_scan = os.path.join(design_path,dir)
                if (not re.search("Target", dir)) and os.path.isdir(dir_scan) and (not srr_file):
                    srr_file = get_unique_file([dir_scan, ".srr"])
                if re.search("Target", dir) and os.path.isdir(dir_scan):
                    pass
                else:
                    continue
                recover = RecoverPath(dir_scan)
                used_dir = ''
                for f_d in os.listdir(dir_scan):
                    f_d_full = os.path.join(dir_scan,f_d)
                    if os.path.isdir(f_d_full):
                        if used_dir:
                            print 'Worning: There are two implementation in the design'
                        used_dir = f_d_full
                
                if not srr_file:
                    pass
                else:
                    srr_file = os.path.join(design_path,dir,srr_file) 
                    scan_time.scan_srr(srr_file)
                mrp_file = get_unique_file([used_dir, ".mrp"])
                if not_exists(mrp_file, "map report file"):
                    
                    continue
                scan_mrp.scan_report(mrp_file)
                scan_time.scan_mrp(mrp_file)
                twr_file = time_file = par_file= ""
                target_fmax_for_time = '_'
                #------------------------------------------------#
                if 1:
                     useful_dir = used_dir
                     base_name = os.path.basename(useful_dir)
                     scan_time.reset_par_time_data()
                     target_fmax_for_match = target_fmax_re.search(dir)
                     if target_fmax_for_match:
                         target_fmax_for_time = target_fmax_for_match.group(1)
                     twr_p = os.path.join(useful_dir,'*'+base_name+".twr")
                     twr_file = get_unique_file(twr_p)
                     if not twr_file:
                         twr_file = get_unique_file([useful_dir, ".twr"])
                     time_file = os.path.join(useful_dir, time_file)
                     par_file = get_unique_file([useful_dir, ".par"])
                     if twr_file:
                         scan_twr.scan_report(twr_file)
                         scan_time.scan_report(time_file)
                         scan_time.scan_par(par_file)
                         #########################
                         #time_title = ['design']+scan_time.get_title2()
                         srr_data = scan_time.get_srr_time_data()
                         mrp_data = scan_time.get_mrp_time_data()
                         par_data = scan_time.get_par_time_data()
                         real_cpu_total = scan_time.get_total_time()
                         all_time_data = dict(srr_data.items()+mrp_data.items()+par_data.items() + real_cpu_total.items() )
                         data_list = []
                         for key in scan_time.get_title():
                             value = all_time_data.get(key,'NA')
                             data_list.append(value)
                         data_list2 = [design]+[target_fmax_for_time] +data_list
                         append_file(report_file_time,",".join(data_list2))
                             
                         #########################
                         #data = [design] + scan_mrp.get_data() + \
                         #      scan_twr.get_data() + data_list
                         if all_time_data['Complete'] == 'NA' or all_time_data['Par_Done'] == 'NA':
                             data_list = ['_']*len(scan_mrp.get_data()) +['_']*len(scan_twr.get_data()) +\
                                         ['_']*len(data_list)
                         else:
                             data_list = scan_mrp.get_data() + \
                               scan_twr.get_data() + data_list
                         data = [design] + data_list
                         append_file(report_file, ",".join(data))
                         data = [design]
                         append_file(report_file_mrp,",".join([design]+ scan_mrp.get_data() ))
                         append_file(report_file_twr,",".join([design]+ scan_twr.get_data() ))
                         #append_file(report_file_time,",".join([design]+ scan_time.get_data()))
                         scan_time.reset_par_time_data()
                     if not twr_file:
                         srr_data = scan_time.get_srr_time_data()
                         mrp_data = scan_time.get_mrp_time_data()
                         par_data = scan_time.get_par_time_data()
                         real_cpu_total = scan_time.get_total_time()
                         all_time_data = dict(srr_data.items()+mrp_data.items()+par_data.items() + \
                                               real_cpu_total.items() )
                         data_list = []
                         for key in scan_time.get_title():
                             value = all_time_data.get(key,'NA')
                             data_list.append(value)
                         data_list2 = [design]+[target_fmax_for_time] +data_list
                         append_file(report_file_time,",".join(data_list2))
                         #data = [design] + scan_mrp.get_data()+ data_list
                         if all_time_data['Complete'] == 'NA' or all_time_data['Par_Done'] == 'NA':
                             data = [design] + ['_']*len(scan_mrp.get_data())+  ['_']*len(data_list)
                         else:
                             data = [design] + scan_mrp.get_data()+ data_list
                         append_file(report_file, ",".join(data))
                         append_file(report_file_mrp,",".join([design]+ scan_mrp.get_data()))
                         scan_time.reset_par_time_data()
                scan_mrp.scan_clocks(mrp_file)
                clock_dict = scan_mrp.get_parse_line_clocks()
                for key in clock_dict.keys():
                    line = design+','+key+','+clock_dict[key]
                    append_file(report_file_clock,line)
                recover.run()
        os.chdir(root_dir)
Exemplo n.º 5
0
def scan_report():
    opt = option()
    job_dir = opt.job_dir
    job_dir = os.path.abspath(job_dir)
    need_design = opt.design
    syn = opt.synthesis
    #syn = ''
    family = opt.family
    report_name = opt.report_name  #this is useless now
    for_pattern = ''
    pap = opt.pap
    scan_mrp = tool_scan_lattice.ScanLatticeMrp()
    scan_twr = tool_scan_lattice.ScanLatticeTwr(pap)
    scan_time = tool_scan_lattice.ScanLatticeTime()
    target_fmax_re = re.compile(r"Target_Fmax_is_(.+)MHz")
    if family:
        for_pattern = '_' + family
    if syn:
        for_pattern = for_pattern + '_' + syn
    dir_pattern = re.compile(for_pattern)

    all_designs = []
    if os.path.isdir(job_dir):
        for d in os.listdir(job_dir):
            if d.endswith('.csv'):
                d = os.path.join(job_dir, d)
                os.remove(d)
        pass
    else:
        print 'The job_dir:%s is not a directory' % job_dir
        return
    for dir in os.listdir(job_dir):  # get all the design path
        dir2 = os.path.join(job_dir, dir)
        if os.path.isdir(dir2):
            all_designs.append(dir)
        else:
            pass
    report_file_list = []

    if 1:
        root_dir = os.getcwd()
        dir = os.path.basename(opt.job_dir)
        if 1:
            scanner = (scan_mrp, scan_twr, scan_time)
            report_file = os.path.join(opt.job_dir, dir + '.csv')
            if report_file in report_file_list:
                pass
            else:
                report_file_list.append(report_file)
            if not_exists(report_file):
                title = ["Design"]
                for item in scanner:  #mrp twr time
                    title += item.get_title()
                append_file(report_file, ",".join(title))
            if 1:
                report_name, subtex = os.path.splitext(report_file)
                report_file_mrp = report_name + '_mrp' + subtex
                if not_exists(report_file_mrp):
                    title = ["Design"]
                    #for item in scanner: #mrp twr time
                    title += (scanner[0]).get_title()
                    append_file(report_file_mrp, ",".join(title))
                report_file_twr = report_name + '_twr' + subtex
                if not_exists(report_file_twr):
                    title = ["Design"]
                    #for item in scanner: #mrp twr time
                    title += (scanner[1]).get_title()
                    append_file(report_file_twr, ",".join(title))
                report_file_time = report_name + '_time' + subtex
                if not_exists(report_file_time):
                    title = ["Design"] + ['Target_fmax']
                    #for item in scanner: #mrp twr time
                    title += (scanner[2]).get_title()
                    append_file(report_file_time, ",".join(title))
                report_file_clock = report_name + '_clock' + subtex
                append_file(report_file_clock,
                            ",".join(['Design', 'Colck', 'Loads']))
        for design in all_designs:
            if need_design:
                if design == need_design:
                    pass
                else:
                    continue
            print_always('scanning %s' % design)
            design_path = os.path.join(job_dir, design)  # e60_ecp3/g64
            srr_file = ''
            for dir in os.listdir(design_path):  # dir:Target_Fmax_is_060MHz
                dir_scan = os.path.join(design_path, dir)
                if (not re.search("Target", dir)
                    ) and os.path.isdir(dir_scan) and not srr_file:
                    srr_file = get_unique_file([dir_scan, ".srr"])
            for dir in os.listdir(design_path):  # dir:Target_Fmax_is_060MHz
                dir_scan = os.path.join(design_path, dir)
                #if (not re.search("Target", dir)) and os.path.isdir(dir_scan) and not srr_file:
                #    srr_file = get_unique_file([dir_scan, ".srr"])
                if re.search("Target", dir) and os.path.isdir(dir_scan):
                    pass
                else:
                    continue
                recover = RecoverPath(dir_scan)
                used_dir = ''
                for f_d in os.listdir(dir_scan):
                    f_d_full = os.path.join(dir_scan, f_d)
                    if os.path.isdir(f_d_full):
                        if used_dir:
                            print 'Worning: There are two implementation in the design'
                        used_dir = f_d_full
                #srr_file = get_unique_file([used_dir, ".srr"])
                if not srr_file:
                    pass
                else:
                    srr_file = os.path.join(design_path, dir, srr_file)
                    scan_time.scan_srr(srr_file)
                mrp_file = get_unique_file([used_dir, ".mrp"])
                if not_exists(mrp_file, "map report file"):

                    continue
                scan_mrp.scan_report(mrp_file)
                scan_time.scan_mrp(mrp_file)
                twr_file = time_file = par_file = ""
                target_fmax_for_time = '_'
                #------------------------------------------------#
                if 1:
                    useful_dir = used_dir
                    base_name = os.path.basename(useful_dir)
                    scan_time.reset_par_time_data()
                    target_fmax_for_match = target_fmax_re.search(dir)
                    if target_fmax_for_match:
                        target_fmax_for_time = target_fmax_for_match.group(1)
                    twr_p = os.path.join(useful_dir, '*' + base_name + ".twr")
                    twr_file = get_unique_file(twr_p)
                    if not twr_file:
                        twr_file = get_unique_file([useful_dir, ".twr"])
                    time_file = os.path.join(useful_dir, time_file)
                    par_file = get_unique_file([useful_dir, ".par"])
                    if twr_file:
                        scan_twr.scan_report(twr_file)
                        scan_time.scan_report(time_file)
                        scan_time.scan_par(par_file)
                        #########################
                        #time_title = ['design']+scan_time.get_title2()
                        srr_data = scan_time.get_srr_time_data()
                        mrp_data = scan_time.get_mrp_time_data()
                        par_data = scan_time.get_par_time_data()
                        real_cpu_total = scan_time.get_total_time()
                        all_time_data = dict(srr_data.items() +
                                             mrp_data.items() +
                                             par_data.items() +
                                             real_cpu_total.items())
                        data_list = []
                        for key in scan_time.get_title():
                            value = all_time_data.get(key, 'NA')
                            data_list.append(value)
                        data_list2 = [design] + [target_fmax_for_time
                                                 ] + data_list
                        append_file(report_file_time, ",".join(data_list2))

                        #########################
                        #data = [design] + scan_mrp.get_data() + \
                        #      scan_twr.get_data() + data_list
                        if all_time_data['Complete'] == 'NA' or all_time_data[
                                'Par_Done'] == 'NA':
                            data_list = ['_']*len(scan_mrp.get_data()) +['_']*len(scan_twr.get_data()) +\
                                        ['_']*len(data_list)
                        else:
                            data_list = scan_mrp.get_data() + \
                              scan_twr.get_data() + data_list
                        data = [design] + data_list
                        append_file(report_file, ",".join(data))
                        data = [design]
                        append_file(report_file_mrp,
                                    ",".join([design] + scan_mrp.get_data()))
                        append_file(report_file_twr,
                                    ",".join([design] + scan_twr.get_data()))
                        #append_file(report_file_time,",".join([design]+ scan_time.get_data()))
                        scan_time.reset_par_time_data()
                    if not twr_file:
                        srr_data = scan_time.get_srr_time_data()
                        mrp_data = scan_time.get_mrp_time_data()
                        par_data = scan_time.get_par_time_data()
                        real_cpu_total = scan_time.get_total_time()
                        all_time_data = dict(srr_data.items()+mrp_data.items()+par_data.items() + \
                                              real_cpu_total.items() )
                        data_list = []
                        for key in scan_time.get_title():
                            value = all_time_data.get(key, 'NA')
                            data_list.append(value)
                        data_list2 = [design] + [target_fmax_for_time
                                                 ] + data_list
                        append_file(report_file_time, ",".join(data_list2))
                        #data = [design] + scan_mrp.get_data()+ data_list
                        if all_time_data['Complete'] == 'NA' or all_time_data[
                                'Par_Done'] == 'NA':
                            data = [design] + ['_'] * len(
                                scan_mrp.get_data()) + ['_'] * len(data_list)
                        else:
                            data = [design] + scan_mrp.get_data() + data_list
                        append_file(report_file, ",".join(data))
                        append_file(report_file_mrp,
                                    ",".join([design] + scan_mrp.get_data()))
                        scan_time.reset_par_time_data()
                scan_mrp.scan_clocks(mrp_file)
                clock_dict = scan_mrp.get_parse_line_clocks()
                for key in clock_dict.keys():
                    line = design + ',' + key + ',' + clock_dict[key]
                    append_file(report_file_clock, line)
                recover.run()
        os.chdir(root_dir)
    for f in report_file_list:
        if os.path.isfile(f):
            file_sorted, note, design_fmax = report_sort.sort_csv(f)
            report_sort.write_note(file_sorted, note)
    file_hand_pass = file('pass_case.log', 'w')
    #----------read fail case first:
    try:
        file_hand_fail = file('fail_case.log', 'r')
        fail_case_lines = file_hand_fail.readlines()
        file_hand_fail.close()
        fail_case_lines2 = [
            f_c.split(':')[0].strip() for f_c in fail_case_lines
        ]
    except:
        fail_case_lines2 = []
    file_hand_fail = file('fail_case.log', 'w')
    for key in design_fmax.keys():
        v = design_fmax[key]

        if re.search(r'\d', v):
            file_hand_pass.write(key + '\n')
        else:
            if key in fail_case_lines2:
                fail_k = fail_case_lines[fail_case_lines2.index(key)]
                file_hand_fail.write(fail_k.strip() + '\n')
            else:
                file_hand_fail.write(key + '\n')
    file_hand_pass.close()
    file_hand_fail.close()

    #----------------update run_stand-------------------#
    if 1:
        pass_log = glob.glob('pass_case.log')
        if pass_log:
            pass_log = pass_log[0]
        else:
            pass_log = '__'
        if os.path.isfile(pass_log):
            file_hand = file(pass_log, 'r')
            lines = file_hand.readlines()
            file_hand.close()
            stand_name = glob.glob('*' + '_run_stand.bat')
            if stand_name:
                stand_name = stand_name[0]
            #stand_name = os.path.join(top_base,top_base2+'_'+syn+'_run_standard.bat')
            else:
                stand_name = ''
            run_standard = file(stand_name, 'r')
            run_standard_lines = run_standard.readlines()
            run_standard_lines = list(set(run_standard_lines))
            run_standard.close()
            #--------------
            try:
                again_name = glob.glob('*' + 'run_again.bat')
                if again_name:
                    again_name = again_name[0]
                #stand_name = os.path.join(top_base,top_base2+'_'+syn+'_run_standard.bat')
                else:
                    again_name = ''
                try:
                    again = file(again_name, 'r')
                    again_lines = again.readlines()
                    again_lines = list(set(again_lines))
                    again.close()
                    replaced_job_dir = os.path.basename(os.getcwd())
                    again_lines = [
                        re.sub(r'--job-dir=\S+',
                               '--job-dir=' + replaced_job_dir, ag)
                        for ag in again_lines
                    ]
                    new_again = []
                    #again_lines = [re.sub(r'--job-dir=\S+',replaced_job_dir,ag) for ag in again_lines]
                    #for ag in again_lines:
                    for ag in again_lines:
                        file_f = re.findall('--file=(\S+)', ag)
                        if file_f:
                            new_f = os.path.basename(file_f[-1])
                            ag = re.sub(r'--file=(\S+)', '--file=' + new_f, ag)
                        new_again.append(ag)

                    run_standard_lines1 = run_standard_lines + new_again
                    run_standard_lines1 = list(set(run_standard_lines1))
                except:
                    run_standard_lines1 = list(set(run_standard_lines))
                    #pass

                #run_standard_lines = run_standard_lines + again_lines
            except:
                pass

            useful_lines = []
            for case in lines:
                case = case.strip()
                if not case:
                    continue
                else:
                    pass
                case_tab = '--design=' + case
                case_tab_re = re.compile(case_tab + r'(\s+|$)')
                for line in run_standard_lines1:
                    line = line.strip()
                    if not line:
                        continue
                    if case_tab_re.search(line):
                        try:
                            fmax = float(design_fmax[case.strip()])
                            fmax = str(int(fmax))
                            line = re.sub(r'--fmax-sweep=[\s\d]+\d', '', line)
                            line2 = line + ' --fmax-sweep=' + fmax + ' ' + fmax + ' ' + '10 \n'
                            useful_lines.append(line2)
                        except:
                            #line2 = line
                            pass

            run_standard = file(stand_name, 'w')
            run_standard.writelines(useful_lines)
            run_standard.close()
def scan_report():
    opt = option()
    job_dir = opt.job_dir
    design = opt.design
    syn = opt.synthesis
    family = opt.family
    report_name = opt.report_name  #this is useless now
    for_pattern = ''
    pap = opt.pap
    scan_mrp = tool_scan_xilinx.ScanXilinxMrp()
    scan_twr = tool_scan_xilinx.ScanXilinxTwr()
    scan_time = tool_scan_xilinx.ScanXilinxTimeMem()
    if family:
        for_pattern = '_' + family
    if syn:
        for_pattern = for_pattern + '_' + syn
    dir_pattern = re.compile(for_pattern)
    print for_pattern

    all_designs = []
    if os.path.isdir(job_dir):
        pass
    else:
        print 'The job_dir:%s is not a directory' % job_dir
        return
    for dir in os.listdir(job_dir):  # get all the design path
        dir2 = os.path.join(job_dir, dir)
        if os.path.isdir(dir2):
            all_designs.append(dir)
        else:
            pass
    report_file_list = []
    if design:
        print_always('scanning %s' % design)
        if design in all_designs:
            design_path = os.path.join(job_dir, design)
            for dir in os.listdir(design_path):
                if dir_pattern.search(dir) and os.path.isdir(
                        os.path.join(design_path, dir)):
                    #####################
                    scanner = (scan_mrp, scan_twr, scan_time)
                    report_file = os.path.join(job_dir, dir + '.csv')
                    report_file_list.append(report_file)
                    if not_exists(report_file):
                        title = ["Design"]
                        for item in scanner:  #mrp twr time
                            title += item.get_title()
                        append_file(report_file, ",".join(title))

                    if 1:
                        report_name, subtex = os.path.splitext(report_file)
                        report_file_mrp = report_name + '_mrp' + subtex
                        if not_exists(report_file_mrp):
                            title = ["Design"]
                            #for item in scanner: #mrp twr time
                            title += (scanner[0]).get_title()
                            append_file(report_file_mrp, ",".join(title))
                        report_file_twr = report_name + '_twr' + subtex
                        if not_exists(report_file_twr):
                            title = ["Design"]
                            #for item in scanner: #mrp twr time
                            title += (scanner[1]).get_title()
                            append_file(report_file_twr, ",".join(title))
                        report_file_time = report_name + '_time_mem' + subtex
                        if not_exists(report_file_time):
                            title = ["Design"]
                            #for item in scanner: #mrp twr time
                            title += (scanner[2]).get_title()
                            append_file(report_file_time, ",".join(title))

                ######################
                    dir_scan = os.path.join(design_path, dir)
                    twr_file = time_file = ""
                    if 'rev_1' in os.listdir(dir_scan):
                        scan_time.set_srr_data()
                        foo = os.path.join(dir_scan, 'rev_1', '*.srr')
                        srr_file = get_unique_file(foo)
                        if srr_file:
                            scan_time.scan_srr(srr_file)
                    for foo in os.listdir(dir_scan):
                        foo = os.path.join(dir_scan, foo)
                        if os.path.isdir(foo):
                            if re.search("Target", foo):
                                print foo
                                recover = RecoverPath(
                                    os.path.join(design_path, dir, foo))
                                scan_mrp.reset()
                                #scan_time.reset()
                                scan_time.set_map_data()
                                scan_time.set_par_data()

                                scan_twr.reset()
                                print_always("  Scanning %s" % foo)
                                _project_name = "%s_%s" % (dir, design[:7])
                                project_name = _project_name.strip("_")
                                mrp_file = os.path.join(
                                    dir_scan, foo, project_name + "_map.mrp")
                                scan_mrp.scan_report(mrp_file)
                                scan_time.scan_map(mrp_file)
                                par_file = os.path.join(
                                    dir_scan, foo, project_name + ".par")
                                scan_time.scan_par(par_file)
                                twr_file = os.path.join(
                                    dir_scan, foo, project_name + ".twr")

                                scan_twr.scan_report(twr_file)
                                time_file = os.path.join(
                                    dir_scan, foo, "mpar_log.time")
                                #scan_time.scan_report(time_file)
                                data1 = scan_mrp.get_data()
                                append_file(report_file_mrp,
                                            ",".join([design] + data1))
                                data2 = scan_twr.get_data()
                                append_file(report_file_twr,
                                            ",".join([design] + data2))
                                data3 = scan_time.get_data()
                                append_file(report_file_time,
                                            ",".join([design] + data3))
                                data = data1 + data2 + data3
                                append_file(report_file,
                                            ",".join([design] + data))
                                recover.run()

        else:
            print 'The design is not exists in the job_dir'
            return
    else:
        root_dir = os.getcwd()
        for design in all_designs:
            print_always('scanning %s' % design)
            design_path = os.path.join(job_dir, design)
            for dir in os.listdir(design_path):
                if dir_pattern.search(dir) and os.path.isdir(
                        os.path.join(design_path, dir)):
                    #####################
                    scanner = (scan_mrp, scan_twr, scan_time)
                    report_file = os.path.join(job_dir, dir + '.csv')
                    report_file_list.append(report_file)
                    if not_exists(report_file):
                        title = ["Design"]
                        for item in scanner:  #mrp twr time
                            title += item.get_title()
                        append_file(report_file, ",".join(title))
                    if 1:
                        report_name, subtex = os.path.splitext(report_file)
                        report_file_mrp = report_name + '_mrp' + subtex
                        if not_exists(report_file_mrp):
                            title = ["Design"]
                            #for item in scanner: #mrp twr time
                            title += (scanner[0]).get_title()
                            append_file(report_file_mrp, ",".join(title))
                        report_file_twr = report_name + '_twr' + subtex
                        if not_exists(report_file_twr):
                            title = ["Design"]
                            #for item in scanner: #mrp twr time
                            title += (scanner[1]).get_title()
                            append_file(report_file_twr, ",".join(title))
                        report_file_time = report_name + '_time_mem' + subtex
                        if not_exists(report_file_time):
                            title = ["Design"]
                            #for item in scanner: #mrp twr time
                            title += (scanner[2]).get_title()
                            append_file(report_file_time, ",".join(title))

                ######################
                    dir_scan = os.path.join(design_path, dir)
                    twr_file = time_file = ""
                    if 'rev_1' in os.listdir(dir_scan):
                        scan_time.set_srr_data()
                        foo = os.path.join(dir_scan, 'rev_1', '*.srr')
                        srr_file = get_unique_file(foo)
                        if srr_file:
                            scan_time.scan_srr(srr_file)

                    for foo in os.listdir(dir_scan):
                        if os.path.isdir(os.path.join(design_path, dir, foo)):
                            if re.search("Target", foo):
                                recover = RecoverPath(
                                    os.path.join(design_path, dir, foo))
                                scan_mrp.reset()
                                #scan_time.reset()
                                scan_time.set_map_data()
                                scan_time.set_par_data()
                                scan_twr.reset()
                                print_always("  Scanning %s" % foo)
                                _project_name = "%s_%s" % (dir, design[:7])
                                project_name = _project_name.strip("_")
                                mrp_file = os.path.join(
                                    dir_scan, foo, project_name + "_map.mrp")
                                scan_mrp.scan_report(mrp_file)
                                scan_time.scan_map(mrp_file)
                                par_file = os.path.join(
                                    dir_scan, foo, project_name + ".par")
                                scan_time.scan_par(par_file)
                                twr_file = os.path.join(
                                    dir_scan, foo, project_name + ".twr")
                                scan_twr.scan_report(twr_file)
                                #time_file = os.path.join(dir_scan,foo,"mpar_log.time")
                                #scan_time.scan_report(time_file)
                                data1 = scan_mrp.get_data()
                                append_file(report_file_mrp,
                                            ",".join([design] + data1))
                                data2 = scan_twr.get_data()
                                append_file(report_file_twr,
                                            ",".join([design] + data2))
                                data3 = scan_time.get_data()
                                append_file(report_file_time,
                                            ",".join([design] + data3))
                                data = data1 + data2 + data3
                                append_file(report_file,
                                            ",".join([design] + data))
                                recover.run()
        os.chdir(root_dir)
    for f in report_file_list:
        if os.path.isfile(f):
            file_sorted, note, design_fmax = report_sort.sort_csv(f)
            report_sort.write_note(file_sorted, note)
    #----------------update run_stand-------------------#
    pass_log = glob.glob('*' + syn + '_pass_case.log')
    if pass_log:
        pass_log = pass_log[0]
    else:
        pass_log = '__'
    if os.path.isfile(pass_log):
        file_hand = file(pass_log, 'r')
        lines = file_hand.readlines()
        file_hand.close()
        stand_name = glob.glob('*' + syn + '_run_standard.bat')
        if stand_name:
            stand_name = stand_name[0]
        #stand_name = os.path.join(top_base,top_base2+'_'+syn+'_run_standard.bat')
        else:
            stand_name = ''
        run_standard = file(stand_name, 'r')
        run_standard_lines = run_standard.readlines()
        run_standard.close()
        useful_lines = []
        for case in lines:
            case = case.strip()
            if not case:
                continue
            else:
                pass
            case_tab = '--design=' + case
            case_tab_re = re.compile(case_tab + r'(\s+|$)')
            for line in run_standard_lines:
                line = line.strip()
                if not line:
                    continue
                if case_tab_re.search(line):
                    try:
                        fmax = float(design_fmax[case.strip()])
                        fmax = str(int(fmax))
                        #line = case_tab_re.sub('',line)
                        line = re.sub(r'--fmax-sweep=[\s\d]+\d', '', line)
                        line2 = line + ' --fmax-sweep=' + fmax + ' ' + fmax + ' ' + '10 \n'
                    except:
                        line2 = line

                    useful_lines.append(line2)
        run_standard = file(stand_name, 'w')
        run_standard.writelines(useful_lines)
        run_standard.close()
        '''        
Exemplo n.º 7
0
def scan_report():
    opt = option()
    scanner = (tool_scan_altera_temp.ScanAlteraFit(), tool_scan_altera_temp.ScanAlteraFmax())
    job_dir = opt.job_dir
    #design = opt.design
    #syn = opt.synthesis
    #family = opt.family
    report_name = opt.report_name #this is useless now
    for_pattern=''
    #pap = opt.pap
    scan_fit = tool_scan_altera_temp.ScanAlteraFit()
    scan_fmax =  tool_scan_altera_temp.ScanAlteraFmax()
    scan_time_mem = tool_scan_altera_temp.ScanTimeMem()
    all_designs = []
    if os.path.isdir(job_dir):
        pass
    else:
        print 'The job_dir:%s is not a directory'%job_dir
        return
    for dir in os.listdir(job_dir):  # get all the design path
        dir2 =  os.path.join(job_dir,dir)
        if os.path.isdir(dir2):
            all_designs.append(dir)
        else:
            pass
    report_file_list = []
    if 0:
        pass
        
    else:
        root_dir = os.getcwd()
        for design in all_designs:
            print_always( 'scanning %s'%design)
            design_path = os.path.join(job_dir,design)
            for dir in os.listdir(design_path): #at here dir should be as "_cyclone4_syn"
                dir_scan = os.path.join(design_path,dir)
                if os.path.isdir(dir_scan):
                    pass
                else:
                    continue
                if 1:
                    #####################
                    scanner = (scan_fit, scan_fmax,scan_time_mem)
                    report_file = os.path.join(job_dir,dir+'.csv')
                    report_file_list.append(report_file)
                    if not_exists(report_file):
                        title = ["Design"]
                        for item in scanner: #mrp twr time
                            title += item.get_title()
                        append_file(report_file, ",".join(title))
                    if 1:
                        report_name,subtex = os.path.splitext(report_file)
                        report_file_fit = report_name+'_fit'+subtex
                        if not_exists(report_file_fit):
                            title = ["Design"]
                            #for item in scanner: #mrp twr time
                            title += (scanner[0]).get_title()
                            append_file(report_file_fit, ",".join(title))
                        report_file_sta = report_name+'_sta'+subtex
                        if not_exists(report_file_sta):
                            title = ["Design"]
                            #for item in scanner: #mrp twr time
                            title += (scanner[1]).get_title()
                            append_file(report_file_sta, ",".join(title))
                        report_file_time_mem = report_name+'_time_mem'+subtex
                        if not_exists(report_file_time_mem):
                            title = ["Design"]
                            title += (scanner[2]).get_title()
                            append_file(report_file_time_mem, ",".join(title))
                        
                    ######################
                    recover = RecoverPath(dir_scan) 
                    fit_file = sta_file = map_file = srr_file =  ""
                    
                    if 'rev_1' in os.listdir('.'):
                        scan_time_mem.reset()
                        foo = os.path.join(dir_scan,'rev_1')
                        srr_file = get_unique_file(foo+'/'+'*.srr')
                        if srr_file:
                            scan_time_mem.scan_srr(srr_file)
                    
                    for foo in os.listdir("."):
                        data = []
                        if os.path.isdir(foo):
                            if re.search("Target", foo):
                                scan_fit.reset()
                                scan_fmax.reset()
                                scan_time_mem.set_fit_data()
                                scan_time_mem.set_map_data()
                                print_always("  Scanning %s" % foo)
                                fit_file = get_unique_file(foo+'/'+"*.fit.rpt")
                                sta_file = get_unique_file(foo+'/'+"*.sta.rpt")
                                map_file = get_unique_file(foo+'/'+'*.map.rpt')
                                if fit_file:
                                    scan_fit.scan_report(fit_file)
                                    scan_time_mem.scan_fit(fit_file)
                                    data1=[design]+scan_fit.get_data()
                                    append_file(report_file_fit, ",".join(data1))
                                    data = data + data1
                                if sta_file:
                                    scan_fmax.scan_report_temp(sta_file)
                                    data2=[design]+scan_fmax.get_data()
                                    append_file(report_file_sta, ",".join(data2))
                                    data = data + data2[1:]
                                if map_file:
                                    scan_time_mem.scan_map(map_file)
                                scan_t_m = scan_time_mem.get_data()
                                append_file(report_file_time_mem, ",".join([design]+scan_t_m))
                                data  = data + scan_t_m
                                append_file(report_file, ",".join(data))
                    recover.run()
            
            
            
            
        os.chdir(root_dir)               
    for f in report_file_list:
        if os.path.isfile(f):
            print '#######################################'
            file_sorted,note,design_fmax = report_sort_temp.sort_csv(f,col_key='PAP',add_average=1)
            report_sort_temp.write_note(file_sorted,note)
Exemplo n.º 8
0
def scan_report():
    opt = option()
    job_dir = opt.job_dir
    design = opt.design
    scan_mrp = tool_scan_xilinx.ScanXilinxMrp()
    scan_twr = tool_scan_xilinx.ScanXilinxTwr()
    scan_time = tool_scan_xilinx.ScanXilinxTimeMem()
    scan_timing_rpt = tool_scan_xilinx.ScanXilinxTimingRpt()
    scan_placed_rpt = tool_scan_xilinx.ScanXilinxPlacedRpt()
    tag = opt.special_structure
    report_name = opt.report_name  #this is useless now
    if report_name == 'report.csv':
        report_file = os.path.basename(job_dir) + '.csv'
    report_path = opt.report_path
    if not report_path:
        report_path = job_dir
    report_file = os.path.join(report_path, report_file)
    all_designs = []
    if os.path.isdir(job_dir):
        pass
    else:
        print 'The job_dir:%s is not a directory' % job_dir
        return
    if not design:
        for dir in os.listdir(job_dir):  # get all the design path
            dir2 = os.path.join(job_dir, dir)
            if os.path.isdir(dir2):
                all_designs.append(dir)
            else:
                pass
    else:
        all_designs.append(design)
    report_file_list = []
    if 1:
        root_dir = os.getcwd()
        for design in all_designs:
            print_always('scanning %s' % design)
            design_path = os.path.join(job_dir, design, tag)
            for dir in os.listdir(design_path):
                if dir.endswith('.runs') and os.path.isdir(
                        os.path.join(design_path, dir)):
                    #####################
                    scanner = (scan_mrp, scan_twr, scan_time)
                    report_file_list.append(report_file)

                    ######################
                    dir_scan = os.path.join(design_path, dir)
                    twr_file = time_file = ""
                    if 'rev_1' in os.listdir(dir_scan):
                        scan_time.set_srr_data()
                        foo = os.path.join(dir_scan, 'rev_1', '*.srr')
                        srr_file = get_unique_file(foo)
                        if srr_file:
                            scan_time.scan_srr(srr_file)

                    for foo in os.listdir(dir_scan):
                        if os.path.isdir(os.path.join(design_path, dir, foo)):
                            if re.search("Target", foo):  # this is ISE
                                recover = RecoverPath(
                                    os.path.join(design_path, dir, foo))
                                scan_mrp.reset()
                                #scan_time.reset()
                                scan_time.set_map_data()
                                scan_time.set_par_data()
                                scan_twr.reset()
                                print_always("  Scanning %s" % foo)
                                _project_name = "%s_%s" % (dir, design[:7])
                                project_name = _project_name.strip("_")
                                mrp_file = os.path.join(
                                    dir_scan, foo, project_name + "_map.mrp")
                                if os.path.isfile(mrp_file):
                                    if not_exists(report_file):
                                        title = ["Design"]
                                        for item in scanner:  #mrp twr time
                                            title += item.get_title()
                                        append_file(report_file,
                                                    ",".join(title))
                                    if 1:
                                        report_name, subtex = os.path.splitext(
                                            report_file)
                                        report_file_mrp = report_name + '_mrp' + subtex
                                        if not_exists(report_file_mrp):
                                            title = ["Design"]
                                            #for item in scanner: #mrp twr time
                                            title += (scanner[0]).get_title()
                                            append_file(
                                                report_file_mrp,
                                                ",".join(title))
                                        report_file_twr = report_name + '_twr' + subtex
                                        if not_exists(report_file_twr):
                                            title = ["Design"]
                                            #for item in scanner: #mrp twr time
                                            title += (scanner[1]).get_title()
                                            append_file(
                                                report_file_twr,
                                                ",".join(title))
                                        report_file_time = report_name + '_time_mem' + subtex
                                        if not_exists(report_file_time):
                                            title = ["Design"]
                                            #for item in scanner: #mrp twr time
                                            title += (scanner[2]).get_title()
                                            append_file(
                                                report_file_time,
                                                ",".join(title))

                                    scan_mrp.scan_report(mrp_file)
                                    scan_time.scan_map(mrp_file)
                                    par_file = os.path.join(
                                        dir_scan, foo, project_name + ".par")
                                    scan_time.scan_par(par_file)
                                    twr_file = os.path.join(
                                        dir_scan, foo, project_name + ".twr")
                                    scan_twr.scan_report(twr_file)
                                    #time_file = os.path.join(dir_scan,foo,"mpar_log.time")
                                    #scan_time.scan_report(time_file)
                                    data1 = scan_mrp.get_data()
                                    append_file(report_file_mrp,
                                                ",".join([design] + data1))
                                    data2 = scan_twr.get_data()
                                    append_file(report_file_twr,
                                                ",".join([design] + data2))
                                    data3 = scan_time.get_data()
                                    append_file(report_file_time,
                                                ",".join([design] + data3))
                                    data = data1 + data2 + data3
                                    append_file(report_file,
                                                ",".join([design] + data))

                                #for vivado
                                if not os.path.isfile(twr_file):
                                    if 1:
                                        title = ["Design"]
                                        for item in [
                                                scan_timing_rpt,
                                                scan_placed_rpt
                                        ]:  #mrp twr time
                                            title += item.get_title()
                                        if not_exists(report_file):
                                            append_file(
                                                report_file, ",".join(title))
                                        if 0:
                                            report_name, subtex = os.path.splitext(
                                                report_file)
                                            report_file_mrp = report_name + '_mrp' + subtex
                                            if not_exists(report_file_mrp):
                                                title = ["Design"]
                                                #for item in scanner: #mrp twr time
                                                title += (
                                                    scanner[0]).get_title()
                                                append_file(
                                                    report_file_mrp,
                                                    ",".join(title))
                                            report_file_twr = report_name + '_twr' + subtex
                                            if not_exists(report_file_twr):
                                                title = ["Design"]
                                                #for item in scanner: #mrp twr time
                                                title += (
                                                    scanner[1]).get_title()
                                                append_file(
                                                    report_file_twr,
                                                    ",".join(title))
                                            report_file_time = report_name + '_time_mem' + subtex
                                            if not_exists(report_file_time):
                                                title = ["Design"]
                                                #for item in scanner: #mrp twr time
                                                title += (
                                                    scanner[2]).get_title()
                                                append_file(
                                                    report_file_time,
                                                    ",".join(title))
                                    timing_rpt = os.path.join(
                                        dir_scan, foo,
                                        '*timing_summary_routed.rpt')
                                    timing_rpt = get_unique_file(timing_rpt)
                                    total_data = [design]
                                    if timing_rpt:
                                        scan_timing_rpt.scan_report(timing_rpt)
                                        total_data += scan_timing_rpt.get_data(
                                        )
                                    else:
                                        total_data += ['NA'] * len(
                                            scan_timing_rpt.get_title())

                                    placed_rpt = os.path.join(
                                        dir_scan, foo,
                                        '*utilization_placed.rpt')
                                    placed_rpt = glob.glob(placed_rpt)
                                    used_rpt = ''
                                    for rpt in placed_rpt:
                                        if rpt.find('clock_utilization') != -1:
                                            continue
                                        else:
                                            used_rpt = rpt
                                            break
                                    if used_rpt:
                                        scan_placed_rpt.scan_report(used_rpt)
                                        total_data += scan_placed_rpt.get_data(
                                        )
                                    else:
                                        total_data += ['NA'] * len(
                                            scan_placed_rpt.get_title())

                                    append_file(report_file,
                                                ",".join(total_data))
                                    for_bqs_data = '<scan_case>\n'
                                    for id1, t in enumerate(title):

                                        for_bqs_data = for_bqs_data + "\t<%s>" % t + total_data[
                                            id1] + "</%s>\n" % t
                                    for_bqs_data = for_bqs_data + "</scan_case>"
                                    print '#BQS_RETRN_DATA_BEGIN#'
                                    print for_bqs_data
                                    print '#BQS_RETRN_DATA_END#'
                                recover.run()
        os.chdir(root_dir)
    for f in report_file_list:
        if os.path.isfile(f):
            file_sorted, note, design_fmax = report_sort.sort_csv(f)
            report_sort.write_note(file_sorted, note)
    #----------------update run_stand-------------------#
    if 0:
        pass_log = glob.glob('*' + syn + '_pass_case.log')
        if pass_log:
            pass_log = pass_log[0]
        else:
            pass_log = '__'
        if os.path.isfile(pass_log):
            file_hand = file(pass_log, 'r')
            lines = file_hand.readlines()
            file_hand.close()
            stand_name = glob.glob('*' + syn + '_run_standard.bat')
            if stand_name:
                stand_name = stand_name[0]
            #stand_name = os.path.join(top_base,top_base2+'_'+syn+'_run_standard.bat')
            else:
                stand_name = ''
            run_standard = file(stand_name, 'r')
            run_standard_lines = run_standard.readlines()
            run_standard.close()
            useful_lines = []
            for case in lines:
                case = case.strip()
                if not case:
                    continue
                else:
                    pass
                case_tab = '--design=' + case
                case_tab_re = re.compile(case_tab + r'(\s+|$)')
                for line in run_standard_lines:
                    line = line.strip()
                    if not line:
                        continue
                    if case_tab_re.search(line):
                        try:
                            fmax = float(design_fmax[case.strip()])
                            fmax = str(int(fmax))
                            #line = case_tab_re.sub('',line)
                            line = re.sub(r'--fmax-sweep=[\s\d]+\d', '', line)
                            line2 = line + ' --fmax-sweep=' + fmax + ' ' + fmax + ' ' + '10 \n'
                        except:
                            line2 = line

                        useful_lines.append(line2)
            run_standard = file(stand_name, 'w')
            run_standard.writelines(useful_lines)
            run_standard.close()
Exemplo n.º 9
0
def scan_report():
    opt = option()
    job_dir = opt.job_dir
    job_dir = os.path.abspath(job_dir)
    need_design = opt.design
    if not need_design:
        print 'In the bqs, you have to specify the design name'
        return
    pap = opt.pap
    report_dir = opt.report_dir
    print '--==--' * 20
    print report_dir
    print os.path.isdir(report_dir)
    print '--==--' * 20
    scan_mrp = tool_scan_lattice.ScanLatticeMrp()
    scan_twr = tool_scan_lattice.ScanLatticeTwr(pap)
    scan_time = tool_scan_lattice.ScanLatticeTime()
    target_fmax_re = re.compile(r"Target_Fmax_is_(.+)MHz")

    if os.path.isdir(job_dir):
        pass
    else:
        print 'The job_dir:%s is not a directory' % job_dir
        return
    design_path = os.path.join(job_dir, need_design)
    design_path = re.sub(r'\\', '/', design_path)
    report_file_list = []

    if 1:
        root_dir = os.getcwd()
        dir = os.path.basename(opt.job_dir)
        design = os.path.basename(design_path)
        if 1:
            scanner = (scan_mrp, scan_twr, scan_time)
            report_file = os.path.join(opt.job_dir,
                                       dir + '_' + design + '.csv')
            if report_file in report_file_list:
                pass
            else:
                report_file_list.append(report_file)
            if not_exists(report_file):
                title = ["Design"]
                for item in scanner:  #mrp twr time
                    title += item.get_title()
                append_file(report_file, ",".join(title))
            if 1:
                report_name, subtex = os.path.splitext(report_file)
                report_file_mrp = report_name + '_mrp' + subtex
                if not_exists(report_file_mrp):
                    title = ["Design"]
                    #for item in scanner: #mrp twr time
                    title += (scanner[0]).get_title()
                    append_file(report_file_mrp, ",".join(title))
                report_file_twr = report_name + '_twr' + subtex
                if not_exists(report_file_twr):
                    title = ["Design"]
                    #for item in scanner: #mrp twr time
                    title += (scanner[1]).get_title()
                    append_file(report_file_twr, ",".join(title))
                report_file_time = report_name + '_time' + subtex
                if not_exists(report_file_time):
                    title = ["Design"] + ['Target_fmax']
                    #for item in scanner: #mrp twr time
                    title += (scanner[2]).get_title()
                    append_file(report_file_time, ",".join(title))
                report_file_clock = report_name + '_clock' + subtex
                append_file(report_file_clock,
                            ",".join(['Design', 'Colck', 'Loads']))
        if 1:  # begin scan case
            if need_design:
                if design == need_design:
                    pass
                else:
                    return
            print_always('scanning %s' % design)
            srr_file = ''
            for dir in os.listdir(design_path):  # dir:Target_Fmax_is_060MHz
                dir_scan = os.path.join(design_path, dir)
                if (not re.search("Target", dir)
                    ) and os.path.isdir(dir_scan) and not srr_file:
                    srr_file = get_unique_file([dir_scan, ".srr"])
            for dir in os.listdir(design_path):  # dir:Target_Fmax_is_060MHz
                dir_scan = os.path.join(design_path, dir)
                #if (not re.search("Target", dir)) and os.path.isdir(dir_scan) and not srr_file:
                #    srr_file = get_unique_file([dir_scan, ".srr"])
                if re.search("Target", dir) and os.path.isdir(dir_scan):
                    pass
                else:
                    continue
                recover = RecoverPath(dir_scan)
                used_dir = ''
                for f_d in os.listdir(dir_scan):
                    f_d_full = os.path.join(dir_scan, f_d)
                    if os.path.isdir(f_d_full):
                        if used_dir:
                            print 'Warning: There are two implementation in the design'
                        used_dir = f_d_full
                #srr_file = get_unique_file([used_dir, ".srr"])
                if not srr_file:
                    pass
                else:
                    srr_file = os.path.join(design_path, dir, srr_file)
                    scan_time.scan_srr(srr_file)
                mrp_file = get_unique_file([used_dir, ".mrp"])
                if not_exists(mrp_file, "map report file"):

                    continue
                scan_mrp.scan_report(mrp_file)
                scan_time.scan_mrp(mrp_file)
                twr_file = time_file = par_file = ""
                target_fmax_for_time = '_'
                #------------------------------------------------#
                if 1:
                    useful_dir = used_dir
                    base_name = os.path.basename(useful_dir)
                    scan_time.reset_par_time_data()
                    target_fmax_for_match = target_fmax_re.search(dir)
                    if target_fmax_for_match:
                        target_fmax_for_time = target_fmax_for_match.group(1)
                    twr_p = os.path.join(useful_dir, '*' + base_name + ".twr")
                    twr_file = get_unique_file(twr_p)
                    if not twr_file:
                        twr_file = get_unique_file([useful_dir, ".twr"])
                    time_file = os.path.join(useful_dir, time_file)
                    par_file = get_unique_file([useful_dir, ".par"])
                    if twr_file:
                        scan_twr.scan_report(twr_file)
                        scan_time.scan_report(time_file)
                        scan_time.scan_par(par_file)
                        #########################
                        #time_title = ['design']+scan_time.get_title2()
                        srr_data = scan_time.get_srr_time_data()
                        mrp_data = scan_time.get_mrp_time_data()
                        par_data = scan_time.get_par_time_data()
                        real_cpu_total = scan_time.get_total_time()
                        all_time_data = dict(srr_data.items() +
                                             mrp_data.items() +
                                             par_data.items() +
                                             real_cpu_total.items())
                        data_list = []
                        for key in scan_time.get_title():
                            value = all_time_data.get(key, 'NA')
                            data_list.append(value)
                        data_list2 = [design] + [target_fmax_for_time
                                                 ] + data_list
                        append_file(report_file_time, ",".join(data_list2))

                        #########################
                        #data = [design] + scan_mrp.get_data() + \
                        #      scan_twr.get_data() + data_list
                        if all_time_data['Complete'] == 'NA' or all_time_data[
                                'Par_Done'] == 'NA':
                            data_list = ['_']*len(scan_mrp.get_data()) +['_']*len(scan_twr.get_data()) +\
                                        ['_']*len(data_list)
                        else:
                            data_list = scan_mrp.get_data() + \
                              scan_twr.get_data() + data_list
                        data = [design] + data_list
                        append_file(report_file, ",".join(data))
                        #-------------------
                        #report_sort_bqs.sort_csv(report_file,job_dir)
                        #-------------------
                        data = [design]
                        append_file(report_file_mrp,
                                    ",".join([design] + scan_mrp.get_data()))
                        append_file(report_file_twr,
                                    ",".join([design] + scan_twr.get_data()))
                        #append_file(report_file_time,",".join([design]+ scan_time.get_data()))
                        scan_time.reset_par_time_data()
                    if not twr_file:
                        srr_data = scan_time.get_srr_time_data()
                        mrp_data = scan_time.get_mrp_time_data()
                        par_data = scan_time.get_par_time_data()
                        real_cpu_total = scan_time.get_total_time()
                        all_time_data = dict(srr_data.items()+mrp_data.items()+par_data.items() + \
                                              real_cpu_total.items() )
                        data_list = []
                        for key in scan_time.get_title():
                            value = all_time_data.get(key, 'NA')
                            data_list.append(value)
                        data_list2 = [design] + [target_fmax_for_time
                                                 ] + data_list
                        append_file(report_file_time, ",".join(data_list2))
                        #data = [design] + scan_mrp.get_data()+ data_list
                        if all_time_data['Complete'] == 'NA' or all_time_data[
                                'Par_Done'] == 'NA':
                            data = [design] + ['_'] * len(
                                scan_mrp.get_data()) + ['_'] * len(data_list)
                        else:
                            data = [design] + scan_mrp.get_data() + data_list
                        append_file(report_file, ",".join(data))
                        #-------------------
                        #report_sort_bqs.sort_csv(report_file,job_dir)

                        #-------------------

                        append_file(report_file_mrp,
                                    ",".join([design] + scan_mrp.get_data()))
                        scan_time.reset_par_time_data()
                scan_mrp.scan_clocks(mrp_file)
                clock_dict = scan_mrp.get_parse_line_clocks()
                for key in clock_dict.keys():
                    line = design + ',' + key + ',' + clock_dict[key]
                    append_file(report_file_clock, line)
                recover.run()
        report_sort_bqs.sort_csv(report_file, report_dir)
        os.chdir(root_dir)
 def scan_report(self):
     scan_mrp = tool_scan_lattice.ScanLatticeMrp()
     scan_twr = tool_scan_lattice.ScanLatticeTwr(self.pap)
     scan_time = tool_scan_lattice.ScanLatticeTime()
     if self.family:
         for_pattern = '_'+family
     if self.synthesis:
         for_pattern = for_pattern + '_'+syn
     dir_pattern = re.compile(for_pattern)
     if os.path.isdir(self.job_dir):
         pass
     else:
         print 'Error: The job_dir:%s is not a directory'%self.job_dir
         return
     report_file_list = []
     all_designs = []
     if not self.design:
         for dir in os.listdir(job_dir):  # get all the design path
             dir2 =  os.path.join(job_dir,dir)
             if os.path.isdir(dir2):
                 all_designs.append(dir)
             else:
                 pass
     else:
         dir = os.path.join(job_dir,self.design)
         if os.path.isdir(dir):
             all_designs.append(dir)
         else:
             print 'Error: Can not find case:%s'%self.design
     root_dir = os.getcwd()
     for design in all_designs:
         print_always( 'scanning %s'%design)
         design_path = os.path.join(job_dir,design)
         for dir in os.listdir(design_path):
             if dir_pattern.search(dir) and os.path.isdir(os.path.join(design_path,dir)) and dir.startswith('_'):
                 #####################
                 scanner = (scan_mrp, scan_twr, scan_time)
                 report_file = self.report_file
                 if report_file in report_file_list:
                     pass
                 else:
                     report_file_list.append(report_file)
                 if not_exists(report_file):
                     title = ["Design"]
                     for item in scanner: #mrp twr time
                         title += item.get_title()
                     append_file(report_file, ",".join(title))
                 if 1:
                     report_name,subtex = os.path.splitext(report_file)
                     report_file_mrp = report_name+'_mrp'+subtex
                     if not_exists(report_file_mrp):
                         title = ["Design"]
                         #for item in scanner: #mrp twr time
                         title += (scanner[0]).get_title()
                         append_file(report_file_mrp, ",".join(title))
                     report_file_twr = report_name+'_twr'+subtex
                     if not_exists(report_file_twr):
                         title = ["Design"]
                         #for item in scanner: #mrp twr time
                         title += (scanner[1]).get_title()
                         append_file(report_file_twr, ",".join(title))
                     report_file_time = report_name+'_time'+subtex
                     if not_exists(report_file_time):
                         title = ["Design"] +['Target_fmax']
                         #for item in scanner: #mrp twr time
                         title += (scanner[2]).get_title()
                         append_file(report_file_time, ",".join(title))
                     report_file_clock = report_name+'_clock'+subtex
                     if not_exists(report_file_clock):
                         append_file(report_file_clock, ",".join(['Design','Colck','Loads']))
            
                 dir_scan = os.path.join(design_path,dir)
                 recover = RecoverPath(dir_scan)
                 if not_exists('rev_1', "srr file directory"):
                     continue
                 srr_file = get_unique_file([os.path.join(design_path,dir,'rev_1'), ".srr"])
                 if not srr_file:
                     pass
                 else:
                     srr_file = os.path.join(design_path,dir,'rev_1',srr_file) 
                     scan_time.scan_srr(srr_file)
                 _project_name = "%s_%s" % (dir, design[:7])
                 project_name = _project_name.strip("_")
                 mrp_file = project_name + ".mrp"
                 if not_exists(mrp_file, "map report file"):
                     continue
                 scan_mrp.scan_report(mrp_file)
                 scan_time.scan_mrp(mrp_file)
                 twr_file = time_file = par_file= ""
                 target_fmax_for_time = '_'
                 target_fmax_re = re.compile(r"Target_Fmax_is_(.+)MHz")
                 for foo in os.listdir("."):
                     if os.path.isdir(foo):
                         if re.search("Target", foo):
                             scan_time.reset_par_time_data()
                             print_always("  Scanning %s" % foo)
                             target_fmax_for_match = target_fmax_re.search(foo)
                             if target_fmax_for_match:
                                 target_fmax_for_time = target_fmax_for_match.group(1)
                             twr_file = get_unique_file([foo, ".twr"])
                             time_file = os.path.join(foo, time_file)
                             par_file = get_unique_file([foo, ".par"])
                         elif re.search("\.dir$", foo):
                             twr_file = get_unique_file([foo, ".twr"])
                             par_file = get_unique_file([foo, ".par"])
                             time_file = time_file
                         else:
                             continue
         
                         if twr_file:
                             scan_twr.scan_report(twr_file)
                             scan_time.scan_report(time_file)
                             scan_time.scan_par(par_file)
                             #########################
                             #time_title = ['design']+scan_time.get_title2()
                             srr_data = scan_time.get_srr_time_data()
                             mrp_data = scan_time.get_mrp_time_data()
                             par_data = scan_time.get_par_time_data()
                             real_cpu_total = scan_time.get_total_time()
                             all_time_data = dict(srr_data.items()+mrp_data.items()+par_data.items() + real_cpu_total.items() )
                             data_list = []
                             for key in scan_time.get_title():
                                 value = all_time_data.get(key,'NA')
                                 data_list.append(value)
                             data_list2 = [design]+[target_fmax_for_time] +data_list
                             append_file(report_file_time,",".join(data_list2))
                                 
                             #########################
                             #data = [design] + scan_mrp.get_data() + \
                             #      scan_twr.get_data() + data_list
                             if all_time_data['Complete'] == 'NA' or all_time_data['Par_Done'] == 'NA':
                                 data_list = ['_']*len(scan_mrp.get_data()) +['_']*len(scan_twr.get_data()) +\
                                             ['_']*len(data_list)
                             else:
                                 data_list = scan_mrp.get_data() + \
                                   scan_twr.get_data() + data_list
                             data = [design] + data_list
                             append_file(report_file, ",".join(data))
                             data = [design]
                             append_file(report_file_mrp,",".join([design]+ scan_mrp.get_data() ))
                             append_file(report_file_twr,",".join([design]+ scan_twr.get_data() ))
                             #append_file(report_file_time,",".join([design]+ scan_time.get_data()))
                             scan_time.reset_par_time_data()
                         if not twr_file:
                             srr_data = scan_time.get_srr_time_data()
                             mrp_data = scan_time.get_mrp_time_data()
                             par_data = scan_time.get_par_time_data()
                             real_cpu_total = scan_time.get_total_time()
                             all_time_data = dict(srr_data.items()+mrp_data.items()+par_data.items() + \
                                                   real_cpu_total.items() )
                             data_list = []
                             for key in scan_time.get_title():
                                 value = all_time_data.get(key,'NA')
                                 data_list.append(value)
                             data_list2 = [design]+[target_fmax_for_time] +data_list
                             append_file(report_file_time,",".join(data_list2))
                             #data = [design] + scan_mrp.get_data()+ data_list
                             if all_time_data['Complete'] == 'NA' or all_time_data['Par_Done'] == 'NA':
                                 data = [design] + ['_']*len(scan_mrp.get_data())+  ['_']*len(data_list)
                             else:
                                 data = [design] + scan_mrp.get_data()+ data_list
                             append_file(report_file, ",".join(data))
                             append_file(report_file_mrp,",".join([design]+ scan_mrp.get_data()))
                             scan_time.reset_par_time_data()
                 scan_mrp.scan_clocks(mrp_file)
                 clock_dict = scan_mrp.get_parse_line_clocks()
                 for key in clock_dict.keys():
                     line = design+','+key+','+clock_dict[key]
                     append_file(report_file_clock,line)
                 recover.run()
         
     os.chdir(root_dir)
def scan_report():
    opt = option()
    job_dir = opt.job_dir
    design = opt.design
    syn = opt.synthesis
    #syn = ''
    family = opt.family
    report_name = opt.report_name #this is useless now
    for_pattern=''
    pap = opt.pap
    scan_mrp = tool_scan_lattice.ScanLatticeMrp()
    scan_twr = tool_scan_lattice.ScanLatticeTwr(pap)
    scan_time = tool_scan_lattice.ScanLatticeTime()
    if family:
        for_pattern = '_'+family
    if syn:
        for_pattern = for_pattern + '_'+syn
    dir_pattern = re.compile(for_pattern)
    
    all_designs = []
    if os.path.isdir(job_dir):
        pass
    else:
        print 'The job_dir:%s is not a directory'%job_dir
        return
    for dir in os.listdir(job_dir):  # get all the design path
        dir2 =  os.path.join(job_dir,dir)
        if os.path.isdir(dir2):
            all_designs.append(dir)
        else:
            pass
    report_file_list = []
    if design:
        print_always( 'scanning %s'%design)
        if design in all_designs:
            design_path = os.path.join(job_dir,design)
            for dir in os.listdir(design_path):
                if dir_pattern.search(dir) and os.path.isdir(os.path.join(design_path,dir)) and dir.startswith('_'):
                    #####################
                    scanner = (scan_mrp, scan_twr, scan_time)
                    report_file = os.path.join(opt.job_dir,dir+'.csv')
                    report_file_list.append(report_file)
                    if not_exists(report_file):
                        title = ["Design"]
                        for item in scanner: #mrp twr time
                            title += item.get_title()
                        append_file(report_file, ",".join(title))
                    if 1:
                        report_name,subtex = os.path.splitext(report_file)
                        report_file_mrp = report_name+'_mrp'+subtex
                        if not_exists(report_file_mrp):
                            title = ["Design"]
                            #for item in scanner: #mrp twr time
                            title += (scanner[0]).get_title()
                            append_file(report_file_mrp, ",".join(title))
                        report_file_twr = report_name+'_twr'+subtex
                        if not_exists(report_file_twr):
                            title = ["Design"]
                            #for item in scanner: #mrp twr time
                            title += (scanner[1]).get_title()
                            append_file(report_file_twr, ",".join(title))
                        report_file_time = report_name+'_time'+subtex
                        if not_exists(report_file_time):
                            title = ["Design"] +['Target_fmax']
                            #for item in scanner: #mrp twr time
                            title += (scanner[2]).get_title()
                            append_file(report_file_time, ",".join(title))
                        report_file_clock = report_name+'_clock'+subtex
                        if not_exists(report_file_clock):
                            append_file(report_file_clock, ",".join(['Design','Colck','Loads']))
                ######################
                    dir_scan = os.path.join(design_path,dir)
                    recover = RecoverPath(dir_scan)
                    if not_exists('rev_1', "srr file directory"):
                        continue
                    srr_file = get_unique_file([os.path.join(design_path,dir,'rev_1'), ".srr"])
                    if srr_file:
                        srr_file = os.path.join(design_path,dir,'rev_1',srr_file) 
                        scan_time.scan_srr(srr_file)
                    _project_name = "%s_%s" % (dir, design[:7])
                    project_name = _project_name.strip("_")
                    mrp_file = project_name + ".mrp"
                    if not_exists(mrp_file, "map report file"):
                        continue
                    scan_mrp.scan_report(mrp_file)
                    scan_time.scan_mrp(mrp_file)
                    twr_file = time_file = par_file= ""
                    target_fmax_for_time = '_'
                    target_fmax_re = re.compile(r"Target_Fmax_is_(.+)MHz")
                    for foo in os.listdir("."):
                        if os.path.isdir(foo):
                            if re.search("Target", foo):
                                print_always("  Scanning %s" % foo)
                                target_fmax_for_match = target_fmax_re.search(foo)
                                if target_fmax_for_match:
                                    target_fmax_for_time = target_fmax_for_match.group(1)
                                twr_file = get_unique_file([foo, ".twr"])
                                time_file = os.path.join(foo, time_file)
                                par_file = get_unique_file([foo, ".par"])
                            elif re.search("\.dir$", foo):
                                twr_file = get_unique_file([foo, ".twr"])
                                par_file = get_unique_file([foo, ".par"])
                                time_file = time_file
                            else:
                                continue
            
                            if twr_file:
                                scan_twr.scan_report(twr_file)
                                scan_time.scan_report(time_file)
                                scan_time.scan_par(par_file)
                                #########################
                                #time_title = ['design']+scan_time.get_title2()
                                srr_data = scan_time.get_srr_time_data()
                                mrp_data = scan_time.get_mrp_time_data()
                                par_data = scan_time.get_par_time_data()
                                real_cpu_total = scan_time.get_total_time()
                                all_time_data = dict(srr_data.items()+mrp_data.items()+par_data.items() + real_cpu_total.items() )
                                data_list = []
                                for key in scan_time.get_title():
                                    value = all_time_data.get(key,'NA')
                                    data_list.append(value)
                                data_list2 = [design]+[target_fmax_for_time] +data_list
                                append_file(report_file_time,",".join(data_list2))
                                    
                                #########################
                                if all_time_data['Complete'] == 'NA' or all_time_data['Par_Done'] == 'NA':
                                    data_list = ['_']*len(scan_mrp.get_data()) +['_']*len(scan_twr.get_data()) + ['_']*len(data_list)
                                else:
                                    data_list = scan_mrp.get_data() + \
                                      scan_twr.get_data() + data_list
                                data = [design] + data_list
                                append_file(report_file, ",".join(data))
                                data = [design]
                                append_file(report_file_mrp,",".join([design]+ scan_mrp.get_data() ))
                                append_file(report_file_twr,",".join([design]+ scan_twr.get_data() ))
                                #append_file(report_file_time,",".join([design]+ scan_time.get_data()))
                            if not twr_file:
                                srr_data = scan_time.get_srr_time_data()
                                mrp_data = scan_time.get_mrp_time_data()
                                par_data = scan_time.get_par_time_data()
                                real_cpu_total = scan_time.get_total_time()
                                all_time_data = dict(srr_data.items()+mrp_data.items()+par_data.items() + real_cpu_total.items() )
                                data_list = []
                                for key in scan_time.get_title():
                                    value = all_time_data.get(key,'NA')
                                    data_list.append(value)
                                data_list2 = [design]+[target_fmax_for_time] +data_list
                                append_file(report_file_time,",".join(data_list2))
                                
                                if all_time_data['Complete'] == 'NA' or all_time_data['Par_Done'] == 'NA':
                                    data = [design] + ['_']*len(scan_mrp.get_data())+ ['_']*len(data_list)
                                else:
                                    data = [design] + scan_mrp.get_data()+ data_list
                                append_file(report_file, ",".join(data))
                                append_file(report_file_mrp,",".join([design]+ scan_mrp.get_data()))
                    scan_mrp.scan_clocks(mrp_file)
                    clock_dict = scan_mrp.get_parse_line_clocks()
                    for key in clock_dict.keys():
                        line = design+','+key+','+clock_dict[key]
                        append_file(report_file_clock,line)
                    
        else:
            print 'The design is not exists in the job_dir'
            return
    
    else:
        root_dir = os.getcwd()
        for design in all_designs:
            print_always( 'scanning %s'%design)
            design_path = os.path.join(job_dir,design)
            for dir in os.listdir(design_path):
                if dir_pattern.search(dir) and os.path.isdir(os.path.join(design_path,dir)) and dir.startswith('_'):
                    #####################
                    scanner = (scan_mrp, scan_twr, scan_time)
                    report_file = os.path.join(opt.job_dir,dir+'.csv')
                    if report_file in report_file_list:
                        pass
                    else:
                        report_file_list.append(report_file)
                    if not_exists(report_file):
                        title = ["Design"]
                        for item in scanner: #mrp twr time
                            title += item.get_title()
                        append_file(report_file, ",".join(title))
                    if 1:
                        report_name,subtex = os.path.splitext(report_file)
                        report_file_mrp = report_name+'_mrp'+subtex
                        if not_exists(report_file_mrp):
                            title = ["Design"]
                            #for item in scanner: #mrp twr time
                            title += (scanner[0]).get_title()
                            append_file(report_file_mrp, ",".join(title))
                        report_file_twr = report_name+'_twr'+subtex
                        if not_exists(report_file_twr):
                            title = ["Design"]
                            #for item in scanner: #mrp twr time
                            title += (scanner[1]).get_title()
                            append_file(report_file_twr, ",".join(title))
                        report_file_time = report_name+'_time'+subtex
                        if not_exists(report_file_time):
                            title = ["Design"] +['Target_fmax']
                            #for item in scanner: #mrp twr time
                            title += (scanner[2]).get_title()
                            append_file(report_file_time, ",".join(title))
                        report_file_clock = report_name+'_clock'+subtex
                        append_file(report_file_clock, ",".join(['Design','Colck','Loads']))
                ######################
                    dir_scan = os.path.join(design_path,dir)
                    recover = RecoverPath(dir_scan)
                    if not_exists('rev_1', "srr file directory"):
                        
                        continue
                    srr_file = get_unique_file([os.path.join(design_path,dir,'rev_1'), ".srr"])
                    if not srr_file:
                        pass
                    else:
                        srr_file = os.path.join(design_path,dir,'rev_1',srr_file) 
                        scan_time.scan_srr(srr_file)
                    _project_name = "%s_%s" % (dir, design[:7])
                    project_name = _project_name.strip("_")
                    mrp_file = project_name + ".mrp"
                    if not_exists(mrp_file, "map report file"):
                        
                        continue
                    scan_mrp.scan_report(mrp_file)
                    scan_time.scan_mrp(mrp_file)
                    twr_file = time_file = par_file= ""
                    target_fmax_for_time = '_'
                    target_fmax_re = re.compile(r"Target_Fmax_is_(.+)MHz")
                    for foo in os.listdir("."):
                        if os.path.isdir(foo):
                            if re.search("Target", foo):
                                scan_time.reset_par_time_data()
                                print_always("  Scanning %s" % foo)
                                target_fmax_for_match = target_fmax_re.search(foo)
                                if target_fmax_for_match:
                                    target_fmax_for_time = target_fmax_for_match.group(1)
                                twr_file = get_unique_file([foo, ".twr"])
                                time_file = os.path.join(foo, time_file)
                                par_file = get_unique_file([foo, ".par"])
                            elif re.search("\.dir$", foo):
                                twr_file = get_unique_file([foo, ".twr"])
                                par_file = get_unique_file([foo, ".par"])
                                time_file = time_file
                            else:
                                continue
            
                            if twr_file:
                                scan_twr.scan_report(twr_file)
                                scan_time.scan_report(time_file)
                                scan_time.scan_par(par_file)
                                #########################
                                #time_title = ['design']+scan_time.get_title2()
                                srr_data = scan_time.get_srr_time_data()
                                mrp_data = scan_time.get_mrp_time_data()
                                par_data = scan_time.get_par_time_data()
                                real_cpu_total = scan_time.get_total_time()
                                all_time_data = dict(srr_data.items()+mrp_data.items()+par_data.items() + real_cpu_total.items() )
                                data_list = []
                                for key in scan_time.get_title():
                                    value = all_time_data.get(key,'NA')
                                    data_list.append(value)
                                data_list2 = [design]+[target_fmax_for_time] +data_list
                                append_file(report_file_time,",".join(data_list2))
                                    
                                #########################
                                #data = [design] + scan_mrp.get_data() + \
                                #      scan_twr.get_data() + data_list
                                if all_time_data['Complete'] == 'NA' or all_time_data['Par_Done'] == 'NA':
                                    data_list = ['_']*len(scan_mrp.get_data()) +['_']*len(scan_twr.get_data()) +\
                                                ['_']*len(data_list)
                                else:
                                    data_list = scan_mrp.get_data() + \
                                      scan_twr.get_data() + data_list
                                data = [design] + data_list
                                append_file(report_file, ",".join(data))
                                data = [design]
                                append_file(report_file_mrp,",".join([design]+ scan_mrp.get_data() ))
                                append_file(report_file_twr,",".join([design]+ scan_twr.get_data() ))
                                #append_file(report_file_time,",".join([design]+ scan_time.get_data()))
                                scan_time.reset_par_time_data()
                            if not twr_file:
                                srr_data = scan_time.get_srr_time_data()
                                mrp_data = scan_time.get_mrp_time_data()
                                par_data = scan_time.get_par_time_data()
                                real_cpu_total = scan_time.get_total_time()
                                all_time_data = dict(srr_data.items()+mrp_data.items()+par_data.items() + \
                                                      real_cpu_total.items() )
                                data_list = []
                                for key in scan_time.get_title():
                                    value = all_time_data.get(key,'NA')
                                    data_list.append(value)
                                data_list2 = [design]+[target_fmax_for_time] +data_list
                                append_file(report_file_time,",".join(data_list2))
                                #data = [design] + scan_mrp.get_data()+ data_list
                                if all_time_data['Complete'] == 'NA' or all_time_data['Par_Done'] == 'NA':
                                    data = [design] + ['_']*len(scan_mrp.get_data())+  ['_']*len(data_list)
                                else:
                                    data = [design] + scan_mrp.get_data()+ data_list
                                append_file(report_file, ",".join(data))
                                append_file(report_file_mrp,",".join([design]+ scan_mrp.get_data()))
                                scan_time.reset_par_time_data()
                    scan_mrp.scan_clocks(mrp_file)
                    clock_dict = scan_mrp.get_parse_line_clocks()
                    for key in clock_dict.keys():
                        line = design+','+key+','+clock_dict[key]
                        append_file(report_file_clock,line)
                    recover.run()
            
        os.chdir(root_dir)
    for f in report_file_list:
        if os.path.isfile(f):
            file_sorted,note,design_fmax = report_sort.sort_csv(f)
            report_sort.write_note(file_sorted,note)
    #----------------update run_stand-------------------#
    pass_log = glob.glob('*'+syn+'_pass_case.log')
    if pass_log:
        pass_log = pass_log[0]
    else:
        pass_log = '__'
    if os.path.isfile(pass_log):
        file_hand = file(pass_log,'r')
        lines = file_hand.readlines()
        file_hand.close()
        stand_name = glob.glob('*'+syn+'_run_standard.bat')
        if stand_name:
            stand_name = stand_name[0]
        #stand_name = os.path.join(top_base,top_base2+'_'+syn+'_run_standard.bat')
        else:
            stand_name = ''
        run_standard = file(stand_name,'r')
        run_standard_lines = run_standard.readlines()
        run_standard.close()
        useful_lines = []
        for case in lines:
            case = case.strip()
            if not case:
                 continue
            else:
                 pass
            case_tab = '--design='+case
            case_tab_re = re.compile(case_tab+r'(\s+|$)')
            for line in run_standard_lines:
                line = line.strip()
                if not line:
                    continue
                if case_tab_re.search(line):
                    try:
                        fmax = float( design_fmax[case.strip()] )
                        fmax = str( int( fmax ))
                    #line = case_tab_re.sub('',line)
                        line = re.sub(r'--fmax-sweep=[\s\d]+\d','',line)
                        line2 = line + ' --fmax-sweep='+fmax+' '+fmax+' '+'10 \n'
                    except:
                        line2 = line
                    useful_lines.append(line2)
        run_standard = file(stand_name,'w')
        run_standard.writelines(useful_lines)
        run_standard.close()
Exemplo n.º 12
0
def scan_report():
    opt = option()
    job_dir = opt.job_dir
    need_design = opt.design
    syn = opt.synthesis
    #syn = ''
    family = opt.family
    report_name = opt.report_name #this is useless now
    for_pattern=''
    pap = opt.pap
    scan_mrp = tool_scan_lattice.ScanLatticeMrp()
    scan_twr = tool_scan_lattice.ScanLatticeTwr(pap)
    scan_time = tool_scan_lattice.ScanLatticeTime()
    
    all_designs = []
    if os.path.isdir(job_dir):
        pass
    else:
        print 'The job_dir:%s is not a directory'%job_dir
        return
    for dir in os.listdir(job_dir):  # get all the design path
        dir2 =  os.path.join(job_dir,dir)
        if os.path.isdir(dir2):
            all_designs.append(dir)
        else:
            pass
    report_file_list = []
    
    if 1:
        root_dir = os.getcwd()
        for design in all_designs:
            if need_design:
                if design ==  need_design:
                    pass
                else:
                    continue
            print_always( 'scanning %s'%design)
            design_path = os.path.join(job_dir,design)
            if 1:
                if 1:
                    #####################
                    scanner = (scan_mrp, scan_twr, scan_time)
                    report_file = os.path.join(opt.job_dir,'aa'+'.csv')
                    if report_file in report_file_list:
                        pass
                    else:
                        report_file_list.append(report_file)
                    if not_exists(report_file):
                        title = ["Design"]
                        for item in scanner: #mrp twr time
                            title += item.get_title()
                        append_file(report_file, ",".join(title))
                    if 1:
                        report_name,subtex = os.path.splitext(report_file)
                        report_file_mrp = report_name+'_mrp'+subtex
                        if not_exists(report_file_mrp):
                            title = ["Design"]
                            #for item in scanner: #mrp twr time
                            title += (scanner[0]).get_title()
                            append_file(report_file_mrp, ",".join(title))
                        report_file_twr = report_name+'_twr'+subtex
                        if not_exists(report_file_twr):
                            title = ["Design"]
                            #for item in scanner: #mrp twr time
                            title += (scanner[1]).get_title()
                            append_file(report_file_twr, ",".join(title))
                        report_file_time = report_name+'_time'+subtex
                        if not_exists(report_file_time):
                            title = ["Design"] +['Target_fmax']
                            #for item in scanner: #mrp twr time
                            title += (scanner[2]).get_title()
                            append_file(report_file_time, ",".join(title))
                        report_file_clock = report_name+'_clock'+subtex
                        append_file(report_file_clock, ",".join(['Design','Colck','Loads']))
                ######################
                    #dir_scan = os.path.join(design_path,dir)
                    recover = RecoverPath(design_path)
                    srr_file = get_unique_file([os.path.join(design_path,'impl'), ".srr"])
                    if not srr_file:
                        pass
                    else:
                        srr_file = os.path.join(design_path,dir,'rev_1',srr_file) 
                        scan_time.scan_srr(srr_file)
                    twr_file = time_file = par_file= mrp_file = ""
                    target_fmax_for_time = '_'
                    target_fmax_re = re.compile(r"Target_Seed_is_(.+)")
                    for foo in os.listdir("."):
                        if os.path.isdir(foo):
                            if re.search("Target", foo):
                                scan_time.reset_par_time_data()
                                print_always("  Scanning %s" % foo)
                                target_fmax_for_match = target_fmax_re.search(foo)
                                if target_fmax_for_match:
                                    target_fmax_for_time = target_fmax_for_match.group(1)
                                twr_file = get_unique_file([foo, ".twr"])
                                mrp_file = get_unique_file([foo, ".mrp"])
                                scan_mrp.scan_report(mrp_file)
                                scan_time.scan_mrp(mrp_file)
                                time_file = os.path.join(foo, time_file)
                                par_file = get_unique_file([os.path.join(foo,'PrjName.dir'), ".par"])
                            elif re.search("\.dir$", foo):
                                twr_file = get_unique_file([foo, ".twr"])
                                par_file = get_unique_file([foo, ".par"])
                                time_file = time_file
                            else:
                                continue
            
                            if twr_file:
                               
                                if design.startswith('hu'):
                                    scan_twr.scan_report(twr_file,'clk_246mhz_c') ### add by yu
                                
                                elif design =='fir1c':
                                        scan_twr.scan_report(twr_file,'fir_clk_c')
                                elif design.startswith('fir'):
                                        scan_twr.scan_report(twr_file,'fir_clk')
                                elif design.startswith('config'):
                                        scan_twr.scan_report(twr_file,'clk_c')
                                else:
                                    scan_twr.scan_report(twr_file,'i_clk')
                                
                                
                                scan_time.scan_report(time_file)
                                scan_time.scan_par(par_file)
                                #########################
                                #time_title = ['design']+scan_time.get_title2()
                                srr_data = scan_time.get_srr_time_data()
                                mrp_data = scan_time.get_mrp_time_data()
                                par_data = scan_time.get_par_time_data()
                                real_cpu_total = scan_time.get_total_time()
                                all_time_data = dict(srr_data.items()+mrp_data.items()+par_data.items() + real_cpu_total.items() )
                                data_list = []
                                for key in scan_time.get_title():
                                    value = all_time_data.get(key,'NA')
                                    data_list.append(value)
                                data_list2 = [design]+[target_fmax_for_time] +data_list
                                append_file(report_file_time,",".join(data_list2))
                                    
                                #########################
                                #data = [design] + scan_mrp.get_data() + \
                                #      scan_twr.get_data() + data_list
                                if all_time_data['Complete'] == 'NA' or all_time_data['Par_Done'] == 'NA':
                                    data_list = ['_']*len(scan_mrp.get_data()) +['_']*len(scan_twr.get_data()) +\
                                                ['_']*len(data_list)
                                else:
                                    data_list = scan_mrp.get_data() + \
                                      scan_twr.get_data() + data_list
                                data = [design] + data_list
                                append_file(report_file, ",".join(data))
                                data = [design]
                                append_file(report_file_mrp,",".join([design]+ scan_mrp.get_data() ))
                                append_file(report_file_twr,",".join([design]+ scan_twr.get_data() ))
                                #append_file(report_file_time,",".join([design]+ scan_time.get_data()))
                                scan_time.reset_par_time_data()
                            if not twr_file:
                                srr_data = scan_time.get_srr_time_data()
                                mrp_data = scan_time.get_mrp_time_data()
                                par_data = scan_time.get_par_time_data()
                                real_cpu_total = scan_time.get_total_time()
                                all_time_data = dict(srr_data.items()+mrp_data.items()+par_data.items() + \
                                                      real_cpu_total.items() )
                                data_list = []
                                for key in scan_time.get_title():
                                    value = all_time_data.get(key,'NA')
                                    data_list.append(value)
                                data_list2 = [design]+[target_fmax_for_time] +data_list
                                append_file(report_file_time,",".join(data_list2))
                                #data = [design] + scan_mrp.get_data()+ data_list
                                if all_time_data['Complete'] == 'NA' or all_time_data['Par_Done'] == 'NA':
                                    data = [design] + ['_']*len(scan_mrp.get_data())+  ['_']*len(data_list)
                                else:
                                    data = [design] + scan_mrp.get_data()+ data_list
                                append_file(report_file, ",".join(data))
                                append_file(report_file_mrp,",".join([design]+ scan_mrp.get_data()))
                                scan_time.reset_par_time_data()
                    scan_mrp.scan_clocks(mrp_file)
                    clock_dict = scan_mrp.get_parse_line_clocks()
                    for key in clock_dict.keys():
                        line = design+','+key+','+clock_dict[key]
                        append_file(report_file_clock,line)
                    recover.run()
        os.chdir(root_dir)
    for f in report_file_list:
        if os.path.isfile(f):
            file_sorted,note,design_fmax = report_sort.sort_csv(f,add_average=1)
            report_sort.write_note(file_sorted,note)
Exemplo n.º 13
0
    def _get_std_devkit(self, raw_devkit, no_doubt=False):
        if not raw_devkit:
            # print_error("No devkit specified")
            return
        devkit = raw_devkit.upper()
        #
        std_devkit = self.devkit_dict.get(devkit)
        if std_devkit:  # try and get the standard DEVKIT directly, Great!
            return std_devkit
        if no_doubt:  # don't find the closest devkit
            print_error("Unknown devkit %s" % raw_devkit)
            return
        #
        raw_pty_sko = self._get_pty_sko(devkit)
        if not raw_pty_sko:
            return

        # match pty name
        std_group = dict()
        for part, part_detail in self.devkit_dict.items():
            if part_detail.get("pty") == raw_pty_sko.get("pty"):
                my_pty_sko = self._get_pty_sko(part)
                if not my_pty_sko: # never got here!
                    print_error("You MUST update scripts after checking the DiamondDevFile.xml file!")
                    return
                std_group[part] = [part_detail, my_pty_sko]
        if not std_group:
            print_error("Unknown pty name: %s in %s" %(raw_pty_sko.get("pty"), raw_devkit))
            return

        # get minimum difference number for package
        min_diff = 10000
        for part, part_detail in std_group.items():
            my_diff = abs(part_detail[1].get("pkg_int") - raw_pty_sko.get("pkg_int"))
            if my_diff <= min_diff:
                min_diff = my_diff

        # match opt, speed and minimum difference number
        for part, part_detail in std_group.items():
            std_pty_sko = part_detail[1]
            my_diff = abs(std_pty_sko.get("pkg_int") - raw_pty_sko.get("pkg_int"))
            if my_diff != min_diff:
                std_group.pop(part)  # Pop it!
                continue
            pop_it = 0
            for item in ("short_opt", "speed", "short_pkg"):
                if std_pty_sko.get(item) != raw_pty_sko.get(item):
                    pop_it = 1
                    break
            if pop_it:
                std_group.pop(part)

        len_std = len(std_group)
        if not len_std:
            print_error("Not found opt_name/speed/pkg_name for %s" % raw_devkit)
        elif len_std > 1:
            print_always("Warning. more than one standard devkit for %s" % raw_devkit)

        for part, part_detail in std_group.items():
            print_always("Convert devkit %s --> %s" % (raw_devkit, part))
            return part_detail[0]
def scan_report():
    opt = option()
    job_dir = opt.job_dir
    report_name = opt.report_name  #this is useless now
    scan_mrp = tool_scan_xilinx_temp.ScanXilinxMrp()
    scan_twr = tool_scan_xilinx_temp.ScanXilinxTwr()
    scan_time = tool_scan_xilinx_temp.ScanXilinxTimeMem()

    all_designs = []
    if os.path.isdir(job_dir):
        pass
    else:
        print 'The job_dir:%s is not a directory' % job_dir
        return
    for dir in os.listdir(job_dir):  # get all the design path
        dir2 = os.path.join(job_dir, dir)
        if os.path.isdir(dir2):
            all_designs.append(dir)
        else:
            pass
    report_file_list = []
    if 0:
        pass
    else:
        root_dir = os.getcwd()
        for design in all_designs:
            design_path = os.path.join(job_dir, design)
            for dir in os.listdir(design_path):
                if os.path.isdir(os.path.join(design_path, dir)):
                    #####################
                    scanner = (scan_mrp, scan_twr, scan_time)
                    report_file = os.path.join(job_dir, dir + '.csv')
                    report_file_list.append(report_file)
                    if not_exists(report_file):
                        title = ["Design"]
                        for item in scanner:  #mrp twr time
                            title += item.get_title()
                        append_file(report_file, ",".join(title))
                    if 1:
                        report_name, subtex = os.path.splitext(report_file)
                        report_file_mrp = report_name + '_mrp' + subtex
                        if not_exists(report_file_mrp):
                            title = ["Design"]
                            #for item in scanner: #mrp twr time
                            title += (scanner[0]).get_title()
                            append_file(report_file_mrp, ",".join(title))
                        report_file_twr = report_name + '_twr' + subtex
                        if not_exists(report_file_twr):
                            title = ["Design"]
                            #for item in scanner: #mrp twr time
                            title += (scanner[1]).get_title()
                            append_file(report_file_twr, ",".join(title))
                        report_file_time = report_name + '_time_mem' + subtex
                        if not_exists(report_file_time):
                            title = ["Design"]
                            #for item in scanner: #mrp twr time
                            title += (scanner[2]).get_title()
                            append_file(report_file_time, ",".join(title))
                    for dir2 in os.listdir(os.path.join(design_path, dir)):
                        dir_scan = os.path.join(design_path, dir, dir2)
                        if os.path.isdir(dir_scan):
                            pass
                        else:
                            continue
                        print dir_scan
                        twr_file = time_file = ""
                        if 'rev_1' in os.listdir(os.path.join(
                                design_path, dir)):
                            scan_time.set_srr_data()
                            foo = os.path.join(dir_scan, '*.srr')
                            srr_file = get_unique_file(foo)
                            if srr_file:
                                scan_time.scan_srr(srr_file)

                        if 1:
                            foo = dir2
                            if 1:
                                if re.search("Target", foo):
                                    recover = RecoverPath(dir_scan)
                                    scan_mrp.reset()
                                    #scan_time.reset()
                                    scan_time.set_map_data()
                                    scan_time.set_par_data()
                                    scan_twr.reset()
                                    print_always("  Scanning %s" % foo)
                                    _project_name = "%s_%s" % (dir, design[:7])
                                    project_name = _project_name.strip("_")
                                    mrp_file = os.path.join(
                                        dir_scan, project_name + "_map.mrp")
                                    scan_mrp.scan_report(mrp_file)
                                    scan_time.scan_map(mrp_file)
                                    par_file = os.path.join(
                                        dir_scan, project_name + ".par")
                                    scan_time.scan_par(par_file)
                                    twr_file = os.path.join(
                                        dir_scan, project_name + ".twr")
                                    scan_twr.scan_report_temp(twr_file)
                                    #time_file = os.path.join(dir_scan,foo,"mpar_log.time")
                                    #scan_time.scan_report(time_file)
                                    data1 = scan_mrp.get_data()
                                    append_file(report_file_mrp,
                                                ",".join([design] + data1))
                                    data2 = scan_twr.get_data()
                                    append_file(report_file_twr,
                                                ",".join([design] + data2))
                                    data3 = scan_time.get_data()
                                    append_file(report_file_time,
                                                ",".join([design] + data3))
                                    data = data1 + data2 + data3
                                    append_file(report_file,
                                                ",".join([design] + data))
                                    recover.run()

        os.chdir(root_dir)
    for f in report_file_list:
        if os.path.isfile(f):
            file_sorted, note, design_fmax = report_sort_temp.sort_csv(
                f, col_key='PAP', add_average=1)
            report_sort_temp.write_note(file_sorted, note)
def scan_report():
    opt = option()
    scanner = (tool_scan_altera.ScanAlteraFit(), tool_scan_altera.ScanAlteraFmax())
    job_dir = opt.job_dir
    if not os.path.isdir(job_dir):
        print 'Error, can not get directory:%s'%job_dir
        return -1
    design = opt.design
    tag = opt.special_structure
    report_name = opt.report_name #this is useless now
    if report_name == 'report.csv':
        report_file = os.path.basename(job_dir)+'.csv'
    report_path = opt.report_path
    if not report_path:
        report_path = job_dir
    report_file = os.path.join(report_path,report_file)
    scan_fit = tool_scan_altera.ScanAlteraFit()
    scan_fmax =  tool_scan_altera.ScanAlteraFmax()
    scan_time_mem = tool_scan_altera.ScanTimeMem()
    all_designs = []
    if not design:
        if os.path.isdir(job_dir):
            pass
        else:
            print 'The job_dir:%s is not a directory'%job_dir
            return
        for dir in os.listdir(job_dir):  # get all the design path
            dir2 =  os.path.join(job_dir,dir)
            if os.path.isdir(dir2):
                all_designs.append(dir)
            else:
                pass
    else:
        all_designs.append(design)
    report_file_list = []
    if 1:
        root_dir = os.getcwd()
        title = ["Design"]
        for item in (scan_fit,scan_fmax,scan_time_mem): #mrp twr time
            title += item.get_title()
        append_file(report_file, ",".join(title))
        global_title = title
        for design in all_designs:
            print_always( 'scanning %s'%design)
            design_path = os.path.join(job_dir,design)
            for dir in os.listdir(design_path): #at here dir should be as "_cyclone4_syn"
                if dir == tag:
                    #####################
                    scanner = (scan_fit, scan_fmax,scan_time_mem)
                    
                    report_file_list.append(report_file)
                    if not_exists(report_file):
                        append_file(report_file, ",".join(global_title))
                    if 1:
                        report_name,subtex = os.path.splitext(report_file)
                        report_file_fit = report_name+'_fit'+subtex
                        if not_exists(report_file_fit):
                            title = ["Design"]
                            #for item in scanner: #mrp twr time
                            title += (scanner[0]).get_title()
                            append_file(report_file_fit, ",".join(title))
                        report_file_sta = report_name+'_sta'+subtex
                        if not_exists(report_file_sta):
                            title = ["Design"]
                            #for item in scanner: #mrp twr time
                            title += (scanner[1]).get_title()
                            append_file(report_file_sta, ",".join(title))
                        report_file_time_mem = report_name+'_time_mem'+subtex
                        if not_exists(report_file_time_mem):
                            title = ["Design"]
                            title += (scanner[2]).get_title()
                            append_file(report_file_time_mem, ",".join(title))  
                ######################
                    dir_scan = os.path.join(design_path,dir)
                    recover = RecoverPath(dir_scan) 
                    fit_file = sta_file = map_file = srr_file =  ""
                    
                    if 'rev_1' in os.listdir('.'): # this part used to scan srr if run synthesis with synpro
                        scan_time_mem.reset()
                        foo = os.path.join(dir_scan,'rev_1')
                        srr_file = get_unique_file(foo+'/'+'*.srr')
                        if srr_file:
                            scan_time_mem.scan_srr(srr_file)
                    
                    for foo in os.listdir("."):
                        data = []
                        if os.path.isdir(foo):
                            if re.search("Target", foo):
                                scan_fit.reset()
                                scan_fmax.reset()
                                scan_time_mem.set_fit_data()
                                scan_time_mem.set_map_data()
                                print_always("  Scanning %s" % foo)
                                fit_file = get_unique_file(foo+'/'+"*.fit.rpt")
                                sta_file = get_unique_file(foo+'/'+"*.sta.rpt")
                                map_file = get_unique_file(foo+'/'+'*.map.rpt')
                                if fit_file:
                                    scan_fit.scan_report(fit_file)
                                    #raw_input(1)
                                    scan_time_mem.scan_fit(fit_file)
                                    #raw_input(2)
                                    data1=[design]+scan_fit.get_data()
                                    append_file(report_file_fit, ",".join(data1))
                                    data = data + data1
                                else:
                                    data1=[design]+['NA']*len(scan_fit.get_title() )
                                    data = data + data1
                                    print 'AA'
                                if sta_file:
                                    scan_fmax.scan_report(sta_file)
                                    #raw_input(3)
                                    data2=[design]+scan_fmax.get_data()
                                    append_file(report_file_sta, ",".join(data2))
                                    data = data + data2[1:]
                                else:
                                    data1=['NA']*len(scan_fmax.get_title() )
                                    data = data + data1
                                if map_file:
                                    scan_time_mem.scan_map(map_file)
                                    #raw_input(4)
                                    scan_t_m = scan_time_mem.get_data()
                                    append_file(report_file_time_mem, ",".join([design]+scan_t_m))
                                    data  = data + scan_t_m
                                else:
                                    data1=['NA']*len(scan_time_mem.get_title() )
                                    data = data + data1
                                append_file(report_file, ",".join(data))
                                for_bqs_data = '<scan_case>\n'
                                for id1, t in enumerate( global_title):
                                    for_bqs_data = for_bqs_data + "\t<%s>"%t+data[id1]+"</%s>\n"%t
                                for_bqs_data = for_bqs_data +"</scan_case>"
                                print '#BQS_RETRN_DATA_BEGIN#'
                                print for_bqs_data
                                print '#BQS_RETRN_DATA_END#'
                    recover.run()
        os.chdir(root_dir) 
    #report_file_list = []    
    for f in report_file_list:
        if os.path.isfile(f):
            file_sorted,note,design_fmax = report_sort.sort_csv(f)
            report_sort.write_note(file_sorted,note)
    #----------------update run_stand-------------------#
    if 0:
        pass_log = glob.glob('*'+syn+'_pass_case.log')
        if pass_log:
            pass_log = pass_log[0]
        else:
            pass_log = '__'
        if os.path.isfile(pass_log):
            file_hand = file(pass_log,'r')
            lines = file_hand.readlines()
            file_hand.close()
            stand_name = glob.glob('*'+syn+'_run_standard.bat')
            if stand_name:
                stand_name = stand_name[0]
            #stand_name = os.path.join(top_base,top_base2+'_'+syn+'_run_standard.bat')
            else:
                stand_name = ''
            run_standard = file(stand_name,'r')
            run_standard_lines = run_standard.readlines()
            run_standard.close()
            useful_lines = []
            for case in lines:
                case = case.strip()
                if not case:
                     continue
                else:
                     pass
                case_tab = '--design='+case
                case_tab_re = re.compile(case_tab+r'(\s+|$)')
                for line in run_standard_lines:
                    line = line.strip()
                    if not line:
                        continue
                    if case_tab_re.search(line):
                        try:
                            fmax = float( design_fmax[case.strip()] )
                            fmax = str( int( fmax ))
                        #line = case_tab_re.sub('',line)
                            line = re.sub(r'--fmax-sweep=[\s\d]+\d','',line)
                            line2 = line + ' --fmax-sweep='+fmax+' '+fmax+' '+'10 \n'
                        except:
                            line2 = line
                        
                        useful_lines.append(line2)
            run_standard = file(stand_name,'w')
            run_standard.writelines(useful_lines)
            run_standard.close()