@@ -1071,6 +1071,63 @@ async def test_image_activated(dut):
1071
1071
await Timer (1 , "us" )
1072
1072
1073
1073
1074
+ @cocotb .test ()
1075
+ async def test_indirect_fifo_reset_access (dut ):
1076
+ i3c_controller , i3c_target , tb , recovery = await initialize (dut , timeout = 1000 )
1077
+
1078
+ tx_data_length = random .randint (10 , 50 )
1079
+
1080
+ # set virtual device dynamic address
1081
+ await i3c_controller .i3c_ccc_write (
1082
+ ccc = CCC .DIRECT .SETDASA , directed_data = [(VIRT_STATIC_ADDR , [VIRT_DYNAMIC_ADDR << 1 ])]
1083
+ )
1084
+
1085
+ # Write data to indirect FIFO through the recovery interface
1086
+ tx_data_before_reset = [random .randint (0 , 255 ) for _ in range (tx_data_length )]
1087
+ await recovery .command_write (
1088
+ VIRT_DYNAMIC_ADDR , I3cRecoveryInterface .Command .INDIRECT_FIFO_DATA , tx_data_before_reset
1089
+ )
1090
+
1091
+ # Clear FIFO (pointers too)
1092
+ await recovery .command_write (
1093
+ VIRT_DYNAMIC_ADDR , I3cRecoveryInterface .Command .INDIRECT_FIFO_CTRL , [0x00 , 0x01 , 0x00 , 0x00 ]
1094
+ )
1095
+
1096
+ # Clear FIFO reset
1097
+ await tb .write_csr_field (
1098
+ tb .reg_map .I3C_EC .SECFWRECOVERYIF .INDIRECT_FIFO_CTRL_0 .base_addr ,
1099
+ tb .reg_map .I3C_EC .SECFWRECOVERYIF .INDIRECT_FIFO_CTRL_0 .RESET ,
1100
+ 0xFF ,
1101
+ )
1102
+
1103
+ # Write data to indirect FIFO through the recovery interface
1104
+ tx_data_after_reset = [random .randint (0 , 255 ) for _ in range (tx_data_length )]
1105
+ await recovery .command_write (
1106
+ VIRT_DYNAMIC_ADDR , I3cRecoveryInterface .Command .INDIRECT_FIFO_DATA , tx_data_after_reset
1107
+ )
1108
+
1109
+ received_data = []
1110
+ for _ in range ((tx_data_length + 3 ) // 4 ):
1111
+ d = dword2int (
1112
+ await tb .read_csr (tb .reg_map .I3C_EC .SECFWRECOVERYIF .INDIRECT_FIFO_DATA .base_addr , 4 )
1113
+ )
1114
+ received_data .append (d )
1115
+
1116
+ tx_data_after_reset_as_dwords = []
1117
+ len_as_dwords = (tx_data_length + 3 ) // 4
1118
+ last_dword_bytes = (tx_data_length % 4 ) or 4
1119
+ for i in range (len_as_dwords ):
1120
+ dword = 0
1121
+ number_of_bytes = last_dword_bytes if ((len_as_dwords - 1 ) == i ) else 4
1122
+ for k in range (number_of_bytes ):
1123
+ dword = dword | (tx_data_after_reset [i * 4 + k ] << (k * 8 ))
1124
+ tx_data_after_reset_as_dwords .append (dword )
1125
+
1126
+ dut ._log .info ("TX dwords: " + " " .join ([hex (w ) for w in tx_data_after_reset_as_dwords ]))
1127
+ dut ._log .info ("RX dwords: " + " " .join ([hex (w ) for w in received_data ]))
1128
+ assert tx_data_after_reset_as_dwords == received_data
1129
+
1130
+
1074
1131
@cocotb .test ()
1075
1132
async def test_recovery_flow (dut ):
1076
1133
"""
0 commit comments