User Tools

Site Tools


This is an old revision of the document!

Using ARM Caches

This page describes how to set up the MMU, L1 caches, and L2 cache on the Cortex-A9 MPCore processor found in the Cyclone V.


The following documents are useful references:

The ARM processor in the Cyclone V has both L1 and L2 caches. The L1 cache is split into separate instruction and data caches and is controlled directly by the processor. The L2 cache is a unified cache and is controlled by the L2C-310 cache controller.

The L1 instruction cache can be enabled using a single bit in the SCTLR register using MRC/MCR instructions. The L1 data cache can only be used when the memory management unit (MMU) is on. The L2 cache can be enabled by programming the L2C-310 controller using memory-mapped registers.

To see how the processor performs in various configurations, see the benchmarking results at ARM Benchmark Results.

Enabling the MMU

The MMU serves to translate virtual addresses used by the processor into physical addresses that correspond to actual memory locations. It also controls the caching behaviour of different sections of the memory space.

Several steps are involved when turning on the MMU:

  • Disable caches and branch predictor
  • Invalidate instruction, data, and unified TLBs, L1 instruction and data caches, and branch predictor array
  • Set up translation table entries
  • Set translation table control registers
  • Set domain access control register
  • Enable the MMU, L1 caches, and branch predictor

Programming the L2 Cache Controller

The L2C-310 cache controller is controlled using memory mapped registers. For the Cyclone V SoC the base address for these registers is 0xFFFEF000. The register descriptions can be found in the L2C-310 TRM, linked above.

The following steps are to be taken to enable the L2 cache controller:

  • Set the way size
  • Set the read, write, and hold delays for Tag RAM
  • Set the read, write, and hold delays for Data RAM
  • Set the prefetching behaviour
  • Invalidate the cache
  • Enable the L2C-310 cache controller

Memory Performance Optimizations

The following additional settings greatly enhance memory performance:

  • Set memory region attributes in TTB entries to use inner write-back
  • Use minimum stable L2C-310 read, write, and hold delays
  • Enable L1 Data-side prefetch

Special L2C-310 + Cortex-A9 MPCore Options

Several other options area available as well. Both the Cortex-A9 TRM and L2C-310 TRM (linked above) outline several optimizations for L2 memory accesses.

The following features are available when using the L2C-310 cache controller with a Cortex-A9 MPCore processor:

  • Exclusive caching
  • L2 prefetch hints
  • Early BRESP
  • Allow L2C-310 to write a full line of zeros
  • L2 cache speculative linefill (requires Snoop Control Unit to be enabled)

These features were all tested during benchmarking; however, none of them seemed to offer any performance gains. Further investigation may may be required to make the best use of these options.

Other Possible Optimizations

There are other options available that may further boost memory performance. These options have not yet been investigated.

  • L2 cache entry lockdown
  • Cache replacement policy
  • L2 cache preloading

Of these options, L2 cache preloading may offer the greatest benefits.

using_arm_caches.1401583897.txt.gz · Last modified: 2014/05/31 20:51 by bain