Skip to content

Commit

Permalink
tools/litex_client: Add Auto-Refresh to Mem Read/Mem Dump.
Browse files Browse the repository at this point in the history
  • Loading branch information
enjoy-digital committed Jan 6, 2025
1 parent d3258a3 commit 3875a4c
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions litex/tools/litex_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,10 @@ def led_callback(sender):
# Memory Read.
dpg.add_separator()
dpg.add_text("Mem Read:")
with dpg.group(horizontal=True):
dpg.add_checkbox(label="Auto-Refresh", tag="auto_refresh_mem_read", default_value=False)
dpg.add_text("Delay (s):")
dpg.add_input_float(tag="mem_read_delay", default_value=1.0, width=100)
with dpg.group(horizontal=True):
dpg.add_text("Address:")
dpg.add_input_text(
Expand Down Expand Up @@ -462,6 +466,10 @@ def led_callback(sender):
# Memory Dump
dpg.add_separator()
dpg.add_text("Mem Dump")
with dpg.group(horizontal=True):
dpg.add_checkbox(label="Auto-Refresh", tag="auto_refresh_mem_dump", default_value=False)
dpg.add_text("Delay (s):")
dpg.add_input_float(tag="mem_dump_delay", default_value=1.0, width=100)
with dpg.group(horizontal=True):
# Base.
dpg.add_text("Base:")
Expand Down Expand Up @@ -529,13 +537,18 @@ def led_callback(sender):
dpg.set_axis_limits("vccbram_y", 0, 1.8)

def timer_callback(refresh=1e-1, xadc_points=100):
last_mem_read_time = time.time()
last_mem_dump_time = time.time()

if with_xadc:
temp = gen_xadc_data(get_xadc_temp, n=xadc_points)
vccint = gen_xadc_data(get_xadc_vccint, n=xadc_points)
vccaux = gen_xadc_data(get_xadc_vccaux, n=xadc_points)
vccbram = gen_xadc_data(get_xadc_vccbram, n=xadc_points)

while dpg.is_dearpygui_running():
now = time.time()

# CSR Update.
for name, reg in bus.regs.__dict__.items():
value = reg.read()
Expand Down Expand Up @@ -566,6 +579,27 @@ def timer_callback(refresh=1e-1, xadc_points=100):
for i in range(8): # FIXME; Get num.
dpg.set_value(f"btn{i}", bool(get_buttons(i)))

# Mem Read Auto-Refresh.
if dpg.does_item_exist("auto_refresh_mem_read"):
if dpg.get_value("auto_refresh_mem_read"):
delay_sec = dpg.get_value("mem_read_delay")
if (now - last_mem_read_time) >= delay_sec:
try:
read_addr = int(dpg.get_value("read_addr"), 0)
val = bus.read(read_addr)
dpg.set_value("read_value", f"0x{val:08X}")
except ValueError:
pass
last_mem_read_time = now

# Mem Dump Auto-Refresh.
if dpg.does_item_exist("auto_refresh_mem_dump"):
if dpg.get_value("auto_refresh_mem_dump"):
delay_sec = dpg.get_value("mem_dump_delay")
if (now - last_mem_dump_time) >= delay_sec:
refresh_dump_table()
last_mem_dump_time = now

time.sleep(refresh)

timer_thread = threading.Thread(target=timer_callback)
Expand Down

0 comments on commit 3875a4c

Please sign in to comment.