...the world's most energy friendly microcontrollers
2016-04-28 - Giant Gecko Family - d0053_Rev1.20
35
www.silabs.com
Figure 7.1. Instruction Cache
Cort ex
128x 32
SRAM
Access
Filt er
Cache
Look- up Logic
ICODE
AHB- Lit e Bus
ICODE
AHB- Lit e Bus
CODE
Mem ory Space
Inst ruct ion Cache
Perform ance Count ers
DCODE
AHB- Lit e Bus
IDCODE
AHB- Lit e Bus
IDCODE
MUX
By default, the instruction cache is automatically invalidated when the contents of the flash is changed
(i.e. written or erased). In many cases, however, the application only makes changes to data in the
flash, not code. In this case, the automatic invalidate feature can be disabled by setting AIDIS in
MSC_READCTRL. The cache can (independent of the AIDIS setting) be manually invalidated by writing
1 to INVCACHE in MSC_CMD.
In general it is highly recommended to keep the cache enabled all the time. However, for some sections
of code with very low cache hit-rate more energy-efficient execution can be achieved by disabling the
cache temporarily. To measure the hit-rate of a code-section, the built-in performance counters can
be used. Before the section, start the performance counters by writing 1 to STARTPC in MSC_CMD.
This starts the performance counters, counting from 0. At the end of the section, stop the performance
counters by writing 1 to STOPPC in MSC_CMD. The number of cache hits and cache misses for
that section can then be read from MSC_CACHEHITS and MSC_CACHEMISSES respectively. The
total number of 32-bit instruction fetches will be MSC_CAC MSC_CACHEMISSES. Thus, the
cache hit-ratio can be calculated as MSC_CACHEHITS / (MSC_CAC MSC_CACHEMISSES).
When MSC_CACHEHITS overflows the CHOF interrupt flag is set. When MSC_CACHEMISSES
overflows the CMOF interrupt flag is set. These flags must be cleared explicitly by software. The
range of the performance counters can thus be extended by increasing a counter in the MSC interrupt
routine. The performance counters only count when a cache lookup is performed. If the lookup fails,
MSC_CACHEMISSES is increased. If the lookup is successful, MSC_CACHEHITS is increased. For
example, a cache lookup is not performed if the cache is disabled or the code is executed from RAM
outside the code space. When caching of vector fetches and instructions in interrupt routines is disabled
(ICCDIS in MSC_READCTRL is set), the performance counters do not count when these types of fetches
occur (i.e. while in interrupt context).
By default, interrupt vector fetches and instructions in interrupt routines are also cached. Some
applications may get better cache utilization by not caching instructions in interrupt context. This is done
by setting ICCDIS in MSC_READCTRL. You should only set this bit based on the results from a cache
hit ratio measurement. In general, it is recommended to keep the ICCDIS bit cleared. Note that lookups
in the cache are still performed, regardless of the ICCDIS setting - but instructions are not cached when
cache misses occur inside the interrupt routine. So, for example, if a cached function is called from the
interrupt routine, the instructions for that function will be taken from the cache.
The cache content is not retained in EM2, EM3 and EM4. The cache is therefore invalidated regardless
of the setting of AIDIS in MSC_READCTRL when entering these energy modes. Applications that switch
frequently between EM0 and EM2/3 and execute the very same non-looping code almost every time
will most likely benefit from putting this code in RAM. The interrupt vectors can also be put in RAM to
reduce current consumption even further.
The cache also supports caching of instruction fetches from the external bus interface (EBI) when
accessing the EBI through code space. By default, this is enabled, but it can be disabled by setting
EBICDIS in MSC_READCTRL.
Summary of Contents for Giant Gecko EFM32GG
Page 842: ......