Skip to content

Commit 1e65d26

Browse files
Add test scenario for tbit error in RxLenH
Test covers both scenarios where error detection is enabled and disabled. Internal-tag: [#95717]
1 parent d81bff7 commit 1e65d26

2 files changed

Lines changed: 62 additions & 2 deletions

File tree

verification/cocotb/top/lib_i3c_top/i3c_recovery_interface_fixed.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ async def command_write_abort(self, address, command, data=None, abort_after_byt
307307
await self.controller.send_stop()
308308
self.controller.give_bus_control()
309309

310-
async def command_write_tbit_error(self, address, command, data=None, error_byte_index=0):
310+
async def command_write_tbit_error(self, address, command, data=None, error_byte_index=0, end_with_rstart=False):
311311
"""
312312
Issues a write command with an intentional T-bit (parity) error on a specific byte.
313313
@@ -342,7 +342,10 @@ async def command_write_tbit_error(self, address, command, data=None, error_byte
342342
inject_error = (i == error_byte_index)
343343
await self.controller.send_byte_tbit(byte, inject_tbit_err=inject_error)
344344

345-
await self.controller.send_stop()
345+
if not end_with_rstart:
346+
await self.controller.send_stop()
347+
else:
348+
await self.controller.send_start()
346349
self.controller.give_bus_control()
347350

348351
async def command_read_tbit_error(self, address, command, error_byte_index=0):

verification/cocotb/top/lib_i3c_top/test_recovery.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,6 +1208,63 @@ async def rapid_fire_scenario():
12081208
)
12091209
await run_scenario("Scenario 15: Rapid-fire aborts (5x)", rapid_fire_scenario)
12101210

1211+
# =========================================================================
1212+
# Scenario 16: T-bit (parity) error on Length MSB byte (detection disabled)
1213+
# Scenario 17: T-bit (parity) error on Length MSB byte (detection enabled)
1214+
# =========================================================================
1215+
async def lenh_pec_err_scenario(pec_det_en=True):
1216+
# Set PEC detection (bit 7)
1217+
err_ctrl = dword2int(
1218+
await tb.read_csr(tb.reg_map.I3C_EC.TTI.TARGET_ERR_CTRL.base_addr, 4)
1219+
)
1220+
pec_det_en_value = (err_ctrl | (1 << 7)) if pec_det_en else (err_ctrl & ~(1 << 7))
1221+
1222+
await tb.write_csr(
1223+
tb.reg_map.I3C_EC.TTI.TARGET_ERR_CTRL.base_addr,
1224+
int2dword(pec_det_en_value), 4
1225+
)
1226+
1227+
tb.te_error_monitor.expect_error(2)
1228+
await recovery.command_write_tbit_error(
1229+
VIRT_DYNAMIC_ADDR,
1230+
I3cRecoveryInterface.Command.RECOVERY_CTRL,
1231+
[0xAA, 0xBB, 0xCC],
1232+
2, # Length MSB byte
1233+
end_with_rstart=True
1234+
)
1235+
tb.te_error_monitor.clear_expectations()
1236+
1237+
# Bring back previous PEC detection
1238+
await tb.write_csr(
1239+
tb.reg_map.I3C_EC.TTI.TARGET_ERR_CTRL.base_addr,
1240+
int2dword(err_ctrl), 4
1241+
)
1242+
1243+
status = dword2int(
1244+
await tb.read_csr(
1245+
tb.reg_map.I3C_EC.SECFWRECOVERYIF.DEVICE_STATUS_0.base_addr, 4
1246+
)
1247+
)
1248+
protocol_status = (status >> 8) & 0xFF
1249+
1250+
# Ensure CRC error (0x4) is reported if detection enabled
1251+
if pec_det_en:
1252+
assert protocol_status == 0x4
1253+
else:
1254+
assert protocol_status == 0x0
1255+
1256+
await run_scenario(
1257+
"Scenario 16: T-bit error on Length MSB (error detection disabled)",
1258+
lenh_pec_err_scenario,
1259+
False
1260+
)
1261+
1262+
await run_scenario(
1263+
"Scenario 17: T-bit error on Length MSB (error detection enabled)",
1264+
lenh_pec_err_scenario,
1265+
True
1266+
)
1267+
12111268
# =========================================================================
12121269
# Final Verification: Do a complete valid write and read cycle
12131270
# =========================================================================

0 commit comments

Comments
 (0)