Injecting an Error in NPI Registers - 2021.1 English

Xilinx Standalone Library Documentation OS and Libraries Document Collection (UG643)

Document ID
UG643
Release Date
2021-06-16
Version
2021.1 English
Here are steps and code snippets illustrating how to inject an error in NPI registers for test purposes.
  1. 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;
    }
    
  2. 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;
    }
    
  3. 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.