From ede93650d52a33ba036fbb83aa0065441a063f1d Mon Sep 17 00:00:00 2001 From: yuqisun Date: Sat, 21 Dec 2024 19:24:36 +0800 Subject: [PATCH] format FlexibleFuRTL --- fu/flexible/FlexibleFuRTL.py | 51 ++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/fu/flexible/FlexibleFuRTL.py b/fu/flexible/FlexibleFuRTL.py index 3e31674..5bdbb80 100644 --- a/fu/flexible/FlexibleFuRTL.py +++ b/fu/flexible/FlexibleFuRTL.py @@ -8,8 +8,6 @@ Date : Dec 24, 2019 """ -import json - from py_markdown_table.markdown_table import markdown_table from pymtl3 import * @@ -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')