tb: phy_core: Fix col/crs detection
Detecting non-clock signal edges with RisingEdge and FallingEdge is not
very robust, and is recommended against. Track edges manually.
Fixes: f6f3f02
("Add phy_core")
Signed-off-by: Sean Anderson <seanga2@gmail.com>
This commit is contained in:
parent
aa4ccf07c0
commit
fb588994b7
|
@ -142,17 +142,21 @@ async def test_transfer(phy):
|
||||||
|
|
||||||
async def count_crs():
|
async def count_crs():
|
||||||
nonlocal crs
|
nonlocal crs
|
||||||
|
last_crs = 0
|
||||||
while True:
|
while True:
|
||||||
await RisingEdge(phy.crs)
|
await RisingEdge(phy.clk)
|
||||||
crs += 1
|
if phy.crs.value and not last_crs:
|
||||||
await FallingEdge(phy.crs)
|
crs += 1
|
||||||
|
last_crs = phy.crs.value
|
||||||
|
|
||||||
async def count_col():
|
async def count_col():
|
||||||
nonlocal col
|
nonlocal col
|
||||||
|
last_col = 0
|
||||||
while True:
|
while True:
|
||||||
await RisingEdge(phy.col)
|
await RisingEdge(phy.clk)
|
||||||
col += 1
|
if phy.col.value and not last_col:
|
||||||
await FallingEdge(phy.col)
|
col += 1
|
||||||
|
last_col = phy.col.value
|
||||||
|
|
||||||
await cocotb.start(count_crs())
|
await cocotb.start(count_crs())
|
||||||
await cocotb.start(count_col())
|
await cocotb.start(count_col())
|
||||||
|
|
Loading…
Reference in New Issue