@@ -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