tb: uart_tx: Check stop bit

Ensure that the stop bit is asserted at the end of each character.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
This commit is contained in:
Sean Anderson 2023-03-04 13:39:09 -05:00
parent 7110eee136
commit d89fd13238
1 changed files with 3 additions and 1 deletions

View File

@ -25,6 +25,8 @@ async def getchar(signals):
result >>= 1 result >>= 1
result |= 0x80 if signals['tx'].value else 0 result |= 0x80 if signals['tx'].value else 0
await Timer(BIT_STEPS)
assert signals['tx'].value
return result return result
@cocotb.test(timeout_time=1, timeout_unit='ms') @cocotb.test(timeout_time=1, timeout_unit='ms')
@ -56,6 +58,6 @@ async def test_tx(uart):
}) })
now = get_sim_time() now = get_sim_time()
expected = BIT_STEPS * (10 * len(msg) - 1.5) expected = BIT_STEPS * (10 * len(msg) - 0.5)
actual = now - then actual = now - then
assert abs(actual - expected) / expected < 0.01 assert abs(actual - expected) / expected < 0.01