Custom Search

CPU Cache

Small memories on or close to the CPU can operate faster than the much larger main memory.

Most CPUs since the 1980s have used one or more caches, and modern high-end embedded, desktop and server microprocessors may have as many as half a dozen, each specialized for a specific function.

Examples of caches with a specific function are the D-cache and I-cache (data cache and instruction cache).

Cache is subset of memory, so multiple memory addresses map to the same cache location.

Overview of CPU Cache

The cache is basically a small amount of fast temporary memory storage.It is positioned between the normal main memory and the CPU. It may be located on CPU chip. The cache includes tags to identify which block of main memory is in each cache slot.

The CPU requests the contents of a memory location and the cache is checked to see whether it is storing this data. If it is present, the data it obtained from the cache. This is a really quick way to obtain the data. If it is not in the cache it has to be read from the required block in main memory and copied to cache. It is then transferred from the cache to the CPU.

Caching Terminology

When reading memory

cache hit: cache block is valid and contains proper address, so read desired word

cache miss: nothing in cache in appropriate block, so fetch from memory.

cache miss, block replacement: wrong data is in cache at appropriate block, so discard it and fetch desired data from memory (cache always copy)

Valid bit: determines whether anything is stored in that cache line (when computer initially turned on, all entries invalid)

Direct mapping,

associative mapping and

set associative mapping