tb: axis_mii_tx.py: Rework test_underflow

This test has a lot of duplication, which makes it harder to modify.
Stick most of it in a loop.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
This commit is contained in:
Sean Anderson 2023-01-11 17:26:20 -05:00
parent 68751229a0
commit a3ae038f4f
1 changed files with 19 additions and 23 deletions

View File

@ -216,29 +216,25 @@ async def test_underflow(mac):
send, status = await start(mac, range(32), ratio=30) send, status = await start(mac, range(32), ratio=30)
await underflow(mac, send, status) await underflow(mac, send, status)
send, status = await start(mac, [*range(56), None]) #from math import floor
await underflow(mac, send, status) # Solution to (IPG + PREAMBLE + x) * BIT_TIME = ratio * x
send, status = await start(mac, [*range(58), None]) # end = floor(200 / (ratio - 10))
await underflow(mac, send, status)
send, status = await start(mac, [*range(60), None]) for x in (56, 58, 60):
# Error on last byte
send, status = await start(mac, [*range(x), None])
await underflow(mac, send, status) await underflow(mac, send, status)
send, status = await start(mac, [*range(56), None, 1]) # Error with more to come
await underflow(mac, send, status) send, status = await start(mac, [*range(x), None, 1])
send, status = await start(mac, [*range(58), None, 1])
await underflow(mac, send, status)
send, status = await start(mac, [*range(60), None, 1])
await underflow(mac, send, status) await underflow(mac, send, status)
send, status = await start(mac, [*range(56), None]) # Underflow with collision
await restart(mac, (8 + 55) * BYTE_TIME_NS) send, status = await start(mac, [*range(x), None])
await restart(mac, (8 + x) * BYTE_TIME_NS - 1)
if x <= 56:
await underflow(mac, send, status) await underflow(mac, send, status)
send, status = await start(mac, [*range(58), None]) else:
await restart(mac, (8 + 57) * BYTE_TIME_NS)
await send.join()
assert await status.join() == Status.LATE_COLLISION
send, status = await start(mac, [*range(60), None])
await restart(mac, (8 + 59) * BYTE_TIME_NS)
await send.join() await send.join()
assert await status.join() == Status.LATE_COLLISION assert await status.join() == Status.LATE_COLLISION