Skip to content

Commit

Permalink
Add option to show field output to dump command. #30
Browse files Browse the repository at this point in the history
  • Loading branch information
amykyta3 committed Aug 31, 2023
1 parent b862426 commit 60935b1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/peakrdl/__about__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.8.0"
__version__ = "0.9.0"
21 changes: 18 additions & 3 deletions src/peakrdl/cmd/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import math

from systemrdl import RDLListener, RDLWalker
from systemrdl.node import AddrmapNode, RegNode
from systemrdl.node import AddrmapNode, RegNode, FieldNode

from ..subcommand import ExporterSubcommand

Expand All @@ -11,9 +11,10 @@


class DumpListener(RDLListener):
def __init__(self, hex_digits:int, unroll: bool) -> None:
def __init__(self, hex_digits: int, unroll: bool, show_fields: bool) -> None:
self.hex_digits = hex_digits
self.unroll = unroll
self.show_fields = show_fields

def enter_Reg(self, node: RegNode) -> None:
if self.unroll:
Expand All @@ -28,6 +29,14 @@ def enter_Reg(self, node: RegNode) -> None:
node.get_path(empty_array_suffix="[{dim:d}]")
)

def enter_Field(self, node: FieldNode) -> None:
if not self.show_fields:
return

print(f"\t[{node.msb}:{node.lsb}] {node.inst_name}")




class Dump(ExporterSubcommand):
name = "dump"
Expand All @@ -42,10 +51,16 @@ def add_exporter_arguments(self, arg_group: 'argparse._ActionsContainer') -> Non
action="store_true",
help="Unroll arrays"
)
arg_group.add_argument(
"-F", "--fields",
default=False,
action="store_true",
help="Show fields"
)


def do_export(self, top_node: AddrmapNode, options: 'argparse.Namespace') -> None:
hex_digits = math.ceil(top_node.total_size.bit_length() / 4)
walker = RDLWalker(unroll=options.unroll)
listener = DumpListener(hex_digits, options.unroll)
listener = DumpListener(hex_digits, options.unroll, options.fields)
walker.walk(top_node, listener)

0 comments on commit 60935b1

Please sign in to comment.