ECC Functions

__STATIC_FORCEINLINE int32_t ECC_IsGlobalSupportECC (void)
__STATIC_FORCEINLINE int32_t ECC_IsICacheSupportECC (void)
__STATIC_FORCEINLINE int32_t ECC_IsDCacheSupportECC (void)
__STATIC_FORCEINLINE int32_t ECC_IsTLBSupportECC (void)
__STATIC_FORCEINLINE int32_t ECC_IsILMSupportECC (void)
__STATIC_FORCEINLINE int32_t ECC_IsDLMSupportECC (void)
__STATIC_FORCEINLINE int32_t ECC_IsXorErrorInjectMode (void)
__STATIC_FORCEINLINE void ECC_EnableICacheECC (void)
__STATIC_FORCEINLINE void ECC_DisableICacheECC (void)
__STATIC_FORCEINLINE void ECC_EnableICacheECCExcp (void)
__STATIC_FORCEINLINE void ECC_DisableICacheECCExcp (void)
__STATIC_FORCEINLINE void ECC_EnableICacheECCCheck (void)
__STATIC_FORCEINLINE void ECC_DisableICacheECCCheck (void)
__STATIC_FORCEINLINE void ECC_EnableDCacheECC (void)
__STATIC_FORCEINLINE void ECC_DisableDCacheECC (void)
__STATIC_FORCEINLINE void ECC_EnableDCacheECCExcp (void)
__STATIC_FORCEINLINE void ECC_DisableDCacheECCExcp (void)
__STATIC_FORCEINLINE void ECC_EnableDCacheECCCheck (void)
__STATIC_FORCEINLINE void ECC_DisableDCacheECCCheck (void)
__STATIC_FORCEINLINE void ECC_ICacheTRamErrInject (uint32_t ecc_code, void *addr)
__STATIC_FORCEINLINE void ECC_ICacheDRamErrInject (uint32_t ecc_code, void *addr)
__STATIC_FORCEINLINE void ECC_ICacheErrRestore (void *addr)
__STATIC_FORCEINLINE void ECC_DCacheTRamErrInject (uint32_t ecc_code, void *addr)
__STATIC_FORCEINLINE void ECC_DCacheDRamErrInject (uint32_t ecc_code, void *addr)
__STATIC_FORCEINLINE void ECC_DCacheErrRestore (void *addr)
__STATIC_FORCEINLINE void ECC_EnableILM (void)
__STATIC_FORCEINLINE void ECC_DisableILM (void)
__STATIC_FORCEINLINE void ECC_EnableILMECC (void)
__STATIC_FORCEINLINE void ECC_DisableILMECC (void)
__STATIC_FORCEINLINE void ECC_EnableILMECCExcp (void)
__STATIC_FORCEINLINE void ECC_DisableILMECCExcp (void)
__STATIC_FORCEINLINE void ECC_EnableILMECCCheck (void)
__STATIC_FORCEINLINE void ECC_DisableILMECCCheck (void)
__STATIC_FORCEINLINE void ECC_ILMErrInject (uint32_t ecc_code, void *addr)
__STATIC_FORCEINLINE void ECC_ILMErrRestore (void *addr)
__STATIC_FORCEINLINE void ECC_EnableDLM (void)
__STATIC_FORCEINLINE void ECC_DisableDLM (void)
__STATIC_FORCEINLINE void ECC_EnableDLMECC (void)
__STATIC_FORCEINLINE void ECC_DisableDLMECC (void)
__STATIC_FORCEINLINE void ECC_EnableDLMECCExcp (void)
__STATIC_FORCEINLINE void ECC_DisableDLMECCExcp (void)
__STATIC_FORCEINLINE void ECC_EnableDLMECCCheck (void)
__STATIC_FORCEINLINE void ECC_DisableDLMECCCheck (void)
__STATIC_FORCEINLINE void ECC_DLMErrInject (uint32_t ecc_code, void *addr)
__STATIC_FORCEINLINE void ECC_DLMErrRestore (void *addr)
__STATIC_FORCEINLINE int32_t ECC_IsAnySingleBitErrorOccured (void)
__STATIC_FORCEINLINE int32_t ECC_IsICacheSingleBitErrorOccured (void)
__STATIC_FORCEINLINE int32_t ECC_IsDCacheSingleBitErrorOccured (void)
__STATIC_FORCEINLINE int32_t ECC_IsTLBSingleBitErrorOccured (void)
__STATIC_FORCEINLINE int32_t ECC_IsILMSingleBitErrorOccured (void)
__STATIC_FORCEINLINE int32_t ECC_IsDLMSingleBitErrorOccured (void)
__STATIC_FORCEINLINE void ECC_ClearAllSingleBitError (void)
__STATIC_FORCEINLINE void ECC_ClearICacheSingleBitError (void)
__STATIC_FORCEINLINE void ECC_ClearDCacheSingleBitError (void)
__STATIC_FORCEINLINE void ECC_ClearTLBSingleBitError (void)
__STATIC_FORCEINLINE void ECC_ClearILMSingleBitError (void)
__STATIC_FORCEINLINE void ECC_ClearDLMSingleBitError (void)
__STATIC_FORCEINLINE int32_t ECC_IsAnyDoubleBitErrorOccured (void)
__STATIC_FORCEINLINE int32_t ECC_IsICacheDoubleBitErrorOccured (void)
__STATIC_FORCEINLINE int32_t ECC_IsDCacheDoubleBitErrorOccured (void)
__STATIC_FORCEINLINE int32_t ECC_IsTLBDoubleBitErrorOccured (void)
__STATIC_FORCEINLINE int32_t ECC_IsILMDoubleBitErrorOccured (void)
__STATIC_FORCEINLINE int32_t ECC_IsDLMDoubleBitErrorOccured (void)
__STATIC_FORCEINLINE void ECC_ClearAllDoubleBitError (void)
__STATIC_FORCEINLINE void ECC_ClearICacheDoubleBitError (void)
__STATIC_FORCEINLINE void ECC_ClearDCacheDoubleBitError (void)
__STATIC_FORCEINLINE void ECC_ClearTLBDoubleBitError (void)
__STATIC_FORCEINLINE void ECC_ClearILMDoubleBitError (void)
__STATIC_FORCEINLINE void ECC_ClearDLMDoubleBitError (void)
static uint8_t ECC_GenerateECCCodeU32(uint32_t a)
static uint8_t ECC_GenerateECCCodeU64(uint64_t a)
ECC_ERROR_RAMID_MASK_ICACHE 1U
ECC_ERROR_RAMID_MASK_DCACHE 2U
ECC_ERROR_RAMID_MASK_TLB 4U
ECC_ERROR_RAMID_MASK_ILM 8U
ECC_ERROR_RAMID_MASK_DLM 16U
group ECC Functions

Functions that related to the ECC feature.

These functions provide access to the Error Correction Code (ECC) feature available in Nuclei N/NX processor cores. ECC is a memory protection mechanism that can detect and correct single-bit errors and detect double-bit errors in memory systems such as caches and local memories.

The ECC feature includes:

  • Detection of ECC support in various memory components (I-Cache, D-Cache, ILM, DLM, TLB)

  • Control functions to enable/disable ECC for different memory components

  • Error injection capabilities for testing purposes

  • Error detection and clearing functions for both single-bit and double-bit errors

  • Configuration of ECC exception handling

Defines

ECC_ERROR_RAMID_MASK_ICACHE 1U
ECC_ERROR_RAMID_MASK_DCACHE 2U
ECC_ERROR_RAMID_MASK_TLB 4U
ECC_ERROR_RAMID_MASK_ILM 8U
ECC_ERROR_RAMID_MASK_DLM 16U

Functions

__STATIC_FORCEINLINE int32_t ECC_IsGlobalSupportECC (void)

Check if the core globally supports ECC.

This function reads the machine configuration info CSR and checks if ECC is supported globally in the core.

Returns:

1 if ECC is globally supported, 0 otherwise

__STATIC_FORCEINLINE int32_t ECC_IsICacheSupportECC (void)

Check if I-Cache supports ECC.

This function checks if both I-Cache and ECC are supported in the core.

Returns:

1 if I-Cache supports ECC, 0 otherwise

__STATIC_FORCEINLINE int32_t ECC_IsDCacheSupportECC (void)

Check if D-Cache supports ECC.

This function checks if both D-Cache and ECC are supported in the core.

Returns:

1 if D-Cache supports ECC, 0 otherwise

__STATIC_FORCEINLINE int32_t ECC_IsTLBSupportECC (void)

Check if TLB supports ECC.

This function checks if both PLIC and TLB ECC are supported in the core. Note: TLB is only present with MMU, and when PLIC is present, MMU will be present.

Returns:

1 if TLB supports ECC, 0 otherwise

__STATIC_FORCEINLINE int32_t ECC_IsILMSupportECC (void)

Check if ILM supports ECC.

This function checks if both ILM and ECC are supported in the core.

Returns:

1 if ILM supports ECC, 0 otherwise

__STATIC_FORCEINLINE int32_t ECC_IsDLMSupportECC (void)

Check if DLM supports ECC.

This function checks if both DLM and ECC are supported in the core.

Returns:

1 if DLM supports ECC, 0 otherwise

__STATIC_FORCEINLINE int32_t ECC_IsXorErrorInjectMode (void)

Check if XOR error injection mode is supported.

This function reads the machine ECC code CSR and checks if error injection mode is suppported.

Returns:

1 if XOR error injection mode is enabled, 0 otherwise

__STATIC_FORCEINLINE void ECC_EnableICacheECC (void)

Enable ECC for I-Cache.

This function enables ECC for the instruction cache by setting the appropriate bit in the machine cache control CSR.

__STATIC_FORCEINLINE void ECC_DisableICacheECC (void)

Disable ECC for I-Cache.

This function disables ECC for the instruction cache by clearing the appropriate bit in the machine cache control CSR.

__STATIC_FORCEINLINE void ECC_EnableICacheECCExcp (void)

Enable ECC exception for I-Cache.

This function enables ECC exception for the instruction cache by setting the appropriate bit in the machine cache control CSR.

__STATIC_FORCEINLINE void ECC_DisableICacheECCExcp (void)

Disable ECC exception for I-Cache.

This function disables ECC exception for the instruction cache by clearing the appropriate bit in the machine cache control CSR.

__STATIC_FORCEINLINE void ECC_EnableICacheECCCheck (void)

Enable ECC checking for I-Cache.

This function enables ECC checking for the instruction cache by setting the appropriate bit in the machine cache control CSR.

__STATIC_FORCEINLINE void ECC_DisableICacheECCCheck (void)

Disable ECC checking for I-Cache.

This function disables ECC checking for the instruction cache by clearing the appropriate bit in the machine cache control CSR.

__STATIC_FORCEINLINE void ECC_EnableDCacheECC (void)

Enable ECC for D-Cache.

This function enables ECC for the data cache by setting the appropriate bit in the machine cache control CSR.

__STATIC_FORCEINLINE void ECC_DisableDCacheECC (void)

Disable ECC for D-Cache.

This function disables ECC for the data cache by clearing the appropriate bit in the machine cache control CSR.

__STATIC_FORCEINLINE void ECC_EnableDCacheECCExcp (void)

Enable ECC exception for D-Cache.

This function enables ECC exception for the data cache by setting the appropriate bit in the machine cache control CSR.

__STATIC_FORCEINLINE void ECC_DisableDCacheECCExcp (void)

Disable ECC exception for D-Cache.

This function disables ECC exception for the data cache by clearing the appropriate bit in the machine cache control CSR.

__STATIC_FORCEINLINE void ECC_EnableDCacheECCCheck (void)

Enable ECC checking for D-Cache.

This function enables ECC checking for the data cache by setting the appropriate bit in the machine cache control CSR.

__STATIC_FORCEINLINE void ECC_DisableDCacheECCCheck (void)

Disable ECC checking for D-Cache.

This function disables ECC checking for the data cache by clearing the appropriate bit in the machine cache control CSR.

__STATIC_FORCEINLINE void ECC_ICacheTRamErrInject (uint32_t ecc_code, void *addr)

Inject error into I-Cache Tag RAM.

This function injects an error into the I-Cache Tag RAM at the specified address with the given ECC code.

Parameters:
  • ecc_code[in] ECC code to inject

  • addr[in] Address where error should be injected

__STATIC_FORCEINLINE void ECC_ICacheDRamErrInject (uint32_t ecc_code, void *addr)

Inject error into I-Cache Data RAM.

This function injects an error into the I-Cache Data RAM at the specified address with the given ECC code.

Parameters:
  • ecc_code[in] ECC code to inject

  • addr[in] Address where error should be injected

__STATIC_FORCEINLINE void ECC_ICacheErrRestore (void *addr)

Restore I-Cache error at specified address.

This function restores the correct ECC code for the I-Cache line at the specified address.

Parameters:

addr[in] Address to restore

__STATIC_FORCEINLINE void ECC_DCacheTRamErrInject (uint32_t ecc_code, void *addr)

Inject error into D-Cache Tag RAM.

This function injects an error into the D-Cache Tag RAM at the specified address with the given ECC code.

Parameters:
  • ecc_code[in] ECC code to inject

  • addr[in] Address where error should be injected

__STATIC_FORCEINLINE void ECC_DCacheDRamErrInject (uint32_t ecc_code, void *addr)

Inject error into D-Cache Data RAM.

This function injects an error into the D-Cache Data RAM at the specified address with the given ECC code.

Parameters:
  • ecc_code[in] ECC code to inject

  • addr[in] Address where error should be injected

__STATIC_FORCEINLINE void ECC_DCacheErrRestore (void *addr)

Restore D-Cache error at specified address.

This function restores the correct ECC code for the D-Cache line at the specified address.

Parameters:

addr[in] Address to restore

__STATIC_FORCEINLINE void ECC_EnableILM (void)

Enable ILM.

This function enables ILM by setting the appropriate bit in the machine ILM control CSR.

__STATIC_FORCEINLINE void ECC_DisableILM (void)

Disable ILM.

This function disables ILM by clearing the appropriate bit in the machine ILM control CSR.

__STATIC_FORCEINLINE void ECC_EnableILMECC (void)

Enable ECC for ILM.

This function enables ECC for ILM by setting the appropriate bit in the machine ILM control CSR.

__STATIC_FORCEINLINE void ECC_DisableILMECC (void)

Disable ECC for ILM.

This function disables ECC for ILM by clearing the appropriate bit in the machine ILM control CSR.

__STATIC_FORCEINLINE void ECC_EnableILMECCExcp (void)

Enable ECC exception for ILM.

This function enables ECC exception for ILM by setting the appropriate bit in the machine ILM control CSR.

__STATIC_FORCEINLINE void ECC_DisableILMECCExcp (void)

Disable ECC exception for ILM.

This function disables ECC exception for ILM by clearing the appropriate bit in the machine ILM control CSR.

__STATIC_FORCEINLINE void ECC_EnableILMECCCheck (void)

Enable ECC checking for ILM.

This function enables ECC checking for ILM by setting the appropriate bit in the machine ILM control CSR.

__STATIC_FORCEINLINE void ECC_DisableILMECCCheck (void)

Disable ECC checking for ILM.

This function disables ECC checking for ILM by clearing the appropriate bit in the machine ILM control CSR.

__STATIC_FORCEINLINE void ECC_ILMErrInject (uint32_t ecc_code, void *addr)

Inject error into ILM.

This function injects an error into the ILM at the specified address with the given ECC code.

Parameters:
  • ecc_code[in] ECC code to inject

  • addr[in] Address where error should be injected

__STATIC_FORCEINLINE void ECC_ILMErrRestore (void *addr)

Restore ILM error at specified address.

This function restores the correct ECC code for the ILM at the specified address.

Parameters:

addr[in] Address to restore

__STATIC_FORCEINLINE void ECC_EnableDLM (void)

Enable DLM.

This function enables DLM by setting the appropriate bit in the machine DLM control CSR.

__STATIC_FORCEINLINE void ECC_DisableDLM (void)

Disable DLM.

This function disables DLM by clearing the appropriate bit in the machine DLM control CSR.

__STATIC_FORCEINLINE void ECC_EnableDLMECC (void)

Enable ECC for DLM.

This function enables ECC for DLM by setting the appropriate bit in the machine DLM control CSR.

__STATIC_FORCEINLINE void ECC_DisableDLMECC (void)

Disable ECC for DLM.

This function disables ECC for DLM by clearing the appropriate bit in the machine DLM control CSR.

__STATIC_FORCEINLINE void ECC_EnableDLMECCExcp (void)

Enable ECC exception for DLM.

This function enables ECC exception for DLM by setting the appropriate bit in the machine DLM control CSR.

__STATIC_FORCEINLINE void ECC_DisableDLMECCExcp (void)

Disable ECC exception for DLM.

This function disables ECC exception for DLM by clearing the appropriate bit in the machine DLM control CSR.

__STATIC_FORCEINLINE void ECC_EnableDLMECCCheck (void)

Enable ECC checking for DLM.

This function enables ECC checking for DLM by setting the appropriate bit in the machine DLM control CSR.

__STATIC_FORCEINLINE void ECC_DisableDLMECCCheck (void)

Disable ECC checking for DLM.

This function disables ECC checking for DLM by clearing the appropriate bit in the machine DLM control CSR.

__STATIC_FORCEINLINE void ECC_DLMErrInject (uint32_t ecc_code, void *addr)

Inject error into DLM.

This function injects an error into the DLM at the specified address with the given ECC code.

Parameters:
  • ecc_code[in] ECC code to inject

  • addr[in] Address where error should be injected

__STATIC_FORCEINLINE void ECC_DLMErrRestore (void *addr)

Restore DLM error at specified address.

This function restores the correct ECC code for the DLM at the specified address.

Parameters:

addr[in] Address to restore

__STATIC_FORCEINLINE int32_t ECC_IsAnySingleBitErrorOccured (void)

Check if any single-bit error has occurred.

This function checks if any single-bit error has occurred by reading the machine ECC code CSR.

Returns:

1 if any single-bit error has occurred, 0 otherwise

__STATIC_FORCEINLINE int32_t ECC_IsICacheSingleBitErrorOccured (void)

Check if I-Cache single-bit error has occurred.

This function checks if a single-bit error has occurred in the I-Cache.

Returns:

1 if I-Cache single-bit error has occurred, 0 otherwise

__STATIC_FORCEINLINE int32_t ECC_IsDCacheSingleBitErrorOccured (void)

Check if D-Cache single-bit error has occurred.

This function checks if a single-bit error has occurred in the D-Cache.

Returns:

1 if D-Cache single-bit error has occurred, 0 otherwise

__STATIC_FORCEINLINE int32_t ECC_IsTLBSingleBitErrorOccured (void)

Check if TLB single-bit error has occurred.

This function checks if a single-bit error has occurred in the TLB.

Returns:

1 if TLB single-bit error has occurred, 0 otherwise

__STATIC_FORCEINLINE int32_t ECC_IsILMSingleBitErrorOccured (void)

Check if ILM single-bit error has occurred.

This function checks if a single-bit error has occurred in the ILM.

Returns:

1 if ILM single-bit error has occurred, 0 otherwise

__STATIC_FORCEINLINE int32_t ECC_IsDLMSingleBitErrorOccured (void)

Check if DLM single-bit error has occurred.

This function checks if a single-bit error has occurred in the DLM.

Returns:

1 if DLM single-bit error has occurred, 0 otherwise

__STATIC_FORCEINLINE void ECC_ClearAllSingleBitError (void)

Clear all single-bit errors.

This function clears all single-bit errors by clearing the appropriate bits in the machine ECC code CSR.

__STATIC_FORCEINLINE void ECC_ClearICacheSingleBitError (void)

Clear I-Cache single-bit error.

This function clears the single-bit error in the I-Cache by clearing the appropriate bits in the machine ECC code CSR.

__STATIC_FORCEINLINE void ECC_ClearDCacheSingleBitError (void)

Clear D-Cache single-bit error.

This function clears the single-bit error in the D-Cache by clearing the appropriate bits in the machine ECC code CSR.

__STATIC_FORCEINLINE void ECC_ClearTLBSingleBitError (void)

Clear TLB single-bit error.

This function clears the single-bit error in the TLB by clearing the appropriate bits in the machine ECC code CSR.

__STATIC_FORCEINLINE void ECC_ClearILMSingleBitError (void)

Clear ILM single-bit error.

This function clears the single-bit error in the ILM by clearing the appropriate bits in the machine ECC code CSR.

__STATIC_FORCEINLINE void ECC_ClearDLMSingleBitError (void)

Clear DLM single-bit error.

This function clears the single-bit error in the DLM by clearing the appropriate bits in the machine ECC code CSR.

__STATIC_FORCEINLINE int32_t ECC_IsAnyDoubleBitErrorOccured (void)

Check if any double-bit error has occurred.

This function checks if any double-bit error has occurred by reading the machine ECC code CSR.

Returns:

1 if any double-bit error has occurred, 0 otherwise

__STATIC_FORCEINLINE int32_t ECC_IsICacheDoubleBitErrorOccured (void)

Check if I-Cache double-bit error has occurred.

This function checks if a double-bit error has occurred in the I-Cache.

Returns:

1 if I-Cache double-bit error has occurred, 0 otherwise

__STATIC_FORCEINLINE int32_t ECC_IsDCacheDoubleBitErrorOccured (void)

Check if D-Cache double-bit error has occurred.

This function checks if a double-bit error has occurred in the D-Cache.

Returns:

1 if D-Cache double-bit error has occurred, 0 otherwise

__STATIC_FORCEINLINE int32_t ECC_IsTLBDoubleBitErrorOccured (void)

Check if TLB double-bit error has occurred.

This function checks if a double-bit error has occurred in the TLB.

Returns:

1 if TLB double-bit error has occurred, 0 otherwise

__STATIC_FORCEINLINE int32_t ECC_IsILMDoubleBitErrorOccured (void)

Check if ILM double-bit error has occurred.

This function checks if a double-bit error has occurred in the ILM.

Returns:

1 if ILM double-bit error has occurred, 0 otherwise

__STATIC_FORCEINLINE int32_t ECC_IsDLMDoubleBitErrorOccured (void)

Check if DLM double-bit error has occurred.

This function checks if a double-bit error has occurred in the DLM.

Returns:

1 if DLM double-bit error has occurred, 0 otherwise

__STATIC_FORCEINLINE void ECC_ClearAllDoubleBitError (void)

Clear all double-bit errors.

This function clears all double-bit errors by clearing the appropriate bits in the machine ECC code CSR.

__STATIC_FORCEINLINE void ECC_ClearICacheDoubleBitError (void)

Clear I-Cache double-bit error.

This function clears the double-bit error in the I-Cache by clearing the appropriate bits in the machine ECC code CSR.

__STATIC_FORCEINLINE void ECC_ClearDCacheDoubleBitError (void)

Clear D-Cache double-bit error.

This function clears the double-bit error in the D-Cache by clearing the appropriate bits in the machine ECC code CSR.

__STATIC_FORCEINLINE void ECC_ClearTLBDoubleBitError (void)

Clear TLB double-bit error.

This function clears the double-bit error in the TLB by clearing the appropriate bits in the machine ECC code CSR.

__STATIC_FORCEINLINE void ECC_ClearILMDoubleBitError (void)

Clear ILM double-bit error.

This function clears the double-bit error in the ILM by clearing the appropriate bits in the machine ECC code CSR.

__STATIC_FORCEINLINE void ECC_ClearDLMDoubleBitError (void)

Clear DLM double-bit error.

This function clears the double-bit error in the DLM by clearing the appropriate bits in the machine ECC code CSR.

static uint8_t ECC_GenerateECCCodeU32(uint32_t a)

Generate ECC code for a 32-bit value.

This function calculates the ECC code for a 32-bit input value using Hamming code algorithm. It generates a 7-bit ECC code that can be used to detect and correct single-bit errors and detect double-bit errors.

Parameters:

a[in] 32-bit value for which ECC code is to be generated

Returns:

8-bit ECC code (7 bits used, 1 bit unused)

static uint8_t ECC_GenerateECCCodeU64(uint64_t a)

Generate ECC code for a 64-bit value.

This function calculates the ECC for a 64-bit input value using Hamming code algorithm. It generates an 8-bit ECC code that can be used to detect and correct single-bit errors and detect double-bit errors.

Parameters:

a[in] 64-bit value for which ECC code is to be generated

Returns:

8-bit ECC code