Timer and Interrupts in jupyter-python

-PYNQ Z2 with image V3.0.0

I have a while loop, but I only want each iteration to last for 10 seconds. Currently, I determine this by calculating the working time, recalculating it after each iteration, and turning the while condition to False when the time reaches 10 seconds.

start_time = time.time()  
Flag = True
while Flag:

    current_time = time.time() 

    if current_time - start_time >= 10:
        Flag = False

However, this significantly reduces the frequency of my loop. Therefore, I want to implement an external timer that stops my loop when 10 seconds have passed.

How can I achieve this? I’m not familiar with C++ development, so it would be best if I could implement this using Verilog, Block Design, or Python.

1 Like

Interrupt example here:
https://pynq.readthedocs.io/en/latest/pynq_libraries/interrupt.html

There is an AXI timer IP which you can use so you don’t need to create the timer in Verilog. However, you should note that the Zynq PS and PL are in different (clock) domains, and the time it takes to service the interrupt from Python will vary. i.e. it won’t be deterministic and therefore may not stop at exactly 10 seconds and will vary slightly.

Cathal