Rework reset logic to better handle X/Z

Signed-off-by: Alex Forencich <alex@alexforencich.com>
This commit is contained in:
Alex Forencich
2025-09-07 13:21:40 -07:00
parent 7077200912
commit 71be7f50d5

View File

@@ -23,7 +23,7 @@ THE SOFTWARE.
""" """
import cocotb import cocotb
from cocotb.triggers import RisingEdge, FallingEdge from cocotb.triggers import Edge
class Reset: class Reset:
@@ -56,11 +56,14 @@ class Reset:
async def _run_reset(self, reset_signal, active_level): async def _run_reset(self, reset_signal, active_level):
while True: while True:
if bool(reset_signal.value): await Edge(reset_signal)
await FallingEdge(reset_signal) try:
self._ext_reset = not active_level level = bool(int(reset_signal.value))
self._update_reset() except ValueError:
else: continue
await RisingEdge(reset_signal) if level:
self._ext_reset = active_level self._ext_reset = active_level
self._update_reset() self._update_reset()
else:
self._ext_reset = not active_level
self._update_reset()