Injecting an Error in NPI Registers - 2023.2 English

Standalone Library Documentation: BSP and Libraries Document Collection (UG643)

Document ID
UG643
Release Date
2023-12-13
Version
2023.2 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 file.
  • 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. NPI scan on PLM stops the scan.
  • When you perform CRAM/NPI error injection, ensure to follow the error injection sequence Stop > Inject > Start from a single master.