Skip to content

Commit

Permalink
format FlexibleFuRTL
Browse files Browse the repository at this point in the history
  • Loading branch information
yuqisun committed Dec 21, 2024
1 parent 40fc3f8 commit ede9365
Showing 1 changed file with 25 additions and 26 deletions.
51 changes: 25 additions & 26 deletions fu/flexible/FlexibleFuRTL.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
Date : Dec 24, 2019
"""
import json

from py_markdown_table.markdown_table import markdown_table
from pymtl3 import *

Expand Down Expand Up @@ -117,36 +115,37 @@ def comb_logic():


def line_trace( s ):
opt_str = " #"
if s.recv_opt.en:
opt_str = OPT_SYMBOL_DICT[s.recv_opt.msg.ctrl]

out_md = markdown_table([x.msg.__dict__ for x in s.send_out]).set_params(quote=False).get_markdown()

recv_data = [x.msg.__dict__ for x in s.recv_in]
# for clk n
# recv: opt+rdy(if ready to receive opt) and [rdy(if ready to receive data) and msg(data) for each inport(total 4 for now)]
# ? what is recv_const for ?
# 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_data = [x for x in s.recv_in]
recv_list = []
for idx, data in enumerate(recv_data):
port_direction = tile_port_direction_dict[idx]
dict_with_direction = {"port_direction": port_direction}
dict_with_direction.update(data)
recv_list.append(dict_with_direction)
msg_dict = data.msg.__dict__
fu_inport_dict = {"fu_inport_idx": idx, "rdy": data.rdy}
fu_inport_dict.update(msg_dict)
recv_list.append(fu_inport_dict)
recv_md = markdown_table(recv_list).set_params(quote=False).get_markdown()

out_data = [x for x in s.send_out]
out_list = []
for idx, data in enumerate(out_data):
msg_dict = data.msg.__dict__
fu_outport_dict = {"fu_outport_idx": idx, "en": data.en}
fu_outport_dict.update(msg_dict)
out_list.append(fu_outport_dict)
out_md = markdown_table(out_list).set_params(quote=False).get_markdown()

return (f'## class: {s.__class__.__name__}\n'
f'- recv:'
f'- recv:\n'
f' opt: {opt_ctrl}, opt_rdy: {opt_rdy}\n'
f' data:'
f'{recv_md}\n'
f'- opt ({opt_str}):\n'
f' (P{s.recv_opt.msg.predicate})\n'
f' const: {str(s.recv_const.msg.__dict__)}\n'
f' en: {s.recv_const.en}\n'
f'===>\n'
f'- out:'
f'{out_md}\n'
f'- recv_opt.rdy: {s.recv_opt.rdy}\n'
f'- recv_in[0].rdy: {s.recv_in[0].rdy}\n'
f'- recv_in[1].rdy: {s.recv_in[1].rdy}\n'
f'- recv_predicate.msg: {str(s.recv_predicate.msg.__dict__)}\n'
f'- opt: {OPT_SYMBOL_DICT[s.recv_opt.msg.ctrl]}\n'
f'- recv_opt.en: {s.recv_opt.en}\n'
f'- send[0].en: {s.send_out[0].en}\n')
f'{out_md}\n')

0 comments on commit ede9365

Please sign in to comment.