Table of Contents
Types of Memory
- Primary Memory
- Secondary Memory
A computer has two types of Memories; Primary and Secondary. Primary Memory comprises DRAM (Dynamic Random Access Memory) and SRAM (Static Random Access Memory), Secondary Memory these days is primarily in the form of HDDs (Hard Disk Drives) or SSDs (Solid State Drives). The difference is that primary memory is Volatile (It needs to be powered to keep the data and when power is turned off, the data is lost) while secondary memory is non-volatile and will retain the data when powered off too. Removable Memory like CDs and USBs also form a part of secondary memory.
Cache memory is made up of SRAM. Before we understand Cache memory, let us try and understand the differences between SRAM and DRAM and why we use SRAM in Cache Memory.
Refresh Needs
DRAM, stores data by holding electrical charges on tiny capacitors on its chip. This electrical charge needs to be refreshed constantly, lest it drains out in the form of heat or leakage. Unlike DRAM, SRAM has latches which are flip-flop kinds of switches that can hold either a zero or a one and hence can retain data without being refreshed.
Density
A Bit of information on DRAM takes one transistor and one capacitor, whereas in SDRAM it takes about six transistors. Therefore, SRAMs occupy more space, about six times more, per bit compared to DRAMs. SRAMS are also more expensive.
Speed
As SRAMs do not need to be refreshed, their seek time is in the order of 10 ns as compared to DRAMs which have a seek time of about 60 ns. For this reason, SRAMs are much faster compared to DRAMs.
Cache
The CPU cache is the CPU’s internal memory and its function is to store copies of data the CPU needs. The CPU copies frequently used data it is going to access repeatedly from the RAM to the Cache memory and when needed accesses it from the faster cache memory. If the required data is not in the Cache, it will then seek it from the slower RAM. Cache memory is very important because the faster a CPU can seek data, the faster the processor will perform. The purpose then of the Cache memory is primarily to make the computer run faster.
How the CPU seeks data?
There are three levels of Cache. L1, L2, and L3 which are essentially SRAM modules. After this is the DRAM. When the CPU needs any data, it first looks for it in L1 Cache, if it does not find it, it looks for it in L2 Cache and so on in L3 Cache, and finally, if the data is not there in any of the cache levels, it gets it from the much slower DRAM. If the data it is seeking is not in DRAM too, the computer will look for the data in the secondary memory being the HDD or SSD or from removal storage like USBs or CDs and move it to the DRAM or SRAM.
How Cache Memory is Organised?
L1 cache is the fastest memory, up to 20 to 100 times faster than DRAM, and is called the Core memory as it is dedicated to the core and placed on the CPU itself. It is generally in the order of 32KB to 2MB. It is not made larger because a larger cache means a CPU will spend more time searching for the data. L2 cache is slower than the L1 cache and is in the order of 256KB to 8 MB. L2 Memory may also be embedded on the CPU itself. L2 cache is also dedicated to the core. L3 cache can be from 2MB to 32MB and is not dedicated to the CPU core and is shared by all the cores in a CPU and is called Shared Cache Memory. L3 is slower than L1 & L2. In some processors, L3 Cache is on the motherboard and in some on the CPU itself.
Do not confuse with Computer Cache
When referred to in colloquial terms, the word “Cache” also refers to temporary data stored in the computer like browsing history, last accessed files, cookies, cached images. This is why when your computer gets slow, you are advised to clear your Cache, This cache is not referring to the cache memory discussed above.
Conclusion
So, that’s the gist of it. Cache memory might seem like a small detail, but it plays a big role in how fast and efficient your CPU really is. L1, L2, and L3 each do their part to keep things running smoothly—and now that you know what they do, you’ll have a better sense of what to look for when checking out processor specs or comparing models.