6.4
Re-configuring the Data Cache as Data RAM
Software has the ability to lock tags associated with 32-byte lines in the data cache, thus creating
the appearance of data RAM. Any subsequent access to this line will always hit the cache unless it
is invalidated. Once a line is locked into the data cache it is no longer available for cache allocation
on a line fill. Up to 28 lines in each set can be reconfigured as data RAM, such that the maximum
data RAM size is 28 Kbytes for the 32 Kbytes cache and 12 Kbytes for the 16 Kbytes cache.
Hardware does not support locking lines into the mini-data cache; any attempt to do this will
produce unpredictable results.
There are two methods for locking tags into the data cache; the method of choice depends on the
application. One method is used to lock data that resides in external memory into the data cache
and the other method is used to re-configure lines in the data cache as data RAM. Locking data
from external memory into the data cache is useful for lookup tables, constants, and any other data
that is frequently accessed. Re-configuring a portion of the data cache as data RAM is useful when
an application needs scratch memory (bigger than the register file can provide) for frequently used
variables. These variables may be strewn across memory, making it advantageous for software to
pack them into data RAM memory.
Code examples for these two applications are shown in
6-4 on page
actually requests the entire line of data from external memory and
the line-allocate operation to lock the tag into the cache. No external memory request is made,
which means software can map any unallocated area of memory as data RAM. However, the
line-allocate operation does validate the target address with the MMU, so system software must
ensure that the memory has a valid descriptor in the page table.
Another item to note in
allocated line in the cache must be initialized by software before it can be read. The line allocate
operation does not initialize the 32 bytes and therefore reading from that line will produce
unpredictable results.
In both examples, the code drains the pending loads before and after locking data. This step ensures
that outstanding loads do not end up in the wrong place -- either unintentionally locked into the
cache or mistakenly left out in the proverbial cold (not locked into the nice warm cache with their
brethren). Note also that a drain operation has been placed after the operation that locks the tag into
the cache. This drains ensures predictable results if a programmer tries to lock more than 28 lines
in a set; the tag will get allocated in this case but not locked into the cache.
Developer's Manual
6-73. The difference between these two routines is that
Example 6-4 on page 6-73
January, 2004
Intel XScale® Core Developer's Manual
Example 6-3 on page 6-72
Example 6-3 on page 6-72
Example 6-4 on page 6-73
is that the 32 bytes of data located in a newly
Data Cache
and
Example
uses
71
Need help?
Do you have a question about the XScale Core and is the answer not in the manual?