diff --git a/cgra/CGRAKingMeshRTL.py b/cgra/CGRAKingMeshRTL.py index f5ff12e..b1ffae3 100644 --- a/cgra/CGRAKingMeshRTL.py +++ b/cgra/CGRAKingMeshRTL.py @@ -149,11 +149,23 @@ def construct( s, DataType, PredicateType, CtrlType, width, height, s.tile[i].to_mem_waddr.rdy //= 0 s.tile[i].to_mem_wdata.rdy //= 0 - # Line trace - def line_trace( s ): + # verbose trace if verbosity > 0 + def verbose_trace(s, verbosity=1): res = '' for (i, x) in enumerate(s.tile): - res += "# [tile"+str(i)+"]: " + x.line_trace() + x.ctrl_mem.line_trace() + '\n' - res += f"\ndata_mem: {s.data_mem.line_trace()}" + res += "# [tile" + str(i) + "]: " + x.line_trace(verbosity=verbosity) + x.ctrl_mem.line_trace(verbosity=verbosity) + '\n' + res += f"\ndata_mem: {s.data_mem.line_trace(verbosity=verbosity)}" res += "------\n\n" return res + + # Line trace + def line_trace(s, verbosity=0): + if verbosity==0: + # str = "||".join([ x.element.line_trace() for x in s.tile ]) + # str += " :: [" + s.data_mem.line_trace() + "]" + res = "||\n".join([(("[tile" + str(i) + "]: ") + x.line_trace() + x.ctrl_mem.line_trace()) + for (i, x) in enumerate(s.tile)]) + res += "\n :: [" + s.data_mem.line_trace() + "] \n" + return res + else: + return s.verbose_trace(verbosity=verbosity) diff --git a/cgra/translate/VectorCGRAKingMeshRTL_test.py b/cgra/translate/VectorCGRAKingMeshRTL_test.py index f6826de..291db2a 100644 --- a/cgra/translate/VectorCGRAKingMeshRTL_test.py +++ b/cgra/translate/VectorCGRAKingMeshRTL_test.py @@ -67,7 +67,8 @@ def done( s ): return done def line_trace( s ): - return s.dut.line_trace() + verbosity = 1 + return s.dut.line_trace(verbosity=verbosity) def test_homo_4x4( cmdline_opts ): num_tile_inports = 8 diff --git a/fu/flexible/FlexibleFuRTL.py b/fu/flexible/FlexibleFuRTL.py index 490171d..d044b8a 100644 --- a/fu/flexible/FlexibleFuRTL.py +++ b/fu/flexible/FlexibleFuRTL.py @@ -113,8 +113,8 @@ def comb_logic(): s.fu_recv_in_rdy_vector[port][i] @= s.fu[i].recv_in[port].rdy s.recv_in[port].rdy @= reduce_or( s.fu_recv_in_rdy_vector[port] ) - - def line_trace( s ): + # verbose trace if verbosity > 0 + def verbose_trace(s, verbosity=1): # for clk n # recv: # 1. OPT: opt+rdy(if ready to receive opt) @@ -151,3 +151,13 @@ def line_trace( s ): f'- FU out:' f'{out_md}\n') + def line_trace( s, verbosity=0 ): + if verbosity == 0: + opt_str = " #" + if s.recv_opt.en: + opt_str = OPT_SYMBOL_DICT[s.recv_opt.msg.ctrl] + out_str = ",".join([str(x.msg) for x in s.send_out]) + recv_str = ",".join([str(x.msg) for x in s.recv_in]) + return f'[recv: {recv_str}] {opt_str}(P{s.recv_opt.msg.predicate}) (const: {s.recv_const.msg}, en: {s.recv_const.en}) ] = [out: {out_str}] (recv_opt.rdy: {s.recv_opt.rdy}, recv_in[0].rdy: {s.recv_in[0].rdy}, recv_in[1].rdy: {s.recv_in[1].rdy}, recv_predicate.msg: {s.recv_predicate.msg}, {OPT_SYMBOL_DICT[s.recv_opt.msg.ctrl]}, recv_opt.en: {s.recv_opt.en}, send[0].en: {s.send_out[0].en}) ' + else: + return s.verbose_trace(verbosity=verbosity) diff --git a/mem/ctrl/CtrlMemRTL.py b/mem/ctrl/CtrlMemRTL.py index 7b42c38..9be4d47 100644 --- a/mem/ctrl/CtrlMemRTL.py +++ b/mem/ctrl/CtrlMemRTL.py @@ -73,21 +73,21 @@ def update_raddr(): else: s.reg_file.raddr[0] <<= s.reg_file.raddr[0] + AddrType( 1 ) - - def line_trace( s ): + # verbose trace if verbosity > 0 + def verbose_trace(s, verbosity=1): num_fu_in = len(s.reg_file.regs[0].fu_in) # num_inports = len(s.reg_file.regs[0].predicate_in) num_outports = len(s.reg_file.regs[0].outport if hasattr(s.reg_file.regs[0], 'outport') else []) num_direction_ports = num_outports - num_fu_in # reg - reg_dicts = [ dict(data.__dict__) for data in s.reg_file.regs ] + reg_dicts = [dict(data.__dict__) for data in s.reg_file.regs] reg_sub_header = {} for reg_dict in reg_dicts: for key in reg_dict.keys(): reg_sub_header[key] = '' reg_dict['ctrl'] = OPT_SYMBOL_DICT[reg_dict['ctrl']] - reg_dict['fu_in'] = [ int(fi) for fi in reg_dict['fu_in']] + reg_dict['fu_in'] = [int(fi) for fi in reg_dict['fu_in']] fu_in_header = [] for idx, val in enumerate(reg_dict['fu_in']): fu_in_header.append(idx) @@ -95,34 +95,36 @@ def line_trace( s ): reg_dict['fu_in'] = "|".join([f"{v : ^3}" for v in reg_dict['fu_in']]) reg_sub_header['fu_in'] = fu_in_header_str if 'outport' in reg_dict: - reg_dict['outport'] = [ int(op) for op in reg_dict['outport']] + reg_dict['outport'] = [int(op) for op in reg_dict['outport']] fu_reg_num = 1 outport_sub_header = [] for idx, val in enumerate(reg_dict['outport']): # to directions - if idx <= num_direction_ports-1: + if idx <= num_direction_ports - 1: hd = tile_port_direction_dict_short_desc[idx] - outport_sub_header.append(f"{hd : ^{len(hd)+2}}") - reg_dict['outport'][idx] = f"{tile_port_direction_dict_short_desc[val-1] if val != 0 else '-' : ^{len(hd)+2}}" + outport_sub_header.append(f"{hd : ^{len(hd) + 2}}") + reg_dict['outport'][ + idx] = f"{tile_port_direction_dict_short_desc[val - 1] if val != 0 else '-' : ^{len(hd) + 2}}" # to fu regs else: hd = f"fu_reg_{fu_reg_num}" outport_sub_header.append(f"{hd : ^{len(hd)}}") - reg_dict['outport'][idx] = f"{tile_port_direction_dict_short_desc[val-1] if val != 0 else '-' : ^{len(hd)}}" + reg_dict['outport'][ + idx] = f"{tile_port_direction_dict_short_desc[val - 1] if val != 0 else '-' : ^{len(hd)}}" fu_reg_num += 1 outport_sub_header_str = "|".join([hd for hd in outport_sub_header]) reg_dict['outport'] = "|".join([v for v in reg_dict['outport']]) - reg_sub_header['outport'] = outport_sub_header_str + reg_sub_header['outport'] = outport_sub_header_str if 'predicate_in' in reg_dict: - reg_dict['predicate_in'] = [ int(pi) for pi in reg_dict['predicate_in']] + reg_dict['predicate_in'] = [int(pi) for pi in reg_dict['predicate_in']] fu_out_num = 1 predicate_in_sub_header = [] for idx, val in enumerate(reg_dict['predicate_in']): # from directions if idx <= num_direction_ports - 1: hd = tile_port_direction_dict_short_desc[idx] - predicate_in_sub_header.append(f"{hd : ^{len(hd)+2}}") - reg_dict['predicate_in'][idx] = f"{val : ^{len(hd)+2}}" + predicate_in_sub_header.append(f"{hd : ^{len(hd) + 2}}") + reg_dict['predicate_in'][idx] = f"{val : ^{len(hd) + 2}}" # from fu else: hd = f"fu_out_{fu_out_num}" @@ -133,13 +135,13 @@ def line_trace( s ): reg_dict['predicate_in'] = "|".join([v for v in reg_dict['predicate_in']]) reg_sub_header['predicate_in'] = predicate_in_sub_header_str if 'routing_xbar_outport' in reg_dict: - reg_dict['routing_xbar_outport'] = [ int(rxop) for rxop in reg_dict['routing_xbar_outport']] + reg_dict['routing_xbar_outport'] = [int(rxop) for rxop in reg_dict['routing_xbar_outport']] if 'fu_xbar_outport' in reg_dict: - reg_dict['fu_xbar_outport'] = [ int(fxop) for fxop in reg_dict['fu_xbar_outport']] + reg_dict['fu_xbar_outport'] = [int(fxop) for fxop in reg_dict['fu_xbar_outport']] if 'routing_predicate_in' in reg_dict: - reg_dict['routing_predicate_in'] = [ int(rpi) for rpi in reg_dict['routing_predicate_in']] + reg_dict['routing_predicate_in'] = [int(rpi) for rpi in reg_dict['routing_predicate_in']] reg_dicts.insert(0, reg_sub_header) - reg_md = markdown_table(reg_dicts).set_params(quote=False).get_markdown() + reg_md = markdown_table(reg_dicts).set_params(quote=False).get_markdown() # recv_ctrl recv_ctrl_msg_dict = dict(s.recv_ctrl.msg.__dict__) @@ -148,7 +150,7 @@ def line_trace( s ): recv_ctrl_sub_header[key] = '' recv_ctrl_msg_list = [] recv_ctrl_msg_dict['ctrl'] = OPT_SYMBOL_DICT[recv_ctrl_msg_dict['ctrl']] - recv_ctrl_msg_dict['fu_in'] = [ int(fi) for fi in recv_ctrl_msg_dict['fu_in']] + recv_ctrl_msg_dict['fu_in'] = [int(fi) for fi in recv_ctrl_msg_dict['fu_in']] fu_in_header = [] for idx, val in enumerate(recv_ctrl_msg_dict['fu_in']): fu_in_header.append(idx) @@ -157,34 +159,36 @@ def line_trace( s ): recv_ctrl_sub_header['fu_in'] = fu_in_header_str if 'outport' in recv_ctrl_msg_dict: - recv_ctrl_msg_dict['outport'] = [ int(op) for op in recv_ctrl_msg_dict['outport']] + recv_ctrl_msg_dict['outport'] = [int(op) for op in recv_ctrl_msg_dict['outport']] fu_reg_num = 1 outport_sub_header = [] for idx, val in enumerate(recv_ctrl_msg_dict['outport']): # to directions if idx <= num_direction_ports - 1: hd = tile_port_direction_dict_short_desc[idx] - outport_sub_header.append(f"{hd : ^{len(hd)+2}}") - recv_ctrl_msg_dict['outport'][idx] = f"{tile_port_direction_dict_short_desc[val - 1] if val != 0 else '-' : ^{len(hd)+2}}" + outport_sub_header.append(f"{hd : ^{len(hd) + 2}}") + recv_ctrl_msg_dict['outport'][ + idx] = f"{tile_port_direction_dict_short_desc[val - 1] if val != 0 else '-' : ^{len(hd) + 2}}" # to fu regs else: hd = f"fu_reg_{fu_reg_num}" outport_sub_header.append(f"{hd : ^{len(hd)}}") - recv_ctrl_msg_dict['outport'][idx] = f"{tile_port_direction_dict_short_desc[val - 1] if val != 0 else '-' : ^{len(hd)}}" + recv_ctrl_msg_dict['outport'][ + idx] = f"{tile_port_direction_dict_short_desc[val - 1] if val != 0 else '-' : ^{len(hd)}}" fu_reg_num += 1 outport_sub_header_str = "|".join([hd for hd in outport_sub_header]) recv_ctrl_msg_dict['outport'] = "|".join([v for v in recv_ctrl_msg_dict['outport']]) recv_ctrl_sub_header['outport'] = outport_sub_header_str if 'predicate_in' in recv_ctrl_msg_dict: - recv_ctrl_msg_dict['predicate_in'] = [ int(pi) for pi in recv_ctrl_msg_dict['predicate_in']] + recv_ctrl_msg_dict['predicate_in'] = [int(pi) for pi in recv_ctrl_msg_dict['predicate_in']] fu_out_num = 1 predicate_in_sub_header = [] for idx, val in enumerate(recv_ctrl_msg_dict['predicate_in']): # from directions if idx <= num_direction_ports - 1: hd = tile_port_direction_dict_short_desc[idx] - predicate_in_sub_header.append(f"{hd : ^{len(hd)+2}}") - recv_ctrl_msg_dict['predicate_in'][idx] = f"{val : ^{len(hd)+2}}" + predicate_in_sub_header.append(f"{hd : ^{len(hd) + 2}}") + recv_ctrl_msg_dict['predicate_in'][idx] = f"{val : ^{len(hd) + 2}}" # from fu else: hd = f"fu_out_{fu_out_num}" @@ -199,7 +203,6 @@ def line_trace( s ): send_ctrl_md = markdown_table(recv_ctrl_msg_list).set_params(quote=False).get_markdown() # recv_ctrl_msg = "\n".join([(key + ": " + str(value)) for key, value in recv_ctrl_msg_dict.items()]) - # send_ctrl send_ctrl_msg_dict = dict(s.send_ctrl.msg.__dict__) send_ctrl_sub_header = {} @@ -209,7 +212,7 @@ def line_trace( s ): send_ctrl_msg_dict['ctrl'] = OPT_SYMBOL_DICT[send_ctrl_msg_dict['ctrl']] if 'predicate' in send_ctrl_msg_dict: send_ctrl_msg_dict['predicate'] = int(send_ctrl_msg_dict['predicate']) - send_ctrl_msg_dict['fu_in'] = [ int(fi) for fi in send_ctrl_msg_dict['fu_in']] + send_ctrl_msg_dict['fu_in'] = [int(fi) for fi in send_ctrl_msg_dict['fu_in']] fu_in_header = [] for idx, val in enumerate(send_ctrl_msg_dict['fu_in']): fu_in_header.append(idx) @@ -225,13 +228,15 @@ def line_trace( s ): # to directions if idx <= num_direction_ports - 1: hd = tile_port_direction_dict_short_desc[idx] - outport_sub_header.append(f"{hd : ^{len(hd)+2}}") - send_ctrl_msg_dict['outport'][idx] = f"{tile_port_direction_dict_short_desc[val - 1] if val != 0 else '-' : ^{len(hd)+2}}" + outport_sub_header.append(f"{hd : ^{len(hd) + 2}}") + send_ctrl_msg_dict['outport'][ + idx] = f"{tile_port_direction_dict_short_desc[val - 1] if val != 0 else '-' : ^{len(hd) + 2}}" # to fu regs else: hd = f"fu_reg_{fu_reg_num}" outport_sub_header.append(f"{hd : ^{len(hd)}}") - send_ctrl_msg_dict['outport'][idx] = f"{tile_port_direction_dict_short_desc[val - 1] if val != 0 else '-' : ^{len(hd)}}" + send_ctrl_msg_dict['outport'][ + idx] = f"{tile_port_direction_dict_short_desc[val - 1] if val != 0 else '-' : ^{len(hd)}}" fu_reg_num += 1 outport_sub_header_str = "|".join([hd for hd in outport_sub_header]) send_ctrl_msg_dict['outport'] = "|".join([v for v in send_ctrl_msg_dict['outport']]) @@ -244,8 +249,8 @@ def line_trace( s ): # from directions if idx <= num_direction_ports - 1: hd = tile_port_direction_dict_short_desc[idx] - predicate_in_sub_header.append(f"{hd : ^{len(hd)+2}}") - send_ctrl_msg_dict['predicate_in'][idx] = f"{val : ^{len(hd)+2}}" + predicate_in_sub_header.append(f"{hd : ^{len(hd) + 2}}") + send_ctrl_msg_dict['predicate_in'][idx] = f"{val : ^{len(hd) + 2}}" # from fu else: hd = f"fu_out_{fu_out_num}" @@ -273,3 +278,12 @@ def line_trace( s ): f'{send_ctrl_md}\n\n' f'- ctrl_memory: {reg_md}\n') + + def line_trace( s, verbosity=0 ): + if verbosity == 0: + out_str = "||".join([str(data) for data in s.reg_file.regs]) + return f'{s.recv_ctrl.msg} : [{out_str}] : {s.send_ctrl.msg}' + else: + return s.verbose_trace(verbosity=verbosity) + + diff --git a/mem/data/DataMemRTL.py b/mem/data/DataMemRTL.py index 2a23c0c..6a08f58 100644 --- a/mem/data/DataMemRTL.py +++ b/mem/data/DataMemRTL.py @@ -97,7 +97,9 @@ def update_signal(): s.recv_waddr[i].rdy @= Bits1( 1 ) s.recv_wdata[i].rdy @= Bits1( 1 ) - def line_trace(s): + + # verbose trace if verbosity > 0 + def verbose_trace(s, verbosity=1): # data memory: mem size, reg # recv_raddr(rdy, msg), send_rdata(en, msg), recv_waddr(rdy, msg), recv_wdata, tile # reg_dicts = [dict(data.__dict__) for data in s.reg_file.regs] @@ -136,3 +138,21 @@ def line_trace(s): f'- regs(mem size: {len(reg_dicts)}): {reg_md}\n' f'- mem_r/w:' f'{mem_md}') + + + def line_trace(s, verbosity=0): + if verbosity == 0: + recv_raddr_str = "recv_read_addr: " + "|".join([str(data.msg) for data in s.recv_raddr]) + recv_waddr_str = "recv_write_addr: " + "|".join([str(data.msg) for data in s.recv_waddr]) + recv_wdata_str = "recv_write_data: " + "|".join([str(data.msg) for data in s.recv_wdata]) + content_str = "content: " + "|".join([str(data) for data in s.reg_file.regs]) + send_rdata_str = "send_read_data: " + "|".join([str(data.msg) for data in s.send_rdata]) + return f'{recv_raddr_str} || {recv_waddr_str} || {recv_wdata_str} || [{content_str}] || {send_rdata_str}' + # return f'DataMem: {recv_str} : [{out_str}] : {send_str} initWrites: {s.initWrites}' + # return s.reg_file.line_trace() + # return f'<{s.reg_file.wen[0]}>{s.reg_file.waddr[0]}:{s.reg_file.wdata[0]}|{s.reg_file.raddr[0]}:{s.reg_file.rdata[0]}' + # rf_trace = f'<{s.reg_file.wen[0]}>{s.reg_file.waddr[0]}:{s.reg_file.wdata[0]}|{s.reg_file.raddr[0]}:{s.reg_file.rdata[0]}' + # return f'[{s.recv_wdata[0].en & s.recv_waddr[0].en}]{s.recv_waddr[0]}<{s.recv_wdata[0]}({rf_trace}){s.recv_raddr[0]}>{s.send_rdata[0]}' + else: + return s.verbose_trace(verbosity=verbosity) + diff --git a/tile/TileRTL.py b/tile/TileRTL.py index 378609c..03f9bf7 100644 --- a/tile/TileRTL.py +++ b/tile/TileRTL.py @@ -124,40 +124,50 @@ def update_opt(): s.crossbar.recv_opt.en @= s.ctrl_mem.send_ctrl.en s.ctrl_mem.send_ctrl.rdy @= s.element.recv_opt.rdy & s.crossbar.recv_opt.rdy + # verbose trace if verbosity > 0 + def verbose_trace(s, verbosity=1): + # recv: + # 1. rdy (if ready to receive data), if en and rdy: then data has been transferred (val, rdy are new type(protocol)) + # 2. data + # [3. opt will show in FU trace] + # FU: + # FlexibleFuRTL.py + # tile out: + # 1. en (is data transferred) + recv_data = [x for x in s.recv_data] + recv_list = [] + for idx, data in enumerate(recv_data): + msg_dict = data.msg.__dict__ + tile_inport_dict = {"tile_inport_direction": tile_port_direction_dict[idx], "rdy": data.rdy} + tile_inport_dict.update(msg_dict) + recv_list.append(tile_inport_dict) + recv_md = markdown_table(recv_list).set_params(quote=False).get_markdown() + + out_data = [x for x in s.send_data] + out_list = [] + for idx, data in enumerate(out_data): + msg_dict = data.msg.__dict__ + tile_outport_dict = {"tile_outport_direction": tile_port_direction_dict[idx], "en": data.en} + tile_outport_dict.update(msg_dict) + out_list.append(tile_outport_dict) + out_md = markdown_table(out_list).set_params(quote=False).get_markdown() + return (f"\n## class[{s.__class__.__name__}]:\n" + f"- Tile recv:" + f"{recv_md}\n" + f"- FU element:\n" + f"{s.element.line_trace(verbosity=verbosity)}\n" + f"===>\n" + f"- Tile out:" + f"{out_md}\n") # Line trace - def line_trace( s ): - # recv: - # 1. rdy (if ready to receive data), if en and rdy: then data has been transferred (val, rdy are new type(protocol)) - # 2. data - # [3. opt will show in FU trace] - # FU: - # FlexibleFuRTL.py - # tile out: - # 1. en (is data transferred) - recv_data = [x for x in s.recv_data] - recv_list = [] - for idx, data in enumerate(recv_data): - msg_dict = data.msg.__dict__ - tile_inport_dict = {"tile_inport_direction": tile_port_direction_dict[idx], "rdy": data.rdy} - tile_inport_dict.update(msg_dict) - recv_list.append(tile_inport_dict) - recv_md = markdown_table(recv_list).set_params(quote=False).get_markdown() - - out_data = [x for x in s.send_data] - out_list = [] - for idx, data in enumerate(out_data): - msg_dict = data.msg.__dict__ - tile_outport_dict = {"tile_outport_direction": tile_port_direction_dict[idx], "en": data.en} - tile_outport_dict.update(msg_dict) - out_list.append(tile_outport_dict) - out_md = markdown_table(out_list).set_params(quote=False).get_markdown() - return (f"\n## class[{s.__class__.__name__}]:\n" - f"- Tile recv:" - f"{recv_md}\n" - f"- FU element:\n" - f"{s.element.line_trace()}\n" - f"===>\n" - f"- Tile out:" - f"{out_md}\n") + def line_trace( s, verbosity=0 ): + if verbosity == 0: + recv_str = "|".join([str(x.msg) for x in s.recv_data]) + channel_recv_str = "|".join([str(x.recv.msg) for x in s.channel]) + channel_send_str = "|".join([str(x.send.msg) for x in s.channel]) + out_str = "|".join(["(" + str(x.msg.payload) + "," + str(x.msg.predicate) + ")" for x in s.send_data]) + return f"{recv_str} => [{s.crossbar.recv_opt.msg}] ({s.element.line_trace()}) => {channel_recv_str} => {channel_send_str} => {out_str}" + else: + return s.verbose_trace(verbosity=verbosity) diff --git a/tile/TileSeparateCrossbarRTL.py b/tile/TileSeparateCrossbarRTL.py index 4129d50..fda984c 100644 --- a/tile/TileSeparateCrossbarRTL.py +++ b/tile/TileSeparateCrossbarRTL.py @@ -191,101 +191,115 @@ def update_opt(): s.routing_crossbar.recv_opt.rdy & \ s.fu_crossbar.recv_opt.rdy - + # verbose trace if verbosity > 0 + def verbose_trace(s, verbosity=1): + recv_data = [x.msg.__dict__ for x in s.recv_data] + recv_list = [] + for idx, data in enumerate(recv_data): + port_direction = tile_port_direction_dict[idx] + dict_with_direction = {"inport_direction": port_direction} + dict_with_direction.update(data) + recv_list.append(dict_with_direction) + recv_md = markdown_table(recv_list).set_params(quote=False).get_markdown() + + routing_crossbar_dict = dict(s.routing_crossbar.recv_opt.msg.__dict__) + routing_crossbar_dict['ctrl'] = OPT_SYMBOL_DICT[routing_crossbar_dict['ctrl']] + routing_crossbar_dict['predicate'] = int(routing_crossbar_dict['predicate']) + routing_crossbar_dict['fu_in'] = [int(fi) for fi in routing_crossbar_dict['fu_in']] + routing_crossbar_dict['fu_xbar_outport'] = [int(fxop) for fxop in routing_crossbar_dict['fu_xbar_outport']] + routing_crossbar_dict['routing_predicate_in'] = [int(rpi) for rpi in + routing_crossbar_dict['routing_predicate_in']] + routing_crossbar_dict['routing_xbar_outport'] = [int(rxop) for rxop in + routing_crossbar_dict['routing_xbar_outport']] + routing_crossbar_str = "\n".join([(key + ": " + str(value)) for key, value in routing_crossbar_dict.items()]) + + fu_crossbar_dict = dict(s.fu_crossbar.recv_opt.msg.__dict__) + fu_crossbar_dict['ctrl'] = OPT_SYMBOL_DICT[fu_crossbar_dict['ctrl']] + fu_crossbar_dict['predicate'] = int(fu_crossbar_dict['predicate']) + fu_crossbar_dict['fu_in'] = [int(fi) for fi in fu_crossbar_dict['fu_in']] + fu_crossbar_dict['fu_xbar_outport'] = [int(fxop) for fxop in fu_crossbar_dict['fu_xbar_outport']] + fu_crossbar_dict['routing_predicate_in'] = [int(rpi) for rpi in fu_crossbar_dict['routing_predicate_in']] + fu_crossbar_dict['routing_xbar_outport'] = [int(rxop) for rxop in fu_crossbar_dict['routing_xbar_outport']] + fu_crossbar_str = "\n".join([(key + ": " + str(value)) for key, value in fu_crossbar_dict.items()]) + + tile_out_channel_recv_data = [x.recv.msg.__dict__ for x in s.tile_out_channel] + tile_out_channel_recv_data_list = [] + for idx, data in enumerate(tile_out_channel_recv_data): + port_direction = tile_port_direction_dict[idx] + dict_with_direction = {"inport_direction": port_direction} + dict_with_direction.update(data) + tile_out_channel_recv_data_list.append(dict_with_direction) + tile_out_channel_recv_md = markdown_table(tile_out_channel_recv_data_list).set_params(quote=False).get_markdown() + + tile_out_channel_send_data = [x.send.msg.__dict__ for x in s.tile_out_channel] + tile_out_channel_send_data_list = [] + for idx, data in enumerate(tile_out_channel_send_data): + port_direction = tile_port_direction_dict[idx] + dict_with_direction = {"outport_direction": port_direction} + dict_with_direction.update(data) + tile_out_channel_send_data_list.append(dict_with_direction) + tile_out_channel_send_md = markdown_table(tile_out_channel_send_data_list).set_params(quote=False).get_markdown() + + fu_in_channel_recv_data = [x.recv.msg.__dict__ for x in s.fu_in_channel] + fu_in_channel_recv_data_list = [] + for idx, data in enumerate(fu_in_channel_recv_data): + port_direction = tile_port_direction_dict[idx] + dict_with_direction = {"inport_direction": port_direction} + dict_with_direction.update(data) + fu_in_channel_recv_data_list.append(dict_with_direction) + fu_in_channel_recv_md = markdown_table(fu_in_channel_recv_data_list).set_params(quote=False).get_markdown() + + fu_in_channel_send_data = [x.send.msg.__dict__ for x in s.fu_in_channel] + fu_in_channel_send_data_list = [] + for idx, data in enumerate(fu_in_channel_send_data): + port_direction = tile_port_direction_dict[idx] + dict_with_direction = {"outport_direction": port_direction} + dict_with_direction.update(data) + fu_in_channel_send_data_list.append(dict_with_direction) + fu_in_channel_send_md = markdown_table(fu_in_channel_send_data_list).set_params(quote=False).get_markdown() + + tile_outports_data = [x.msg.__dict__ for x in s.send_data] + tile_outports_data_list = [] + for idx, data in enumerate(tile_outports_data): + port_direction = tile_port_direction_dict[idx] + dict_with_direction = {"outport_direction": port_direction} + dict_with_direction.update(data) + tile_outports_data_list.append(dict_with_direction) + tile_outports_md = markdown_table(tile_outports_data_list).set_params(quote=False).get_markdown() + + return (f'\n## class: {s.__class__.__name__}\n' + f'- tile_inports:\n' + f'{recv_md}\n' + f'===>\n' + f'- routing_crossbar:\n' + f'{routing_crossbar_str}\n' + f'- fu_crossbar:\n' + f'{fu_crossbar_str}\n' + f'- element:\n' + f'{s.element.line_trace()}\n' + f'- tile_out_channels_recv:\n' + f'{tile_out_channel_recv_md}\n' + f'===>\n' + f'- tile_out_channel_send:\n' + f'{tile_out_channel_send_md}\n' + f'- fu_in_channels_recv:\n' + f'{fu_in_channel_recv_md}\n' + f'===>\n' + f'- fu_in_channels_send:\n' + f'{fu_in_channel_send_md}\n' + f'===>\n' + f'- tile_outports:\n' + f'{tile_outports_md}\n') # Line trace - def line_trace( s ): - recv_data = [x.msg.__dict__ for x in s.recv_data] - recv_list = [] - for idx, data in enumerate(recv_data): - port_direction = tile_port_direction_dict[idx] - dict_with_direction = {"inport_direction": port_direction} - dict_with_direction.update(data) - recv_list.append(dict_with_direction) - recv_md = markdown_table(recv_list).set_params(quote=False).get_markdown() - - routing_crossbar_dict = dict(s.routing_crossbar.recv_opt.msg.__dict__) - routing_crossbar_dict['ctrl'] = OPT_SYMBOL_DICT[routing_crossbar_dict['ctrl']] - routing_crossbar_dict['predicate'] = int(routing_crossbar_dict['predicate']) - routing_crossbar_dict['fu_in'] = [int(fi) for fi in routing_crossbar_dict['fu_in']] - routing_crossbar_dict['fu_xbar_outport'] = [int(fxop) for fxop in routing_crossbar_dict['fu_xbar_outport']] - routing_crossbar_dict['routing_predicate_in'] = [int(rpi) for rpi in routing_crossbar_dict['routing_predicate_in']] - routing_crossbar_dict['routing_xbar_outport'] = [int(rxop) for rxop in routing_crossbar_dict['routing_xbar_outport']] - routing_crossbar_str = "\n".join([(key + ": " + str(value)) for key, value in routing_crossbar_dict.items()]) - - fu_crossbar_dict = dict(s.fu_crossbar.recv_opt.msg.__dict__) - fu_crossbar_dict['ctrl'] = OPT_SYMBOL_DICT[fu_crossbar_dict['ctrl']] - fu_crossbar_dict['predicate'] = int(fu_crossbar_dict['predicate']) - fu_crossbar_dict['fu_in'] = [int(fi) for fi in fu_crossbar_dict['fu_in']] - fu_crossbar_dict['fu_xbar_outport'] = [int(fxop) for fxop in fu_crossbar_dict['fu_xbar_outport']] - fu_crossbar_dict['routing_predicate_in'] = [int(rpi) for rpi in fu_crossbar_dict['routing_predicate_in']] - fu_crossbar_dict['routing_xbar_outport'] = [int(rxop) for rxop in fu_crossbar_dict['routing_xbar_outport']] - fu_crossbar_str = "\n".join([(key + ": " + str(value)) for key, value in fu_crossbar_dict.items()]) - - tile_out_channel_recv_data = [x.recv.msg.__dict__ for x in s.tile_out_channel] - tile_out_channel_recv_data_list = [] - for idx, data in enumerate(tile_out_channel_recv_data): - port_direction = tile_port_direction_dict[idx] - dict_with_direction = {"inport_direction": port_direction} - dict_with_direction.update(data) - tile_out_channel_recv_data_list.append(dict_with_direction) - tile_out_channel_recv_md = markdown_table(tile_out_channel_recv_data_list).set_params(quote=False).get_markdown() - - tile_out_channel_send_data = [x.send.msg.__dict__ for x in s.tile_out_channel] - tile_out_channel_send_data_list = [] - for idx, data in enumerate(tile_out_channel_send_data): - port_direction = tile_port_direction_dict[idx] - dict_with_direction = {"outport_direction": port_direction} - dict_with_direction.update(data) - tile_out_channel_send_data_list.append(dict_with_direction) - tile_out_channel_send_md = markdown_table(tile_out_channel_send_data_list).set_params(quote=False).get_markdown() - - fu_in_channel_recv_data = [x.recv.msg.__dict__ for x in s.fu_in_channel] - fu_in_channel_recv_data_list = [] - for idx, data in enumerate(fu_in_channel_recv_data): - port_direction = tile_port_direction_dict[idx] - dict_with_direction = {"inport_direction": port_direction} - dict_with_direction.update(data) - fu_in_channel_recv_data_list.append(dict_with_direction) - fu_in_channel_recv_md = markdown_table(fu_in_channel_recv_data_list).set_params(quote=False).get_markdown() - - fu_in_channel_send_data = [x.send.msg.__dict__ for x in s.fu_in_channel] - fu_in_channel_send_data_list = [] - for idx, data in enumerate(fu_in_channel_send_data): - port_direction = tile_port_direction_dict[idx] - dict_with_direction = {"outport_direction": port_direction} - dict_with_direction.update(data) - fu_in_channel_send_data_list.append(dict_with_direction) - fu_in_channel_send_md = markdown_table(fu_in_channel_send_data_list).set_params(quote=False).get_markdown() - - tile_outports_data = [x.msg.__dict__ for x in s.send_data] - tile_outports_data_list = [] - for idx, data in enumerate(tile_outports_data): - port_direction = tile_port_direction_dict[idx] - dict_with_direction = {"outport_direction": port_direction} - dict_with_direction.update(data) - tile_outports_data_list.append(dict_with_direction) - tile_outports_md = markdown_table(tile_outports_data_list).set_params(quote=False).get_markdown() - - return (f'\n## class: {s.__class__.__name__}\n' - f'- tile_inports:\n' - f'{recv_md}\n' - f'===>\n' - f'- routing_crossbar:\n' - f'{routing_crossbar_str}\n' - f'- fu_crossbar:\n' - f'{fu_crossbar_str}\n' - f'- element:\n' - f'{s.element.line_trace()}\n' - f'- tile_out_channels_recv:\n' - f'{tile_out_channel_recv_md}\n' - f'===>\n' - f'- tile_out_channel_send:\n' - f'{tile_out_channel_send_md}\n' - f'- fu_in_channels_recv:\n' - f'{fu_in_channel_recv_md}\n' - f'===>\n' - f'- fu_in_channels_send:\n' - f'{fu_in_channel_send_md}\n' - f'===>\n' - f'- tile_outports:\n' - f'{tile_outports_md}\n') + def line_trace( s, verbosity=0 ): + if verbosity == 0: + recv_str = "|".join([str(x.msg) for x in s.recv_data]) + tile_out_channel_recv_str = "|".join([str(x.recv.msg) for x in s.tile_out_channel]) + tile_out_channel_send_str = "|".join([str(x.send.msg) for x in s.tile_out_channel]) + fu_in_channel_recv_str = "|".join([str(x.recv.msg) for x in s.fu_in_channel]) + fu_in_channel_send_str = "|".join([str(x.send.msg) for x in s.fu_in_channel]) + out_str = "|".join(["(" + str(x.msg.payload) + "," + str(x.msg.predicate) + ")" for x in s.send_data]) + return f"tile_inports: {recv_str} => [routing_crossbar: {s.routing_crossbar.recv_opt.msg} || fu_crossbar: {s.fu_crossbar.recv_opt.msg} || element: {s.element.line_trace()} || tile_out_channels: {tile_out_channel_recv_str} => {tile_out_channel_send_str} || fu_in_channels: {fu_in_channel_recv_str} => {fu_in_channel_send_str}] => tile_outports: {out_str} ## " + # return f"{recv_str} => [{s.crossbar.recv_opt.msg}] ({s.element.line_trace()}) => {channel_recv_str} => {channel_send_str} => {out_str}" + else: + return s.verbose_trace(verbosity=verbosity)