Quellcode durchsuchen

test-fix: synchronize UART e2e after motor completion

Codex Resource Selftest vor 4 Monaten
Ursprung
Commit
1da914ed52

+ 28 - 0
tests/cocotb/test_prod2u_door_temp_uart_e2e.pre-sync.diff

@@ -0,0 +1,28 @@
+diff --git a/tests/cocotb/test_prod2u_door_temp_uart_e2e.py b/tests/cocotb/test_prod2u_door_temp_uart_e2e.py
+index 0e4c13b..5a04a14 100644
+--- a/tests/cocotb/test_prod2u_door_temp_uart_e2e.py
++++ b/tests/cocotb/test_prod2u_door_temp_uart_e2e.py
+@@ -6,7 +6,7 @@ wire boundary: bytes are serialized as 8N1 bits at 217 system clocks/bit.
+ 
+ import cocotb
+ 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
+@@ -38,6 +38,7 @@ async def clocks(dut, count: int) -> None:
+ 
+ 
+ async def send_uart_byte(dut, value: int) -> None:
++    await ReadWrite()
+     dut.host_uart_rx.value = 0
+     await clocks(dut, CLKS_PER_BIT)
+     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:
++    await NextTimeStep()
+     for value in packet:
+         await send_uart_byte(dut, value)

+ 9 - 1
tests/cocotb/test_prod2u_door_temp_uart_e2e.py

@@ -6,7 +6,7 @@ wire boundary: bytes are serialized as 8N1 bits at 217 system clocks/bit.
 
 import cocotb
 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
@@ -38,6 +38,7 @@ async def clocks(dut, count: int) -> None:
 
 
 async def send_uart_byte(dut, value: int) -> None:
+    await ReadWrite()
     dut.host_uart_rx.value = 0
     await clocks(dut, CLKS_PER_BIT)
     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:
+    await NextTimeStep()
     for value in packet:
         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 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""))
         response = bytearray()
         for byte_index in range(33):

+ 26 - 0
tests/cocotb/test_prod2u_door_temp_uart_e2e.sync-cause.md

@@ -0,0 +1,26 @@
+# Real-UART synchronization record
+
+- Worktree: `C:\Users\Administrator\CodexTemp\prod2u-final-convergence-b2a3230e66f74a35bb74ac6730e58bb5`
+- Baseline HEAD before this follow-up: `72600bc672522f91bf62047b1cfac065dae131c2`
+- Pre-existing uncommitted patch: `test_prod2u_door_temp_uart_e2e.pre-sync.diff`
+
+## Root cause
+
+The motor observer sets completion on the 450th rising edge. At that moment the
+motor output can still be high. The RTL drives `x_step` and `y_step` low on the
+next 500 us tick, then the controller returns through `ST_MOTOR`, `ST_DRAIN`,
+and `ST_IDLE`. Until that transition completes, `frame_rx` does not have
+`accept_enable=1`.
+
+The test sent the 6-byte GET frame immediately after observer completion. Its
+approximately 520.8 us wire duration therefore overlapped the motor drain and
+was discarded as a complete frame. The I2C/temperature DUT path was separately
+confirmed to be a read-only calculation path without a deadlock; the existing
+100 ms response-byte timeout remains sufficient.
+
+## Required test-only synchronization
+
+After motor completion, wait until both real DUT outputs `x_step` and `y_step`
+are low, then wait four additional `sys_clk` rising edges before sending GET.
+This synchronizes the test with the existing RTL state transition without
+changing the UART protocol, timeout, or assertions.