From 7f164e9c1507517b3df9517de9a42899460cef8b Mon Sep 17 00:00:00 2001 From: Yuqi Sun <791079835@qq.com> Date: Mon, 9 Dec 2024 22:58:20 +0800 Subject: [PATCH] Simulation traces are not understandable for human being #23 --- cgra/CGRAKingMeshRTL.py | 2 +- fu/flexible/FlexibleFuRTL.py | 8 +++++--- mem/ctrl/CtrlMemRTL.py | 4 ++-- mem/data/DataMemRTL.py | 12 ++++++------ tile/TileRTL.py | 14 ++++++++------ 5 files changed, 22 insertions(+), 18 deletions(-) diff --git a/cgra/CGRAKingMeshRTL.py b/cgra/CGRAKingMeshRTL.py index e9e37b0..a5d1dff 100644 --- a/cgra/CGRAKingMeshRTL.py +++ b/cgra/CGRAKingMeshRTL.py @@ -155,5 +155,5 @@ def line_trace( s ): # 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" + res += "\n data_mem:: [" + s.data_mem.line_trace() + "] \n" return res diff --git a/fu/flexible/FlexibleFuRTL.py b/fu/flexible/FlexibleFuRTL.py index 2fdbadd..3be4caf 100644 --- a/fu/flexible/FlexibleFuRTL.py +++ b/fu/flexible/FlexibleFuRTL.py @@ -8,6 +8,7 @@ Date : Dec 24, 2019 """ +import json from pymtl3 import * from ...fu.single.MemUnitRTL import MemUnitRTL @@ -111,11 +112,12 @@ 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 ): 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}) ' + out_str = f'[{",".join([str(x.msg.__dict__) for x in s.send_out])}]' + recv_str = f'[{",".join([str(x.msg.__dict__) for x in s.recv_in])}]' + return f'class: {s.__class__.__name__}, [recv: {recv_str}] opt: {opt_str} (P{s.recv_opt.msg.predicate}) (const: {str(s.recv_const.msg.__dict__)}, 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: {str(s.recv_predicate.msg.__dict__)}, {OPT_SYMBOL_DICT[s.recv_opt.msg.ctrl]}, recv_opt.en: {s.recv_opt.en}, send[0].en: {s.send_out[0].en}) ' diff --git a/mem/ctrl/CtrlMemRTL.py b/mem/ctrl/CtrlMemRTL.py index 644882f..0b41bfd 100644 --- a/mem/ctrl/CtrlMemRTL.py +++ b/mem/ctrl/CtrlMemRTL.py @@ -73,6 +73,6 @@ def update_raddr(): s.reg_file.raddr[0] <<= s.reg_file.raddr[0] + AddrType( 1 ) def line_trace( s ): - out_str = "||".join([ str(data) for data in s.reg_file.regs ]) - return f'{s.recv_ctrl.msg} : [{out_str}] : {s.send_ctrl.msg}' + out_str = f'[{", ".join([ str(data.__dict__) for data in s.reg_file.regs ])}]' + return f'class: {s.__class__.__name__}, recv_ctrl_msg: {s.recv_ctrl.msg.__dict__} : out: {out_str} : send_ctrl_msg: {str(s.send_ctrl.msg.__dict__)}' diff --git a/mem/data/DataMemRTL.py b/mem/data/DataMemRTL.py index ac7bda0..9f620a6 100644 --- a/mem/data/DataMemRTL.py +++ b/mem/data/DataMemRTL.py @@ -99,12 +99,12 @@ def update_signal(): s.recv_wdata[i].rdy @= Bits1( 1 ) def line_trace(s): - 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}' + recv_raddr_str = "recv_read_addr: " + f'[{", ".join([str(data.msg) for data in s.recv_raddr])}]' + recv_waddr_str = "recv_write_addr: " + f'[{", ".join([str(data.msg) for data in s.recv_waddr])}]' + recv_wdata_str = "recv_write_data: " + f'[{", ".join([str(data.msg.__dict__) for data in s.recv_wdata])}]' + content_str = "content: " + f'[{", ".join([str(data.__dict__) for data in s.reg_file.regs])}]' + send_rdata_str = "send_read_data: " + f'[{", ".join([str(data.msg) for data in s.send_rdata])}]' + return f'class: {s.__class__.__name__}, {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]}' diff --git a/tile/TileRTL.py b/tile/TileRTL.py index dd68900..3add022 100644 --- a/tile/TileRTL.py +++ b/tile/TileRTL.py @@ -6,6 +6,7 @@ Author : Cheng Tan Date : Dec 11, 2019 """ +import json from pymtl3 import * @@ -123,12 +124,13 @@ 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 + # Line trace def line_trace( s ): - - 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}" + recv_str = f'[{", ".join([ str(x.msg.__dict__) for x in s.recv_data ])}]' + # recv_json = json.dumps(s.recv_data) + channel_recv_str = f'[{", ".join([ str(x.recv.msg.__dict__) for x in s.channel ])}]' + channel_send_str = f'[{", ".join([ str(x.send.msg.__dict__) for x in s.channel ])}]' + out_str = f'[{", ".join([ "{send_msg_payload: "+str(x.msg.payload)+", send_msg_predicate: "+str(x.msg.predicate)+"}" for x in s.send_data ])}]' + return f"class: {s.__class__.__name__}, recv: {recv_str} => [recv_opt_msg: {str(s.crossbar.recv_opt.msg.__dict__)}] ({s.element.line_trace()}) => channel_recv: {channel_recv_str} => channel_send: {channel_send_str} => out: {out_str}"