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
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
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])
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
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)
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
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)
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
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