Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
7f164e9
Simulation traces are not understandable for human being #23
yuqisun Dec 9, 2024
8145fcf
Merge branch 'tancheng:master' into 23-simulation-traces-are-not-unde…
yuqisun Dec 14, 2024
30d3a31
Simulation traces are not understandable for human being #23
yuqisun Dec 16, 2024
86de5ef
Simulation traces are not understandable for human being #23
yuqisun Dec 16, 2024
fe9ba2c
Simulation traces are not understandable for human being #23
yuqisun Dec 16, 2024
9b9c737
Populate values for #ctrl and use decimal for fu_in, outport and pred…
yuqisun Dec 17, 2024
dddb3e1
Populate values for #ctrl and use decimal for fu_in, outport and pred…
yuqisun Dec 17, 2024
04f63fa
Populate values for #ctrl and use decimal for fu_in, outport and pred…
yuqisun Dec 17, 2024
3e0a506
Use decimal for trace bit values instead of 0x
yuqisun Dec 17, 2024
3c65021
Format Ctrl and Crossbar RTL
yuqisun Dec 17, 2024
0dfb132
Format Ctrl and Crossbar RTL
yuqisun Dec 17, 2024
84c1921
Format data mem
yuqisun Dec 19, 2024
73d5db8
Simulation traces are not understandable for human being #23
yuqisun Dec 9, 2024
899ebf9
Simulation traces are not understandable for human being #23
yuqisun Dec 16, 2024
2640d30
Simulation traces are not understandable for human being #23
yuqisun Dec 16, 2024
2f5f354
Simulation traces are not understandable for human being #23
yuqisun Dec 16, 2024
fd1b30e
Populate values for #ctrl and use decimal for fu_in, outport and pred…
yuqisun Dec 17, 2024
1ce8c61
Populate values for #ctrl and use decimal for fu_in, outport and pred…
yuqisun Dec 17, 2024
a6eaf41
Populate values for #ctrl and use decimal for fu_in, outport and pred…
yuqisun Dec 17, 2024
bca2dde
Use decimal for trace bit values instead of 0x
yuqisun Dec 17, 2024
2fe23a8
Format Ctrl and Crossbar RTL
yuqisun Dec 17, 2024
839c979
Format Ctrl and Crossbar RTL
yuqisun Dec 17, 2024
11f53a1
Format data mem
yuqisun Dec 19, 2024
40fc3f8
Merge remote-tracking branch 'origin/23-simulation-traces-are-not-und…
yuqisun Dec 19, 2024
ede9365
format FlexibleFuRTL
yuqisun Dec 21, 2024
7d04f0c
format with directions and addr
yuqisun Dec 22, 2024
48a8a34
format with directions and addr
yuqisun Dec 22, 2024
1b33b9f
format CtrlMemRTL reg with sub header
yuqisun Dec 23, 2024
323bf85
format CtrlMemRTL with sub header
yuqisun Dec 23, 2024
bab8bee
format CtrlMemRTL with sub header
yuqisun Dec 23, 2024
0e0e8e9
Add verbosity level.
yuqisun Dec 24, 2024
a48dc05
print ctrl_memory when verbosity > 1
yuqisun Dec 25, 2024
9ed1abb
Merge branch 'master' into 23-simulation-traces-are-not-understandabl…
yuqisun Dec 25, 2024
e9054d8
verbose_trace calls verbose_trace, leave line_trace as it is.
yuqisun Dec 26, 2024
d798f19
Move to after from pymtl3 import *, we are sorting these in alphabet …
yuqisun Dec 26, 2024
834ccef
Optimize imports order and move common dicts to common
yuqisun Dec 26, 2024
58bb723
Test with verilog.
yuqisun Dec 26, 2024
dd750f7
extract common logic for verbose_trace
yuqisun Dec 26, 2024
787c94a
extract common logic for verbose_trace
yuqisun Dec 26, 2024
898e594
enable the verbosity for https://github.com/tancheng/VectorCGRA/blob/…
yuqisun Dec 26, 2024
57dfc34
1. TILE_PORT_DIRECTION_DICT -> TILE_PORT_DIRECTION_DICT_DESC
yuqisun Dec 27, 2024
f88c8f4
put line_trace() before verbose()
yuqisun Dec 27, 2024
8f9ecd8
Add verbose trace for CtrlMemDynamicRTL.py
yuqisun Dec 27, 2024
f702763
Remove the unnecessary space.
yuqisun Dec 28, 2024
877ab24
Remove the unnecessary space.
yuqisun Dec 28, 2024
a11819c
Remove the unnecessary space.
yuqisun Dec 28, 2024
51bbc5c
enable verbose_trace by default
yuqisun Dec 28, 2024
bf825b1
Control verbose_trace by set_param.
yuqisun Jan 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ jobs:
pip install -U git+https://github.com/tancheng/pymtl3.1@yo-struct-list-fix
pip install hypothesis
pip install pytest
pip install py-markdown-table
pip list

- name: Test and translate with pytest
Expand Down
25 changes: 19 additions & 6 deletions cgra/CGRAKingMeshRTL.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,23 @@ def construct( s, DataType, PredicateType, CtrlType, width, height,
s.tile[i].to_mem_wdata.rdy //= 0

# Line trace
def line_trace( s ):
# 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"
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)

# verbose trace
def verbose_trace(s, verbosity = 1):
res = ''
for (i, x) in enumerate(s.tile):
res += "# [tile" + str(i) + "]: " + x.verbose_trace(verbosity = verbosity) + x.ctrl_mem.verbose_trace(
verbosity = verbosity) + '\n'
res += f"data_mem: {s.data_mem.verbose_trace(verbosity = verbosity)}"
res += "------\n\n"
return res
27 changes: 20 additions & 7 deletions cgra/CgraCrossbarDataMemRingCtrlMemRTL.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,24 @@ def construct(s, DataType, PredicateType, CtrlPktType, CtrlSignalType,
s.tile[i].to_mem_wdata.rdy //= 0

# Line trace
def line_trace( s ):
# 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"
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)


def verbose_trace(self, verbosity = 1):
res = ''
for (i, x) in enumerate(self.tile):
res += "# [tile" + str(i) + "]: " + x.verbose_trace(verbosity = verbosity) + x.ctrl_mem.verbose_trace(verbosity = verbosity) + '\n'
# todo
# no verbose_trace for DataMemWithCrossbarRTL yet
res += f"data_mem: {self.data_mem.line_trace()}"
res += "------\n\n"
return res

1 change: 1 addition & 0 deletions cgra/translate/VectorCGRAKingMeshRTL_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def test_homo_4x4( cmdline_opts ):
else:
print( f' - set tile[{idx}] to scalar')
th.set_param( f'top.dut.tile[{idx}].construct', FuList=scalar_list )
th.set_param('top.dut.line_trace', verbosity = 1)

th.elaborate()
th.dut.set_metadata( VerilogTranslationPass.explicit_module_name,
Expand Down
59 changes: 48 additions & 11 deletions fu/flexible/FlexibleFuRTL.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
Date : Dec 24, 2019

"""
from py_markdown_table.markdown_table import markdown_table

from pymtl3 import *
from ...fu.single.MemUnitRTL import MemUnitRTL
from ...fu.single.AdderRTL import AdderRTL
from ...lib.basic.en_rdy.ifcs import SendIfcRTL, RecvIfcRTL
from ...lib.opt_type import *

Expand Down Expand Up @@ -111,11 +109,50 @@ 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}) '

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)


def verbose_trace_md_formatter(self, data_type, data):
assert data_type in [ "recv", "send" ]
data_list = [ x for x in data ]
result_list = []
for idx, fu_data in enumerate(data_list):
msg_dict = fu_data.msg.__dict__
if data_type is "recv":
fu_port_dict = { "fu_inport_idx": idx, "rdy": fu_data.rdy }
else:
fu_port_dict = { "fu_outport_idx": idx, "en": fu_data.en }
fu_port_dict.update(msg_dict)
result_list.append(fu_port_dict)
result_md = markdown_table(result_list).set_params(quote = False).get_markdown()
return result_md

# verbose trace if verbosity > 0
def verbose_trace(s, verbosity = 1):
# for clk n
# recv:
# 1. OPT: opt+rdy(if ready to receive opt)
# 2. Data: [rdy(if ready to receive data) and msg(data) for each inport(total 4 for now)]
# out: [en(if data is sent out) and msg for each outport(total 2 for now)]
opt_ctrl = OPT_SYMBOL_DICT[s.recv_opt.msg.ctrl]
opt_rdy = s.recv_opt.rdy
recv_md = s.verbose_trace_md_formatter("recv", s.recv_in)
send_md = s.verbose_trace_md_formatter("send", s.send_out)

return (f'## class: {s.__class__.__name__}\n'
f'- FU recv:\n'
f' FU opt: {opt_ctrl}, opt_rdy: {opt_rdy}\n'
f' FU data:'
f'{recv_md}\n'
f'===>\n'
f'- FU out:'
f'{send_md}')
22 changes: 22 additions & 0 deletions lib/util/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,25 @@
LINK_NO_MEM = 0
LINK_FROM_MEM = 1
LINK_TO_MEM = 2

TILE_PORT_DIRECTION_DICT_DESC = {
PORT_NORTH: "NORTH",
PORT_SOUTH: "SOUTH",
PORT_WEST: "WEST",
PORT_EAST: "EAST",
PORT_NORTHWEST: "NORTHWEST",
PORT_NORTHEAST: "NORTHEAST",
PORT_SOUTHEAST: "SOUTHEAST",
PORT_SOUTHWEST: "SOUTHWEST"
}

TILE_PORT_DIRECTION_DICT_SHORT_DESC = {
PORT_NORTH: "N",
PORT_SOUTH: "S",
PORT_WEST: "W",
PORT_EAST: "E",
PORT_NORTHWEST: "NW",
PORT_NORTHEAST: "NE",
PORT_SOUTHEAST: "SE",
PORT_SOUTHWEST: "SW"
}
131 changes: 126 additions & 5 deletions mem/ctrl/CtrlMemDynamicRTL.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@
Author : Cheng Tan
Date : Dec 20, 2024
"""

from pymtl3 import *
from py_markdown_table.markdown_table import markdown_table
from pymtl3.stdlib.primitive import RegisterFile

from ...lib.basic.en_rdy.ifcs import SendIfcRTL
from ...lib.basic.val_rdy.ifcs import ValRdyRecvIfcRTL
from ...lib.basic.val_rdy.queues import NormalQueueRTL
from ...lib.cmd_type import *
from ...lib.opt_type import *
from ...lib.util.common import TILE_PORT_DIRECTION_DICT_SHORT_DESC


class CtrlMemDynamicRTL(Component):

Expand Down Expand Up @@ -136,7 +138,126 @@ def update_raddr():
else:
s.reg_file.raddr[0] <<= s.reg_file.raddr[0] + CtrlAddrType(1)

def line_trace(s):
config_mem_str = "|".join([str(data) for data in s.reg_file.regs])
return f'{s.recv_pkt.msg} || config_mem: [{config_mem_str}] || out: {s.send_ctrl.msg}'
def line_trace(s, verbosity = 0):
if verbosity == 0:
config_mem_str = "|".join([str(data) for data in s.reg_file.regs])
return f'{s.recv_pkt.msg} || config_mem: [{config_mem_str}] || out: {s.send_ctrl.msg}'
else:
return s.verbose_trace(verbosity = verbosity)


def verbose_trace_normal_processor(self, data_dict):
if 'ctrl_operation' in data_dict:
data_dict['ctrl_operation'] = OPT_SYMBOL_DICT[ data_dict['ctrl_operation'] ]
if 'ctrl' in data_dict:
data_dict['ctrl'] = OPT_SYMBOL_DICT[ data_dict['ctrl'] ]

def verbose_trace_fu_in_processor(self, data_dict, sub_header, key_prefix = None):
fu_in_key = 'fu_in'
if key_prefix:
fu_in_key = key_prefix + fu_in_key
data_dict[fu_in_key] = [ int(fi) for fi in data_dict[fu_in_key] ]
fu_in_header = []
for idx, val in enumerate(data_dict[fu_in_key]):
fu_in_header.append(idx)
fu_in_header_str = "|".join([ f"{hd : ^3}" for hd in fu_in_header ])
data_dict[fu_in_key] = "|".join([ f"{v : ^3}" for v in data_dict[fu_in_key] ])
sub_header[fu_in_key] = fu_in_header_str

# outport: fu_xbar_outport, routing_xbar_outport
def verbose_trace_outport_processor(self, data_dict, sub_header, num_direction_ports, outport_key, key_prefix = None):
if key_prefix:
outport_key = key_prefix + outport_key
if outport_key in data_dict:
data_dict[outport_key] = [ int(op) for op in data_dict[outport_key] ]
fu_reg_num = 1
outport_sub_header = []
for idx, val in enumerate(data_dict[outport_key]):
# 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}}")
data_dict[outport_key][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)}}")
data_dict[outport_key][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 ])
data_dict[outport_key] = "|".join([ v for v in data_dict[outport_key] ])
sub_header[outport_key] = outport_sub_header_str

def verbose_trace_predicate_in_processor(self, data_dict, sub_header, num_direction_ports, key_prefix = None):
predicate_in_key = 'routing_predicate_in'
if key_prefix:
predicate_in_key = key_prefix + predicate_in_key
if predicate_in_key in data_dict:
data_dict[predicate_in_key] = [ int(pi) for pi in data_dict[predicate_in_key] ]
fu_out_num = 1
predicate_in_sub_header = []
for idx, val in enumerate(data_dict[predicate_in_key]):
# 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}}")
data_dict[predicate_in_key][idx] = f"{val : ^{len(hd) + 2}}"
# from fu
else:
hd = f"fu_out_{fu_out_num}"
predicate_in_sub_header.append(f"{hd : ^{len(hd)}}")
data_dict[predicate_in_key][idx] = f"{val : ^{len(hd)}}"
fu_out_num += 1
predicate_in_sub_header_str = "|".join([ hd for hd in predicate_in_sub_header ])
data_dict[predicate_in_key] = "|".join([ v for v in data_dict[predicate_in_key] ])
sub_header[predicate_in_key] = predicate_in_sub_header_str

def verbose_trace_data_processor(self, data_dict, num_direction_ports, key_prefix = None):
sub_header = {}
for key in data_dict.keys():
sub_header[key] = ''
self.verbose_trace_normal_processor(data_dict)
self.verbose_trace_fu_in_processor(data_dict, sub_header, key_prefix)
self.verbose_trace_outport_processor(data_dict, sub_header, num_direction_ports, 'fu_xbar_outport', key_prefix)
self.verbose_trace_outport_processor(data_dict, sub_header, num_direction_ports, 'routing_xbar_outport', key_prefix)
self.verbose_trace_predicate_in_processor(data_dict, sub_header, num_direction_ports, key_prefix)
return sub_header

# verbose trace
def verbose_trace(s, verbosity = 1):
num_routing_outports = len(s.reg_file.wdata[0].routing_xbar_outport)
num_fu_inports = len(s.reg_file.wdata[0].fu_in)
num_tile_outports = num_routing_outports - num_fu_inports

# recv_ctrl
recv_pkt_msg_dict = dict(s.recv_pkt.msg.__dict__)
recv_pkt_msg_header = s.verbose_trace_data_processor(recv_pkt_msg_dict, num_tile_outports, key_prefix = 'ctrl_')
recv_pkt_msg_list = [recv_pkt_msg_header, recv_pkt_msg_dict]
recv_pkt_msg_md = markdown_table(recv_pkt_msg_list).set_params(quote = False).get_markdown()

# send_ctrl
send_ctrl_msg_dict = dict(s.send_ctrl.msg.__dict__)
send_ctrl_sub_header = s.verbose_trace_data_processor(send_ctrl_msg_dict, num_tile_outports)
send_ctrl_msg_list = [send_ctrl_sub_header, send_ctrl_msg_dict]
send_ctrl_msg_md = markdown_table(send_ctrl_msg_list).set_params(quote = False).get_markdown()

if verbosity == 1:
return (f'\n## class: {s.__class__.__name__}\n'
f'- recv_pkt_msg:'
f'{recv_pkt_msg_md}\n\n'
f'- send_ctrl_msg:'
f'{send_ctrl_msg_md}\n\n')
else:
# reg
reg_dicts = [ dict(data.__dict__) for data in s.reg_file.regs ]
reg_sub_header = {}
for reg_dict in reg_dicts:
reg_sub_header = s.verbose_trace_data_processor(reg_dict, num_tile_outports)
reg_dicts.insert(0, reg_sub_header)
reg_md = markdown_table(reg_dicts).set_params(quote=False).get_markdown()
return (f'\n## class: {s.__class__.__name__}\n'
f'- recv_pkt_msg:'
f'{recv_pkt_msg_md}\n\n'
f'- send_ctrl_msg:'
f'{send_ctrl_msg_md}\n\n'
f'- config_memory: {reg_md}\n')
Loading
Loading