Hardware is inherently parallel—multiple blocks work simultaneously. Python is inherently sequential. Coroutines bridge this gap.
A coroutine is a function that can pause execution and return control to the scheduler (the simulator). When it pauses, other coroutines can run. This mimics parallelism.
# Standard Function (Blocking)
def my_func():
return 10
# Coroutine (Can Pause)
async def my_driver(dut):
dut.a.value = 1
await Timer(10, "ns") # <--- Pauses here!
dut.a.value = 0