Skip to content

Commit

Permalink
QSPI tests: make more robust by immediately detecting deasserted CS line
Browse files Browse the repository at this point in the history
  • Loading branch information
purdeaandrei committed Sep 11, 2024
1 parent b15d10b commit dca941d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions software/tests/gateware/test_qspi.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest
from amaranth import *
from amaranth.sim import Simulator
from amaranth.sim import Simulator, BrokenTrigger
from amaranth.lib import io

from glasgow.gateware.ports import PortGroup
Expand All @@ -26,8 +26,11 @@ class CSDeasserted(Exception):
pass

async def watch_cs(cs_o, triggers):
*values, cs_o = await triggers.sample(cs_o)
if cs_o == 1:
try:
*values, posedge_cs_o, cs_o = await triggers.posedge(cs_o).sample(cs_o)
except BrokenTrigger: # Workaround for amaranth bug: https://github.com/amaranth-lang/amaranth/issues/1508
raise CSDeasserted # both our original trigger and posedge of cs happened at the same time. We choose to prioritize CS being deasserted.
if posedge_cs_o or cs_o == 1:
raise CSDeasserted
return values

Expand Down

0 comments on commit dca941d

Please sign in to comment.