8-bit
128-bit data cache
Instruction fetch
8 x 128-bit
Direct mapped
program cache
128-bit prefetch data
Look ahead prefetch
Data from DCODE access
Flash cache mode
Flash and OTP
Cortex
M3
CPU
M
U
X
32-bit
Flash Controller Memory Module
540
SPRUHE8E – October 2012 – Revised November 2019
Copyright © 2012–2019, Texas Instruments Incorporated
Internal Memory
5.3.8.1.2 Cache Mode
5.3.8.1.2.1 Program Cache
Flash memory is typically used to store application code. During code execution, instructions are fetched
from sequential memory addresses, except when a discontinuity occurs. Usually, the portion of the code
that resides in sequential addresses makes up the majority of the application code, and is referred to as
linear code. To improve the performance of linear code execution, a flash prefetch-mechanism has been
implemented in FMC. This prefetch mechanism does a look-ahead prefetch on linear address increments
starting from the address of the last program access.
Apart from linear code, in general application codes, there may be several loops wherein a set of
instructions located in sequential addresses are executed repeatedly in a loop, until a condition holds true.
To improve the performance of small loop code execution, an 8-level deep 128-bit wide (8 x 128) direct
mapped program cache has been implemented in the FMC. Whenever instructions in cache are fetched
for CPU processing, the flash prefetch mechanism does a look-ahead prefetch of 128 bits from the next
linear 128-bit aligned address from last address access, and fills the program cache as shown in
Figure 5-82. Flash Cache Mode
Up to four 32-bit instructions or up to eight 16-bit instructions can reside within a single 128-bit access. For
every 128-bit instruction fetch from the flash bank, it is likely that there are up to eight instructions
(assuming 16-bit instructions) in each level of cache, ready to process through the CPU. During the time it
takes to process these instructions, the flash prefetch mechanism automatically initiates another access to
the flash bank to prefetch the next 128 bits. In this manner, the flash prefetch mechanism works in the
background to keep the cache as full as possible with data corresponding to the next linear address.
Using this technique, the overall efficiency of sequential code execution and small loop code execution
from flash or OTP is improved significantly.
The flash program-cache and prefetch mechanism features are disabled by default. Setting the
PROG_CACHE_EN bit in the FRD_INTF_CTRL register enables this cache mode. This flash prefetch and
cache mechanisms are independent of the CPU pipeline.