예제 #1
0
def print_module_trace():
    cursor_inf = get_cur_cursor_inf()
    # get cur module name
    cur_module_name = ''
    cur_module_inf = None
    cur_line_inf = FileInfLib.get_file_line_inf(cursor_inf['line_num'],
                                                cursor_inf['file_path'])
    if cur_line_inf:
        cur_module_inf = cur_line_inf['module_inf']
    if not cur_module_inf:
        PrintReport('Note: current cursor not in valid module, do-nothing !')
        return
    cur_module_name = cur_module_inf['module_name']
    # recursion get all trace
    full_traces = []
    FileInfLib.recursion_get_module_trace(cur_module_name, [], full_traces)
    print_strs = []
    i_offset = 0  # used to control multi same trace case
    for i, traces in enumerate(full_traces):
        c_trace_strs = [traces[-1]['cur_module_name']]
        for t in traces[::-1]:
            c_str = '%s(%s)' % (t['instance_name'], t['submodule_name'])
            if c_str not in c_trace_strs:
                c_trace_strs.append(c_str)
            else:
                i_offset -= 1
        print_strs.append('%d : %s' %
                          (i + i_offset, ' -> '.join(c_trace_strs)))
    mounted_line_list = MountPrintLines(print_strs,
                                        label='Module Trace')['line_list']
    mounted_line_list.append('')
    mounted_line_list.append('')
    PrintReport(mounted_line_list, MountPrint=True)
    # edit_vim_buffer_and_file_link(G['Report_Inf']['Report_Path'], mounted_line_list)
    return
예제 #2
0
def get_full_module_inf(module_name):
    # valid when has vtags.db
    if not G['OfflineActive']:
        print('Error: no vtags.db found !')
        return {}
    # get pre module inf no subcall list
    cur_module_inf = FileInfLib.get_module_inf(module_name)
    if not cur_module_inf:
        print('Error: module %s not found! \n' % (module_name))
        return {}
    if cur_module_inf.setdefault('subcall_instance_list', None) == None:
        assert (
            FileInfLib.module_inf_add_subcall_instance_list(cur_module_inf))
    # give a copy of module_inf incase someone change it
    return copy.deepcopy(cur_module_inf)
예제 #3
0
def print_module_trace(to_module, from_module = None):
    full_traces = []
    FileInfLib.recursion_get_module_trace(to_module, [], full_traces)
    print_strs = []
    i_offset = 0 # used to control multi same trace case
    for i, traces in enumerate(full_traces):
        c_trace_strs = [ traces[-1]['cur_module_name'] ]
        for t in traces[::-1]:
            c_str = '%s(%s)'%(t['instance_name'], t['submodule_name'])
            if c_str not in c_trace_strs:
                c_trace_strs.append(c_str)
            else:
                i_offset -= 1
        print_strs.append( '%d : %s'%(i + i_offset, ' -> '.join(c_trace_strs) ) )
    MountPrintLines(print_strs, label = 'Module Trace', Print = True)
예제 #4
0
파일: FrameLib.py 프로젝트: jimmysitu/vtags
def fold_frame_line(frame_line,
                    cur_frame_level,
                    cur_frame_type,
                    cur_module_name=''):
    assert (G['Frame_Inf']['Frame_Path'] in G['VimBufferLineFileLink'])
    G['VimBufferLineFileLink'][G['Frame_Inf']['Frame_Path']][frame_line][
        'action_parm_dic']['fold_status'] = 'on'
    if cur_frame_type == 'topo':
        # if cur is ModuleTopo: line, show refresh topo
        if cur_frame_level == G['TopoInf']['TopFoldLevel'] - 1:
            topo_module_name = G['TopoInf']['CurModule']
            show_topo(topo_module_name)
            return
        if not cur_module_name:
            PrintReport('Note: cur topo line has no module name !')
            return
        if not FileInfLib.get_module_inf(cur_module_name):
            PrintReport('Note: current module: \"%s\" not found in design !' %
                        (cur_module_name))
            return
        # get cur module sub module inf
        sub_topo_data, sub_topo_link = get_fram_topo_sub_inf(
            cur_module_name, cur_frame_level)
        # add cur module topo inf to frame
        edit_vim_buffer_and_file_link(G['Frame_Inf']['Frame_Path'],
                                      sub_topo_data,
                                      sub_topo_link,
                                      add_index=frame_line + 1)
    elif cur_frame_type == 'check_point':
        show_check_point()
    elif cur_frame_type == 'base_module':
        show_base_module()
    else:
        PrintReport('Note: no operation in this line !')
    return
예제 #5
0
def get_father_module_set(module_name, dir_path_set=None):
    upper_module_set = set()
    if not dir_path_set:
        dir_path_set = get_vtags_db_dir_path_set()
    for dir_path in dir_path_set:
        if not os.path.exists(dir_path):
            continue
        exclude_patten = '--exclude-dir="vtags.db"'
        include_patten = '--include ' + (' --include '.join(
            ['"*.%s"' % (p) for p in G['SupportVerilogPostfix']]))
        match_lines = os.popen('egrep -n -r %s %s \'(^|\W)%s(\W|$)\' %s' %
                               (exclude_patten, include_patten, module_name,
                                dir_path)).readlines()
        for l in match_lines:
            try:
                spl = l.split(':')  #not support file name has ':'
                file_path = spl[0]
                line_num = int(spl[1]) - 1
                line_inf = FileInfLib.get_file_line_inf(line_num, file_path)
                submodule = line_inf['subcall_inf']['submodule_name']
                upmodule = line_inf['module_inf']['module_name']
                if submodule == module_name:
                    upper_module_set.add(upmodule)
            except:
                continue
    return upper_module_set
예제 #6
0
파일: FrameLib.py 프로젝트: jimmysitu/vtags
def go_module_action(go_module_name):
    module_inf = FileInfLib.get_module_inf(go_module_name)
    if not module_inf:
        PrintReport('Warning: module:%s not find in design !' %
                    (go_module_name))
        return False
    go_win(module_inf['file_path'], module_inf['module_name_match_pos'],
           go_module_name)
    return True
예제 #7
0
파일: FrameLib.py 프로젝트: jimmysitu/vtags
def show_topo(topo_module_name=''):
    if not topo_module_name:
        cursor_inf = get_cur_cursor_inf()
        if cursor_inf['hdl_type'] != 'verilog':
            # if not in support file type(verilog,vhdl) just return
            PrintReport("Note: Current only support verilog !")
            return False
        # get current module inf
        cur_module_inf = None
        cur_line_inf = FileInfLib.get_file_line_inf(cursor_inf['line_num'],
                                                    cursor_inf['file_path'])
        if cur_line_inf:
            cur_module_inf = cur_line_inf['module_inf']
        # current not at module lines, just return
        if not cur_module_inf:
            PrintReport("Note: Current cursor not in valid module !")
            return False
        topo_module_name = cur_module_inf['module_name']
    else:
        topo_module_inf = FileInfLib.get_module_inf(topo_module_name)
        if not topo_module_inf:
            PrintReport("Note: show topo module %s not have database !" %
                        (topo_module_name))
            return False
    # if frame not show ,show it
    Show(G['Frame_Inf']['Frame_Path'])
    # current module must has module inf
    G['TopoInf'][
        'CurModule'] = topo_module_name  # note cur topo name for refresh
    range_inf = get_frame_range_inf()
    has_topo = range_inf['has_topo']
    topo_range = range_inf['topo_range']
    topo_data, topo_link = gen_top_topo_data_link(topo_module_name)
    # del old topo, add new topo
    if has_topo:  # del
        edit_vim_buffer_and_file_link(path=G['Frame_Inf']['Frame_Path'],
                                      mode='del',
                                      del_range=topo_range)
    edit_vim_buffer_and_file_link(G['Frame_Inf']['Frame_Path'],
                                  topo_data,
                                  topo_link,
                                  add_index=topo_range[0])
    return True
예제 #8
0
def go_into_submodule():
    cursor_inf = get_cur_cursor_inf()
    subcall_cursor_inf = CodeLib.get_subcall_pos_inf(cursor_inf['file_path'],
                                                     cursor_inf['pos'],
                                                     cursor_inf['codes'])
    if not subcall_cursor_inf:
        PrintReport(
            'Note: not found module instance at current cursor line, do-nothing !'
        )
        return True
    assert (subcall_cursor_inf['subcall_inf'])
    # for case subcall recoginize not accuracy, may because of '`ifdef, `endif ...'
    if subcall_cursor_inf['subcall_inf']['inaccuracy']:
        PrintReport(
            'Warning: carefull the trace result, subcall module:%s, instance:%s inaccuracy !'
            % (subcall_cursor_inf['subcall_inf']['module_name'],
               subcall_cursor_inf['subcall_inf']['instance_name']))
    # it is subcall must go subcall, has 2 case:
    # case 1, cursor on valid io connect, go submodule io line
    # case 2, cursor not on valid io connect, just go submodule define line
    submodule_name = subcall_cursor_inf['subcall_inf']['submodule_name']
    submodule_inf = FileInfLib.get_module_inf(submodule_name)
    if not submodule_inf:
        PrintReport(
            'Warning: can not find module:%s define in design, do-nothing !' %
            (submodule_name))
        return True
    go_path = submodule_inf['file_path']
    go_word = submodule_name
    go_pos = submodule_inf['module_name_match_pos']
    if subcall_cursor_inf['submodule_io_inf']:  # case 1
        go_word = subcall_cursor_inf['submodule_io_inf']['name']
        go_pos = subcall_cursor_inf['submodule_io_inf']['name_pos']
    # note upper module information
    subcall_instance_name = subcall_cursor_inf['subcall_inf']['instance_name']
    cur_module_inf = subcall_cursor_inf['module_inf']
    cur_module_name = cur_module_inf['module_name']
    FileInfLib.set_module_last_call_inf(submodule_name, cur_module_name,
                                        subcall_instance_name)
    # go submodule
    add_trace_point()
    go_win(go_path, go_pos, go_word)
예제 #9
0
def open_module_file(module_name):
    cur_module_inf = FileInfLib.get_module_inf(module_name)
    if not cur_module_inf:
        print('Error: module %s not found! \n' % (module_name))
        return False
    file_path = cur_module_inf['file_path']
    module_name_match_pos = cur_module_inf['module_name_match_pos']
    if not os.path.isfile(file_path):
        print('Error: module file %s not exist! \n' % (file_path))
        return False
    WinLib.open_file_separately(file_path, module_name_match_pos[0])
예제 #10
0
파일: FrameLib.py 프로젝트: jimmysitu/vtags
def gen_top_topo_data_link(topo_module):
    topo_datas = []
    topo_links = []
    topo_module_inf = FileInfLib.get_module_inf(topo_module)
    if not topo_module_inf:
        PrintDebug('Error: get topo module name %s, should has module inf !' %
                   (topo_module))
        return topo_datas, topo_links
    TopTopoLevel = G['TopoInf']['TopFoldLevel']
    TopTopoPrefix = G['Frame_Inf']['FoldLevelSpace'] * TopTopoLevel
    # add first topo line
    topo_datas.append(TopTopoPrefix + 'ModuleTopo:')
    topo_link_parm = {
        'Type': 'topo'  # fold_unfold_frame_action()
        ,
        'fold_level': TopTopoLevel - 1  # fold_unfold_frame_action() 
        ,
        'fold_status': 'on'  # fold_unfold_frame_action()
        ,
        'topo_module': ''  # fold_unfold_frame_action()
        ,
        'go_module_name': ''  # for fold_unfold_frame_action()
    }
    topo_link = gen_hyperlink(['go_module_action', 'fold_unfold_frame_action'],
                              topo_link_parm,
                              Type='topo')
    topo_link['payload_dic']['topo_instance_name'] = ''
    topo_links.append(topo_link)
    # add cur module name
    topo_datas.append(TopTopoPrefix + topo_module + ':')
    topo_link_parm = {
        'Type': 'topo'  # fold_unfold_frame_action()
        ,
        'fold_level': TopTopoLevel  # fold_unfold_frame_action() 
        ,
        'fold_status': 'on'  # fold_unfold_frame_action()
        ,
        'topo_module': topo_module  # fold_unfold_frame_action()
        ,
        'go_module_name': topo_module  # for fold_unfold_frame_action()
    }
    topo_link = gen_hyperlink(['go_module_action', 'fold_unfold_frame_action'],
                              topo_link_parm,
                              Type='topo')
    topo_link['payload_dic']['topo_instance_name'] = ''
    topo_links.append(topo_link)
    # gen current module sub function module, and base module topo inf
    sub_module_data, sub_module_link = get_fram_topo_sub_inf(topo_module, 0)
    topo_datas = topo_datas + sub_module_data
    topo_links = topo_links + sub_module_link
    assert (len(topo_datas) == len(topo_links))
    return topo_datas, topo_links
예제 #11
0
파일: FrameLib.py 프로젝트: jimmysitu/vtags
def get_sub_func_base_module(module_name):
    func_instance_name_submodule_name_list = []
    base_submodule_name_to_instance_list_dic = {}
    # first get current module inf
    module_inf = FileInfLib.get_module_inf(module_name)
    if not module_inf:
        return func_instance_name_submodule_name_list, base_submodule_name_to_instance_list_dic
    # get the subcall inf list for current module
    if module_inf.setdefault('subcall_instance_list', None) == None:
        assert (FileInfLib.module_inf_add_subcall_instance_list(module_inf))
    subcall_instance_list = module_inf['subcall_instance_list']
    for subcall_inf in subcall_instance_list:
        instance_name = subcall_inf['instance_name']
        submodule_name = subcall_inf['submodule_name']
        if submodule_name in G['BaseModuleInf']['BaseModules']:
            base_submodule_name_to_instance_list_dic.setdefault(
                submodule_name, [])
            base_submodule_name_to_instance_list_dic[submodule_name].append(
                instance_name)
        else:
            func_instance_name_submodule_name_list.append(
                (instance_name, submodule_name))
    return func_instance_name_submodule_name_list, base_submodule_name_to_instance_list_dic
예제 #12
0
def go_upper_module():
    cursor_inf = get_cur_cursor_inf()
    # get cur module name
    cur_module_name = ''
    cur_module_inf = None
    cur_line_inf = FileInfLib.get_file_line_inf(cursor_inf['line_num'],
                                                cursor_inf['file_path'])
    if cur_line_inf:
        cur_module_inf = cur_line_inf['module_inf']
    if not cur_module_inf:
        PrintReport('Note: current cursor not in valid module, do-nothing !')
        return
    cur_module_name = cur_module_inf['module_name']
    # get cur module last call upper module inf
    cur_last_call_inf = FileInfLib.get_module_last_call_inf(cur_module_name)
    already_get_upper = False
    if cur_last_call_inf:
        upper_subcall_inf = cur_last_call_inf['upper_subcall_inf']
        upper_module_path = upper_subcall_inf['file_path']
        upper_submodule_name_match_pos = upper_subcall_inf[
            'submodule_name_match_pos']
        upper_instance_name = upper_subcall_inf['instance_name']
        add_trace_point()
        go_win(upper_module_path, upper_submodule_name_match_pos,
               upper_instance_name)
        already_get_upper = True
    # even has upper, also should list all the poss upper
    line_and_link_list = CodeLib.get_upper_module_line_and_link_list(
        cur_module_name)
    if line_and_link_list:
        # i = 0
        link_list = []
        line_list = []
        # pre inf
        line_list.append('Knock "<Space>" to choise upper module you want: ')
        line_list.append('')
        link_list.append({})
        link_list.append({})
        line_list += line_and_link_list['line_list']
        link_list += line_and_link_list['link_list']
        mounted_line_inf = MountPrintLines(line_list,
                                           label='Possible Upper',
                                           link_list=link_list)
        mounted_line_list = mounted_line_inf['line_list']
        mounted_link_list = mounted_line_inf['link_list']
        # add a empty line below
        mounted_line_list.append('')
        mounted_link_list.append({})
        if link_list:
            add_trace_point()
            assert (len(mounted_line_list) == len(mounted_link_list))
            PrintReport(mounted_line_list, mounted_link_list, MountPrint=True)
            if not already_get_upper:
                if len(line_and_link_list['line_list']) == 1:
                    for link in link_list:
                        if link:
                            do_hyperlink(link, [
                                'go_file_action', 'add_module_last_call_action'
                            ])  # first valid link
                            break
                else:
                    # len(mounted_line_list) + 1 is the lines relative to the last report line
                    # -4 is skip first 4 unused line
                    go_win(G['Report_Inf']['Report_Path'],
                           (-(len(mounted_line_list) + 1 - 4), 49))
    else:
        PrintReport('Note: module %s not called by upper module before !' %
                    (cur_module_name))
    return
예제 #13
0
파일: FrameLib.py 프로젝트: jimmysitu/vtags
def get_fram_topo_sub_inf(topo_module, cur_level):
    sub_level = cur_level + 1
    topo_prefix = G['Frame_Inf']['FoldLevelSpace'] * sub_level
    topo_datas = []
    topo_links = []
    func_instance_name_submodule_name_list, base_submodule_name_to_instance_list_dic = get_sub_func_base_module(
        topo_module)
    # first deal sub func module, show "inst(module)"
    for instance_name, submodule_name in func_instance_name_submodule_name_list:
        # gen show data
        c_str = '%s%s(%s)' % (topo_prefix, instance_name, submodule_name)
        topo_datas.append(c_str)
        # gen link
        c_topo_link_parm = {
            'Type': 'topo'  # fold_unfold_frame_action()
            ,
            'fold_level': sub_level  # fold_unfold_frame_action() 
            ,
            'fold_status': 'off'  # fold_unfold_frame_action()
            ,
            'topo_module': submodule_name  # fold_unfold_frame_action()
            ,
            'go_module_name': submodule_name  # for fold_unfold_frame_action()
        }
        c_topo_link = gen_hyperlink(
            ['go_module_action', 'fold_unfold_frame_action'],
            c_topo_link_parm,
            Type='topo')
        c_topo_link['payload_dic']['topo_instance_name'] = instance_name
        submodule_inf = FileInfLib.get_module_inf(submodule_name)
        if submodule_inf:
            # show cur module, then all submodule, last call set to cur module
            FileInfLib.set_module_last_call_inf(submodule_name, topo_module,
                                                instance_name)
        topo_links.append(c_topo_link)
    # deal base modules
    base_submodule_name_list = list(base_submodule_name_to_instance_list_dic)
    base_submodule_name_list.sort()
    if len(base_submodule_name_list) > 0:
        # deal base , show "module(n)"
        # add one to sep func and base
        topo_datas.append(topo_prefix + '------')
        c_topo_link_parm = {
            'Type': 'topo'  # fold_unfold_frame_action()
            ,
            'fold_level': sub_level  # fold_unfold_frame_action() 
            ,
            'fold_status': 'fix'  # fold_unfold_frame_action()
            ,
            'topo_module': ''  # fold_unfold_frame_action()
            ,
            'go_module_name': ''  # for fold_unfold_frame_action()
        }
        c_topo_link = gen_hyperlink(
            ['go_module_action', 'fold_unfold_frame_action'],
            c_topo_link_parm,
            Type='topo')
        c_topo_link['payload_dic']['topo_instance_name'] = ''
        topo_links.append(c_topo_link)
        for submodule_name in base_submodule_name_list:
            # deal data
            instance_num = len(
                base_submodule_name_to_instance_list_dic[submodule_name])
            c_str = '%s%s(%d)' % (topo_prefix, submodule_name, instance_num)
            topo_datas.append(c_str)
            # deal link
            c_topo_link_parm = {
                'Type': 'topo'  # fold_unfold_frame_action()
                ,
                'fold_level': sub_level  # fold_unfold_frame_action() 
                ,
                'fold_status': 'off'  # fold_unfold_frame_action()
                ,
                'topo_module': submodule_name  # fold_unfold_frame_action()
                ,
                'go_module_name':
                submodule_name  # for fold_unfold_frame_action()
            }
            c_topo_link = gen_hyperlink(
                ['go_module_action', 'fold_unfold_frame_action'],
                c_topo_link_parm,
                Type='topo')
            c_topo_link['payload_dic']['topo_instance_name'] = ''
            topo_links.append(c_topo_link)
    assert (len(topo_datas) == len(topo_links))
    return topo_datas, topo_links
예제 #14
0
            line_list.append('  %s'%(d))
        line_list.append('Such as:')
        for d in dir_in_filelist:
            line_list.append('  ln -s ./vtags.db %s'%(d))
        MountPrintLines(line_list, label = 'TAKE CARE', Print = True)
else:
    print("Note: no filelist, create vtags.db for current dir !")
    filelist_filehandle.write( os.path.realpath( os.getcwd() ) + '\n')
    filelist_filehandle.close()


#-------------------------------------------------------------------------------
# get all the verilog file code inf
#-------------------------------------------------------------------------------
# get all verilog files path from file_list
design_file_path_set      = FileInfLib.get_all_design_file_path_from_filelist(vtags_file_list)

# get all code inf
file_path_to_code_inf_dic = FileInfLib.init_get_file_path_to_code_inf_dic(design_file_path_set)


#-------------------------------------------------------------------------------
# add more inf to module_inf, subcall_inf, macro_inf
#-------------------------------------------------------------------------------
module_name_to_file_path_list_dic = {}
file_path_to_last_modify_time_dic = {}
for f in file_path_to_code_inf_dic:
    file_path_to_last_modify_time_dic[f] = file_path_to_code_inf_dic[f]['last_modify_time']
    module_inf_list = file_path_to_code_inf_dic[f]['module_inf_list'  ]
    for module_inf in module_inf_list:
        module_name_to_file_path_list_dic.setdefault(module_inf['module_name'],[])