Skip to content

Commit

Permalink
Simulation traces are not understandable for human being tancheng#23
Browse files Browse the repository at this point in the history
  • Loading branch information
yuqisun committed Dec 19, 2024
1 parent d1dd6b3 commit 73d5db8
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion cgra/CGRAKingMeshRTL.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 5 additions & 3 deletions fu/flexible/FlexibleFuRTL.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
Date : Dec 24, 2019
"""
import json

from pymtl3 import *
from ...fu.single.MemUnitRTL import MemUnitRTL
Expand Down Expand Up @@ -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}) '

4 changes: 2 additions & 2 deletions mem/ctrl/CtrlMemRTL.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)}'

12 changes: 6 additions & 6 deletions mem/data/DataMemRTL.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]}'
Expand Down
14 changes: 8 additions & 6 deletions tile/TileRTL.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Author : Cheng Tan
Date : Dec 11, 2019
"""
import json


from pymtl3 import *
Expand Down Expand Up @@ -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}"

0 comments on commit 73d5db8

Please sign in to comment.