tools/litex_client: Add filter parameter to dump_registrers to only dump/display the filtered registers:

ex: litex_cli --regs --filter=pcie_phy will only dump/display pcie_phy registers.
This commit is contained in:
Florent Kermarrec 2021-04-13 13:44:12 +02:00
parent 5011b564c3
commit f014e4cbd2
1 changed files with 11 additions and 9 deletions

View File

@ -106,7 +106,7 @@ def dump_identifier(port):
wb.close()
def dump_registers(port):
def dump_registers(port, filter=None):
wb = RemoteClient(port=port)
wb.open()
@ -115,6 +115,7 @@ def dump_registers(port):
wb.base_address = -wb.mems.csr.base
for name, register in wb.regs.__dict__.items():
if (filter is None) or filter in name:
print("0x{:08x} : 0x{:08x} {}".format(register.addr, register.read(), name))
wb.close()
@ -138,10 +139,11 @@ def write_memory(port, addr, data):
# Run ----------------------------------------------------------------------------------------------
def main():
parser = argparse.ArgumentParser(description="LiteX Client utility")
parser.add_argument("--port", default="1234", help="Host bind port")
parser.add_argument("--ident", action="store_true", help="Dump SoC identifier")
parser.add_argument("--regs", action="store_true", help="Dump SoC registers")
parser = argparse.ArgumentParser(description="LiteX Client utility.")
parser.add_argument("--port", default="1234", help="Host bind port.")
parser.add_argument("--ident", action="store_true", help="Dump SoC identifier.")
parser.add_argument("--regs", action="store_true", help="Dump SoC registers.")
parser.add_argument("--filter", default=None, help="Registers filter (to be used with --regs).")
parser.add_argument("--read", default=None, help="Do a MMAP Read to SoC bus (--read addr)")
parser.add_argument("--write", default=None, nargs=2, help="Do a MMAP Write to SoC bus (--write addr data)")
args = parser.parse_args()
@ -152,7 +154,7 @@ def main():
dump_identifier(port=port)
if args.regs:
dump_registers(port=port)
dump_registers(port=port, filter=args.filter)
if args.read:
read_memory(port=port, addr=int(args.read, 0))