def __init__(self, fd, work_dir, gen_full_tree=False, tags=[]): self.gtkw = gtkw_new.GTKWSave(fd) self.gtkw.dumpfile(os.path.join(work_dir, 'all.vcd')) self.work_dir = work_dir self.current_groups = [] self.current_groups.append(Gtkwave_group(None)) self.gen_full_tree = gen_full_tree self.view = 'overview' self.tags = tags self.activate_traces = []
def gen_gtkw_files(config, gv_config): nb_pe = config.get_int('**/cluster/nb_pe') user_traces = gv_config.get('**/vcd/traces') tags = gv_config.get('**/vcd/tags').get_dict() gen_rt_traces(config, gv_config) # Remove trace file so that we can switch between regular file and fifo if os.path.exists('all.vcd'): os.remove('all.vcd') core_state_file = os.path.join(os.getcwd(), 'core_state.txt') rt_state_file = os.path.join(os.getcwd(), 'rt_state.txt') all_state_file = os.path.join(os.getcwd(), 'all_state.txt') with open(core_state_file, 'w') as file: file.write('01 ?CadetBlue?ACTIVE\n') with open(all_state_file, 'w') as file: for i in range(0, len(gtkw_colors)): file.write('%d ?%s?ACTIVE\n' % (i, gtkw_colors[i])) with open(rt_state_file, 'w') as file: file.write('0 ?DarkSlateGray3?ENTRY\n') file.write('1 ?CadetBlue?FORK\n') file.write('2 ?DarkSlateGrey?BARRIER\n') file.write('3 ?DarkSlateGrey?CRITICAL\n') file.write('4 ?DarkSlateGrey?DMA_PUSH\n') file.write('5 ?DarkSlateGrey?DMA_WAIT\n') tp = Trace_pool() if len(gv_config.get('event').get()) != 0 or gv_config.get_bool( 'vcd/active'): path = os.path.join(os.getcwd(), 'view.gtkw') with open(path, 'w') as file: gtkw = gtkw_new.GTKWSave(file) gtkw.dumpfile('all.vcd') with gtkw.group('overview'): check_user_traces(gtkw, tp, 'overview', user_traces) with gtkw.group('soc'): check_user_traces(gtkw, tp, 'overview.soc', user_traces) gtkw.trace(tp.get('overview', 'sys.board.chip.soc.fc.state', '[7:0]'), 'fc', translate_filter_file=core_state_file) gen_gtkw_vector( gtkw, 'sys.board.chip.soc', 'udma', trace_filter=core_state_file, traces=[ [ tp.get( 'overview', 'sys.board.chip.soc.udma.spim0_rx.state', '[7:0]'), 'spim0_rx' ], [ tp.get( 'overview', 'sys.board.chip.soc.udma.spim0_tx.state', '[7:0]'), 'spim0_tx' ], [ tp.get( 'overview', 'sys.board.chip.soc.udma.spim1_rx.state', '[7:0]'), 'spim1_rx' ], [ tp.get( 'overview', 'sys.board.chip.soc.udma.spim1_tx.state', '[7:0]'), 'spim1_tx' ], [ tp.get( 'overview', 'sys.board.chip.soc.udma.hyper0_rx.state', '[7:0]'), 'hyper0_rx' ], [ tp.get( 'overview', 'sys.board.chip.soc.udma.hyper0_tx.state', '[7:0]'), 'hyper0_tx' ], [ tp.get( 'overview', 'sys.board.chip.soc.udma.i2c0_rx.state', '[7:0]'), 'ic20_rx' ], [ tp.get( 'overview', 'sys.board.chip.soc.udma.i2c0_tx.state', '[7:0]'), 'ic20_tx' ], [ tp.get( 'overview', 'sys.board.chip.soc.udma.i2c1_rx.state', '[7:0]'), 'ic21_rx' ], [ tp.get( 'overview', 'sys.board.chip.soc.udma.i2c1_tx.state', '[7:0]'), 'i2c1_tx' ], [ tp.get( 'overview', 'sys.board.chip.soc.udma.i2s0_rx.state', '[7:0]'), 'i2s0_rx' ], [ tp.get( 'overview', 'sys.board.chip.soc.udma.uart0_rx.state', '[7:0]'), 'uart0_rx' ], [ tp.get( 'overview', 'sys.board.chip.soc.udma.uart0_tx.state', '[7:0]'), 'uart0_tx' ], [ tp.get( 'overview', 'sys.board.chip.soc.udma.cpi0_rx.state', '[7:0]'), 'cpi0_rx' ] ]) if nb_pe is not None: with gtkw.group('cluster'): check_user_traces(gtkw, tp, 'overview.cluster', user_traces) for i in range(0, nb_pe): gtkw.trace(tp.get( 'overview', 'sys.board.chip.cluster.pe%d.state' % i, '[7:0]'), 'pe_%d' % i, translate_filter_file=core_state_file) gen_gtkw_vector( gtkw, 'sys.board.chip.cluster', 'dma', trace_filter=core_state_file, traces=[ [ tp.get( 'overview', 'sys.board.chip.cluster.dma.channel_0', '[7:0]'), 'channel_0' ], [ tp.get( 'overview', 'sys.board.chip.cluster.dma.channel_1', '[7:0]'), 'channel_1' ], [ tp.get( 'overview', 'sys.board.chip.cluster.dma.channel_2', '[7:0]'), 'channel_2' ], [ tp.get( 'overview', 'sys.board.chip.cluster.dma.channel_3', '[7:0]'), 'channel_3' ], [ tp.get( 'overview', 'sys.board.chip.cluster.dma.channel_4', '[7:0]'), 'channel_4' ], [ tp.get( 'overview', 'sys.board.chip.cluster.dma.channel_5', '[7:0]'), 'channel_5' ], [ tp.get( 'overview', 'sys.board.chip.cluster.dma.channel_6', '[7:0]'), 'channel_6' ], [ tp.get( 'overview', 'sys.board.chip.cluster.dma.channel_7', '[7:0]'), 'channel_7' ], [ tp.get( 'overview', 'sys.board.chip.cluster.dma.channel_8', '[7:0]'), 'channel_8' ], [ tp.get( 'overview', 'sys.board.chip.cluster.dma.channel_9', '[7:0]'), 'channel_9' ], [ tp.get( 'overview', 'sys.board.chip.cluster.dma.channel_10', '[7:0]'), 'channel_10' ], [ tp.get( 'overview', 'sys.board.chip.cluster.dma.channel_11', '[7:0]'), 'channel_11' ], [ tp.get( 'overview', 'sys.board.chip.cluster.dma.channel_12', '[7:0]'), 'channel_12' ], [ tp.get( 'overview', 'sys.board.chip.cluster.dma.channel_13', '[7:0]'), 'channel_13' ], [ tp.get( 'overview', 'sys.board.chip.cluster.dma.channel_14', '[7:0]'), 'channel_14' ], [ tp.get( 'overview', 'sys.board.chip.cluster.dma.channel_15', '[7:0]'), 'channel_15' ], ]) with gtkw.group('runtime', closed=True): check_user_traces(gtkw, tp, 'overview.cluster.runtime', user_traces) with gtkw.group('stats', closed=True): check_user_traces(gtkw, tp, 'overview.cluster.stats', user_traces) for i in range(0, nb_pe): gtkw.trace(tp.get( 'overview', 'sys.board.chip.cluster.pe%d.ipc_stat' % i), 'pe%d_ipc' % i, extraflags=[ 'analog_step', 'analog_fullscale' ]) with gtkw.group('chip', closed=True): check_user_traces(gtkw, tp, 'chip', user_traces) with gtkw.group('fc', closed=True): check_user_traces(gtkw, tp, 'chip.fc', user_traces) gen_gtkw_core_traces(gtkw, tp, 'sys.board.chip.soc.fc') if nb_pe is not None: with gtkw.group('cluster', closed=True): gtkw.trace( 'sys.board.chip.cluster.power_trace', datafmt='real', extraflags=['analog_step', 'analog_fullscale']) check_user_traces(gtkw, tp, 'chip.cluster', user_traces) for i in range(0, nb_pe): with gtkw.group('pe_%d' % i, closed=True): gen_gtkw_core_traces( gtkw, tp, 'sys.board.chip.cluster.pe%d' % i) print() print( 'A Gtkwave script has been generated and can be opened with the following command:' ) print('gtkwave ' + path) print() for trace in tp.get_traces(tags): gv_config.set('event', trace.get_vp()) if gv_config.get_bool('**/vcd/gtkw'): gv_config.set('vcd/format', 'vcd') os.mkfifo('all.vcd') gtkw_new.spawn_gtkwave_interactive('all.vcd', 'view.gtkw', quiet=False)