tb: uart_rx: Export putchar
This function is useful for other testbenches. Export it. Signed-off-by: Sean Anderson <seanga2@gmail.com>
This commit is contained in:
parent
d89fd13238
commit
587a567188
|
@ -17,6 +17,11 @@ def as_bits(c):
|
|||
yield c & 1
|
||||
c >>= 1
|
||||
|
||||
async def putchar(rx, c):
|
||||
for bit in (0, *as_bits(c), 1):
|
||||
rx.value = bit
|
||||
await Timer(BIT_STEPS)
|
||||
|
||||
@cocotb.test(timeout_time=1, timeout_unit='ms')
|
||||
async def test_rx(uart):
|
||||
uart.clk.value = BinaryValue('Z')
|
||||
|
@ -30,11 +35,6 @@ async def test_rx(uart):
|
|||
await cocotb.start(Clock(uart.clk, 8, units='ns').start())
|
||||
await FallingEdge(uart.clk)
|
||||
|
||||
async def putchar(c):
|
||||
for bit in (0, *as_bits(c), 1):
|
||||
uart.rx.value = bit
|
||||
await Timer(BIT_STEPS)
|
||||
|
||||
msg = b"Hell\0"
|
||||
signals = {
|
||||
'clk': uart.clk,
|
||||
|
@ -45,7 +45,7 @@ async def test_rx(uart):
|
|||
|
||||
await cocotb.start(recv_packet(signals, msg))
|
||||
for c in msg:
|
||||
await putchar(c)
|
||||
await putchar(uart.rx, c)
|
||||
|
||||
overflows = 0
|
||||
frame_errors = 0
|
||||
|
@ -69,8 +69,8 @@ async def test_rx(uart):
|
|||
assert frame_errors == 1
|
||||
|
||||
uart.ready.value = 0
|
||||
await putchar(0xFF)
|
||||
await putchar(0)
|
||||
await putchar(uart.rx, 0xFF)
|
||||
await putchar(uart.rx, 0)
|
||||
|
||||
assert overflows == 1
|
||||
|
||||
|
|
Loading…
Reference in New Issue