CACHE — Instruction/data cache

The cache is two-way set associative with a least recently used (LRU) replacement policy. Both instruction and data accesses towards flash memory or XIP code regions are cached.

The cache has the following features:
  • 128-bit cache line
  • Configurable as a cache or general purpose RAM
  • Hit/miss counters per NVM region and access type (instruction or data)
  • Readable cache content (for profiling)
    • Data, tag, valid, and most recently used (MRU) bits
    • Can be disabled when not in use
  • Manual invalidation and erase support
  • Locking cache updates on cache misses
Figure 1. Cache overview
Cache overview

In Cache mode (MODE=Cache), instruction and data accesses from the CPU over the code bus towards internal or external flash, are cached. The contents of the cache, i.e. data, tag, valid, and MRU bits, are memory mapped, see Cache content. This can be used for performance profiling of code running in the system. Access to the cache content region is read-only by default, but can be blocked by enabling a lock bit in DEBUGLOCK. Preventing cache content updates on cache misses can be enabled through register DEBUGLOCK. When enabled, cache content is not replaced, but kept intact. The cache is still enabled and provides fast instruction and data fetches for cached content.

Access to internal or external flash memory will not be cached when in Ram mode (MODE=Ram). Instead, the cache data content, as described in Cache content, can be used as read/write RAM.

Cache content

Cache information is divided into cache info content and cache data content.

Cache info content is organized in memory as shown in the following figure.
Figure 2. Cache info content
Cache info content
The V field contains the bit that indicates if a cache entry is valid or not. All V fields are cleared when invalidating the cache using register INVALIDATE, when disabling the cache using register ENABLE, or when changing MODE from Ram to Cache. The MRU field indicates which way was used most recently in the set. The MRU bit is updated on each fetch from the cache and is used for the cache replacement policy. The Tag field is used to check if an entry in the cache matches the address being fetched.
The following figure shows how the cache data content is organized in memory.
Figure 3. Cache data content
Cache data content
Each set consists of two ways, each containing 128 bits of data. The 128-bit data is available as 4x32-bit words in sequential order. When operating in Ram mode (MODE = Ram), the data is accessible as general purpose RAM.

The cache info and cache data content are memory mapped in the CACHEINFO and CACHEDATA regions. These can be accessed in the CACHEINFO registers and CACHEDATA registers respectively.

Profiling

The cache includes profiling counters IHIT, IMISS, DHIT, and DMISS for both flash and execute-in-place (XIP).

Cache performance on executed code is indicated by these counters when enabled through PROFILINGENABLE. The counters can be cleared at any time using PROFILINGCLEAR. Writing to this register will clear all profiling counters. After being cleared, the counters will increment at the next instruction, or data fetch, according to the rules in the following table.

Table 1. Profiling counters
Profiling counterDescription
IHITIncreased on a cache hit for instruction fetch
IMISSIncreased on a cache miss for instruction fetch
DHITIncreased on a cache hit for data fetch (i.e. LOAD type instruction targeting the cache region)
DMISSIncreased on a cache miss for data fetch (i.e. LOAD type instruction targeting the cache region)

Registers

Instances

InstanceDomainBase addressTrustZoneSplit accessDescription
MapAttDMA
CACHEAPPLICATION0x50001000HFSNANoCache

Register overview

RegisterOffsetTZDescription
PROFILING[n].IHIT0x400Instruction fetch cache hit counter for cache region n, where n=0 means Flash and n=1 means XIP.
PROFILING[n].IMISS0x404Instruction fetch cache miss counter for cache region n, where n=0 means Flash and n=1 means XIP.
PROFILING[n].DHIT0x408Data fetch cache hit counter for cache region n, where n=0 means Flash and n=1 means XIP.
PROFILING[n].DMISS0x40CData fetch cache miss counter for cache region n, where n=0 means Flash and n=1 means XIP.
ENABLE0x500Enable cache.
INVALIDATE0x504Invalidate the cache.
ERASE0x508Erase the cache.
PROFILINGENABLE0x50CEnable the profiling counters.
PROFILINGCLEAR0x510Clear the profiling counters.
MODE0x514

Cache mode.

Switching from Cache to Ram mode causes the RAM to be cleared.

Switching from RAM to Cache mode causes the cache to be invalidated.

DEBUGLOCK0x518Lock debug mode.
ERASESTATUS0x51CCache erase status.
WRITELOCK0x520

Lock cache updates. Prevents updating of cache content on cache misses, but will continue to lookup instruction/data fetches in content already present in the cache.

Ignored in RAM mode.

PROFILING[n].IHIT (n=0..1)

Address offset: 0x400 + (n × 0x20)

Instruction fetch cache hit counter for cache region n, where n=0 means Flash and n=1 means XIP.

Bit number313029282726252423222120191817161514131211109876543210
IDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARHITSNumber of instruction cache hits

PROFILING[n].IMISS (n=0..1)

Address offset: 0x404 + (n × 0x20)

Instruction fetch cache miss counter for cache region n, where n=0 means Flash and n=1 means XIP.

Bit number313029282726252423222120191817161514131211109876543210
IDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARMISSESNumber of instruction cache misses

PROFILING[n].DHIT (n=0..1)

Address offset: 0x408 + (n × 0x20)

Data fetch cache hit counter for cache region n, where n=0 means Flash and n=1 means XIP.

Bit number313029282726252423222120191817161514131211109876543210
IDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARHITSNumber of data cache hits

PROFILING[n].DMISS (n=0..1)

Address offset: 0x40C + (n × 0x20)

Data fetch cache miss counter for cache region n, where n=0 means Flash and n=1 means XIP.

Bit number313029282726252423222120191817161514131211109876543210
IDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARMISSESNumber of data cache misses

ENABLE

Address offset: 0x500

Enable cache.

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWENABLEEnable cache
Disabled0Disable cache
Enabled1Enable cache

INVALIDATE

Address offset: 0x504

Invalidate the cache.

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
AWINVALIDATEInvalidate the cache
Invalidate1Invalidate the cache

ERASE

Address offset: 0x508

Erase the cache.

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
AWERASEErase the cache
Erase1Erase cache

PROFILINGENABLE

Address offset: 0x50C

Enable the profiling counters.

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWENABLEEnable the profiling counters
Disable0Disable profiling
Enable1Enable profiling

PROFILINGCLEAR

Address offset: 0x510

Clear the profiling counters.

The profiling counters can be cleared at any time. When cleared, all profiling counters will be set to zero, and will increment at the next instruction or data fetch.

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
AWCLEARClearing the profiling counters
Clear1Clear the profiling counters

MODE

Address offset: 0x514

Cache mode.

Switching from Cache to Ram mode causes the RAM to be cleared.

Switching from RAM to Cache mode causes the cache to be invalidated.

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWMODECache mode
Cache0Cache mode
Ram1RAM mode

DEBUGLOCK

Address offset: 0x518

Lock debug mode.

This register is ignored when CACHE is used in RAM mode. Once this register has been set to Locked, the debug mode can only be unlocked by resetting the device.

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARW1DEBUGLOCKLock debug mode
Unlocked0Debug mode unlocked
Locked1Debug mode locked

ERASESTATUS

Address offset: 0x51C

Cache erase status.

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWERASESTATUSCache erase status
Idle0Erase is not complete or hasn't started
Finished1

Cache erase is finished

Write 0 to clear.

WRITELOCK

Address offset: 0x520

Lock cache updates. Prevents updating of cache content on cache misses, but will continue to lookup instruction/data fetches in content already present in the cache.

Ignored in RAM mode.

Bit number313029282726252423222120191817161514131211109876543210
IDA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWWRITELOCKLock cache updates
Unlocked0Cache updates unlocked
Locked1Cache updates locked

Electrical specification

Cache size

SymbolDescriptionMin.Typ.Max.Units
SizeCACHEDATACACHEDATA size8192Bytes

Registers

Instances

InstanceDomainBase addressTrustZoneSplit accessDescription
MapAttDMA
CACHEINFOAPPLICATION0x00F08000HFSNANoCache info

Register overview

RegisterOffsetTZDescription
SET[n].WAY[o]0x0Cache information for SET[n], WAY[o].

SET[n].WAY[o] (n=0..255) (o=0..1)

Address offset: 0x0 + (n × 0x8) + (o × 0x4)

Cache information for SET[n], WAY[o].

Bit number313029282726252423222120191817161514131211109876543210
IDCBAAAAAAAAAAAAAAAAA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWTAGCache tag.
BRVValid bit
Invalid0Invalid cache line
Valid1Valid cache line
CRMRUMost recently used way.
Way00Way0 was most recently used
Way11Way1 was most recently used

Registers

Instances

InstanceDomainBase addressTrustZoneSplit accessDescription
MapAttDMA
CACHEDATAAPPLICATION0x00F00000HFSNANoCache data

Register overview

RegisterOffsetTZDescription
SET[n].WAY[o].DATA00x0Cache data bits [31:0] of SET[n], WAY[o].
SET[n].WAY[o].DATA10x4Cache data bits [63:32] of SET[n], WAY[o].
SET[n].WAY[o].DATA20x8Cache data bits [95:64] of SET[n], WAY[o].
SET[n].WAY[o].DATA30xCCache data bits [127:96] of SET[n], WAY[o].

SET[n].WAY[o].DATA0 (n=0..255) (o=0..1)

Address offset: 0x0 + (n × 0x20) + (o × 0x10)

Cache data bits [31:0] of SET[n], WAY[o].

Bit number313029282726252423222120191817161514131211109876543210
IDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWDataData

SET[n].WAY[o].DATA1 (n=0..255) (o=0..1)

Address offset: 0x4 + (n × 0x20) + (o × 0x10)

Cache data bits [63:32] of SET[n], WAY[o].

Bit number313029282726252423222120191817161514131211109876543210
IDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWDataData

SET[n].WAY[o].DATA2 (n=0..255) (o=0..1)

Address offset: 0x8 + (n × 0x20) + (o × 0x10)

Cache data bits [95:64] of SET[n], WAY[o].

Bit number313029282726252423222120191817161514131211109876543210
IDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWDataData

SET[n].WAY[o].DATA3 (n=0..255) (o=0..1)

Address offset: 0xC + (n × 0x20) + (o × 0x10)

Cache data bits [127:96] of SET[n], WAY[o].

Bit number313029282726252423222120191817161514131211109876543210
IDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Reset 0x0000000000000000000000000000000000000000
IDR/WFieldValue IDValueDescription
ARWDataData