Cache memory is random access memory (RAM) used by the central processing unit of a computer to reduce the average time to access memory. The cache is a smaller, faster memory which stores copies of the data from the most frequently used main memory locations. As long as most memory accesses are to cached memory locations, the average latency of memory accesses will be closer to the cache latency than to the latency of main memory.
Cache memory is extremely fast memory that is built into a computer’s central processing unit (CPU), or located next to it on a separate chip.
The advantage of cache memory is that the CPU does not have to use the motherboard’s system bus for data transfer. Whenever data must be passed through the system bus, the data transfer speed slows to the motherboard’s capability. The CPU can process data much faster by avoiding the bottleneck created by the system bus.
Cache memory is sometimes described in levels of closeness and accessibility to the microprocessor. Most computers today come with L3 cache and/or L2 cache, while older computers included only L1 cache.
A cache is made up of a pool of entries. Each entry has a datum (a nugget of data) which is a copy of the datum in some backing store. Each entry also has a tag, which specifies the identity of the datum in the backing store of which the entry is a copy.
The central processing unit (CPU) contains a number of memory locations which are individually addressable and reserved for specific purpose. These memory locations are called registers. CPU instructions operate on these values directly. Registers are at the top of the memory hierarchy, and provide the fastest way for a CPU to access data.
On RISC processors, all data must be moved into a register before it can be operated. On CISC (Intel) chips, there are a few operations that can load data from RAM, process it, and save the result back out, but the fastest operations work directly with registers.
The number of registers that a CPU has and the size of each (number of bits) help determine the power and speed of a CPU. For example a 32-bit CPU is one in which each register is 32 bits wide. Therefore, each CPU instruction can manipulate 32 bits of data.
CPU registers are:
- Very fast (access times of a few nanoseconds)
- Low capacity (usually less than 200 bytes)
- Very limited expansion capabilities (a change in CPU architecture would be required)
- Expensive (more than one dollar/byte)