|
@@ -6,7 +6,7 @@ wire boundary: bytes are serialized as 8N1 bits at 217 system clocks/bit.
|
|
|
|
|
|
|
|
import cocotb
|
|
import cocotb
|
|
|
from cocotb.clock import Clock
|
|
from cocotb.clock import Clock
|
|
|
-from cocotb.triggers import Event, ReadOnly, RisingEdge, SimTimeoutError, with_timeout
|
|
|
|
|
|
|
+from cocotb.triggers import Event, NextTimeStep, ReadOnly, ReadWrite, RisingEdge, SimTimeoutError, with_timeout
|
|
|
|
|
|
|
|
|
|
|
|
|
CLKS_PER_BIT = 217
|
|
CLKS_PER_BIT = 217
|
|
@@ -38,6 +38,7 @@ async def clocks(dut, count: int) -> None:
|
|
|
|
|
|
|
|
|
|
|
|
|
async def send_uart_byte(dut, value: int) -> None:
|
|
async def send_uart_byte(dut, value: int) -> None:
|
|
|
|
|
+ await ReadWrite()
|
|
|
dut.host_uart_rx.value = 0
|
|
dut.host_uart_rx.value = 0
|
|
|
await clocks(dut, CLKS_PER_BIT)
|
|
await clocks(dut, CLKS_PER_BIT)
|
|
|
for bit in range(8):
|
|
for bit in range(8):
|
|
@@ -48,6 +49,7 @@ async def send_uart_byte(dut, value: int) -> None:
|
|
|
|
|
|
|
|
|
|
|
|
|
async def send_frame(dut, packet: bytes) -> None:
|
|
async def send_frame(dut, packet: bytes) -> None:
|
|
|
|
|
+ await NextTimeStep()
|
|
|
for value in packet:
|
|
for value in packet:
|
|
|
await send_uart_byte(dut, value)
|
|
await send_uart_byte(dut, value)
|
|
|
|
|
|
|
@@ -142,6 +144,12 @@ async def test_set_all_get_temperature_over_real_uart(dut):
|
|
|
assert observed["overlap"] is True
|
|
assert observed["overlap"] is True
|
|
|
assert int(dut.motor_en_n.value) == 0
|
|
assert int(dut.motor_en_n.value) == 0
|
|
|
|
|
|
|
|
|
|
+ while True:
|
|
|
|
|
+ await RisingEdge(dut.sys_clk)
|
|
|
|
|
+ await ReadOnly()
|
|
|
|
|
+ if int(dut.x_step.value) == 0 and int(dut.y_step.value) == 0:
|
|
|
|
|
+ break
|
|
|
|
|
+ await clocks(dut, 4)
|
|
|
await send_frame(dut, frame(GET_TEMPERATURE, b""))
|
|
await send_frame(dut, frame(GET_TEMPERATURE, b""))
|
|
|
response = bytearray()
|
|
response = bytearray()
|
|
|
for byte_index in range(33):
|
|
for byte_index in range(33):
|