Skip to content

Commit

Permalink
tools/litex_client: Add binary mode to read_memory and fix hex/binary…
Browse files Browse the repository at this point in the history
… prefix in dump_registers.
  • Loading branch information
enjoy-digital committed Sep 8, 2023
1 parent 6c30cb8 commit 022bdf3
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions litex/tools/litex_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -406,6 +410,7 @@ def main():
port = port,
addr = addr,
length = int(args.length, 0),
binary = args.binary,
)

if args.write:
Expand Down

0 comments on commit 022bdf3

Please sign in to comment.