From 022bdf3cdc0c251434981517ec80f7127b89cf83 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Fri, 8 Sep 2023 16:12:04 +0200 Subject: [PATCH] tools/litex_client: Add binary mode to read_memory and fix hex/binary prefix in dump_registers. --- litex/tools/litex_client.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/litex/tools/litex_client.py b/litex/tools/litex_client.py index ff6ac180f..07b741973 100644 --- a/litex/tools/litex_client.py +++ b/litex/tools/litex_client.py @@ -129,19 +129,23 @@ def dump_registers(host, csr_csv, port, filter=None, binary=False): for name, register in bus.regs.__dict__.items(): if (filter is None) or filter in name: register_value = { - True : f"{register.read():032b}", - False : f"{register.read():08x}", + True : f"0b{register.read():032b}", + False : f"0x{register.read():08x}", }[binary] - print("0x{:08x} : 0x{} {}".format(register.addr, register_value, name)) + print("0x{:08x} : {} {}".format(register.addr, register_value, name)) bus.close() -def read_memory(host, csr_csv, port, addr, length): +def read_memory(host, csr_csv, port, addr, length, binary=False): bus = RemoteClient(host=host, csr_csv=csr_csv, port=port) bus.open() for offset in range(length//4): - print(f"0x{addr + 4*offset:08x} : 0x{bus.read(addr + 4*offset):08x}") + register_value = { + True : f"0b{bus.read(addr + 4*offset):032b}", + False : f"0x{bus.read(addr + 4*offset):08x}", + }[binary] + print(f"0x{addr + 4*offset:08x} : {register_value}") bus.close() @@ -406,6 +410,7 @@ def main(): port = port, addr = addr, length = int(args.length, 0), + binary = args.binary, ) if args.write: