Here are steps and code snippets illustrating how to inject an error in NPI registers for test purposes.
- Stop scan
/*To stop scan*/ Status = XSem_CmdNpiStopScan(&IpiInst, &IpiResp); if ((XST_SUCCESS == Status) && (CMD_ACK_NPI_STOPSCAN == IpiResp.RespMsg1) && (XST_SUCCESS == IpiResp.RespMsg2)) { xil_printf("[%s] Success: Stop\n\r", __func__); } else { xil_printf("[%s] Error: Stop Status 0x%x Ack 0x%x, Ret 0x%x\n\r", \ __func__, Status, IpiResp.RespMsg1, IpiResp.RespMsg2); goto END; }
- Inject
error
/* Inject error in first used SHA */ Status = XSem_CmdNpiInjectError(&IpiInst, &IpiResp); if ((XST_SUCCESS == Status) && (CMD_ACK_NPI_ERRINJECT == IpiResp.RespMsg1) && (XST_SUCCESS == IpiResp.RespMsg2)) { xil_printf("[%s] Success: Inject\n\r", __func__); } else { xil_printf("[%s] Error: Inject Status 0x%x Ack 0x%x, Ret 0x%x\n\r", \ __func__, Status, IpiResp.RespMsg1, IpiResp.RespMsg2); goto END; }
- Start scan to detect injected error
/*To start scan*/ Status = XSem_CmdNpiStartScan(&IpiInst, &IpiResp); if ((XST_SUCCESS == Status) && (CMD_ACK_NPI_STARTSCAN == IpiResp.RespMsg1) && (XST_SUCCESS == IpiResp.RespMsg2)) { xil_printf("[%s] Success: Start\n\r", __func__); } else { xil_printf("[%s] Error: Start Status 0x%x Ack 0x%x, Ret 0x%x\n\r", \ __func__, Status, IpiResp.RespMsg1, IpiResp.RespMsg2); goto END; }
Wait for the XilSEM library to detect and report the error. The following code illustrates how to validate if the error injection was successful.
/*To validate injection*/ TimeoutCount = 4U; while (TimeoutCount != 0U) { Status = XSem_CmdNpiGetStatus(&NpiStatus); if (XST_SUCCESS != Status) { xil_printf("[%s] ERROR: NPI Status read failure\n\r", \ __func__, Status); goto END; } /* Read NPI_SCAN_ERROR status bit */ TempA_32 = ((NpiStatus.Status & 0x00020000U) >> 17U); if (TempA_32 == 1U) { goto END; } TimeoutCount--; /* Small delay before polling again */ usleep(25000); } xil_printf("[%s] ERROR: Timeout occurred waiting for error\n\r", __func__); Status = XST_FAILURE; END: return Status;
Note:
- All the macros used in the code snippets are defined in xsem_client_api.h
- The above code snippets are demonstrated through examples in the XilSEM library using xsem_cram_example.c and xsem_npi_example.c. You can import these examples into the Vitis IDE to get more implementation details.
- When an error is injected in NPI golden SHA value, this condition is treated as uncorrectable error. XilSEM on PLM stops the scan.