The CPU is the brain of a computer. This brain also called the processor does all kinds of stuff including fetching data, transferring data between memory & I/O devices, and executing instructions, etc.
But despite doing all these, can it store any data?
If you are desperate to know the answer and want to dive deeper into this factor, reading this article is mandatory for you.
So, without further ado, let’s begin!
Where does the CPU store its Computational Data?
The CPU is the brain of the computer system, and it handles all the calculations while performing any operations. But while calculating the instructions, the CPU needs to hold that data in faster memory. For this, it uses the register, which is similar to RAM & Cache.
Registers are part of a special memory unit that is only used by the CPU because it’s ultra-fast. The CPU needs faster memory to perform any instructions. Modern high-end x86-based desktop CPUs can execute 100 billion instructions in a second.
Jaw-dropping amount, right?
The CPU uses the register because it’s faster and more efficient than the cache or RAM. The registers are unchangeable because they are part of the system microarchitecture. But it has a lesser memory capacity than other memories, but those are blazing fast.
That’s why the CPU uses the register to utilize the instructions faster. And there are several types of registers, that I’ll talk about later in this article.
When you launch any program or app, the CPU requires to execute lots of processes. To execute those instructions, the CPU fetches those data from other substantial memory units. After that, it stacks those data into its cache and then registers for storage and computing.
After finishing those calculations, the CPU sends the data to the RAM for a temporary hold. That’s why RAM is called temporary memory. In the meantime, the CPU gets enough space for new data analysis, and the cycle keeps running.
I hope you get your answer that the CPU can store data, and it has a specific memory for storing calculations data. But the storage space is tiny compared to the main memory and hard drives.
CPU Memory Hierarchy
The memory hierarchy of a CPU means how different sets of memory work one by one based on usage and speed. Two main memories store data for a processor. And the processor can move from one memory segment to another effortlessly while executing instructions.
Below are the five hierarchies of a system’s memory:
- Register: the CPU’s registers are the fastest and even faster than the L1 cache. It is the closest memory located beside the CPU. In most CPUs, there is a status word register and an accumulator. The status word helps to make decisions, and the accumulator performs all the mathematical operations.There are different types of registers in a processor, and those vary from one CPU to another. Not all the processors have the same amount of registers because of the change in architectures.So, the processor gets the required data from the cache to the registers, and that’s why it’s faster than the cache memory.
- Cache memory: when the CPU needs data, the RAM gets that data from the disk. After that, the data then passes from the RAM to the CPU’s cache. So, cache memory does the job. Most processors have L1, L2, and L3 L1 is the fastest one, but it has the lowest memory capacity.
Whereas L2 has a higher memory capacity than L1, and L3 has the largest. But L1 is faster than L2, and L3 is the slowest memory.
Cache memory is also known as SRAM or static RAM, and it’s a lot faster than DRAM.
There are mainly three cache levels in modern multicore processors. Among these three, the first two (L1 & L2) are shared among each core. Whereas the last one, the L3, is available for all the cores.
After fetching data from the RAM, cache memory passes that data to the register.
I bet now you have a clear vision of the CPU memory hierarchy. The cache and the register are the main storage system for every CPU, and these are the fastest storage of any computer system.
But registers, cache, and RAM can only hold the data as long as they are powered. And the data gets destroyed when you turn off the system.
Apart from this, you should also know how CPU and RAM work together because it’ll help you to understand the entire procedure of the CPU’s instruction executions.
Types of Registers & How Do They Work?
There are two types of CPU registers, the general & control register. The general register does the data calculations and stores addresses. And the control register does control the program improvement & condition code register (CCR) to test the conditions.
The general one has 8 registers and each one is capable of holding 32-bit binary data and sometimes storing 16-bit or 8-bit data. But when it needs to hold data more than 32-bit, it can shift to 64-bit mode.
Registers are also referred to as L1 cache, which is the fastest memory in the CPU cache segment. These registers in the CPU mainly stand beside the ALU (Arithmetic Logic Unit) on the chip. The number of registers and type of it varies from processor to processor, and mainly on the architecture.
But I will give you a basic idea of different types of common registers and their working purposes.
Below are the different types of registers and how they work:
- Address Registers: it only stores addresses, and it helps the CPU to locate the data from the RAM.
- Data Registers: these registers help with arithmetic operations by storing numeric data.
- Vector Registers: their main purpose is to hold data that is mainly needed for vector processing.
- Constant Registers: these registers’ main job is to store read-only values.
- Instruction Registers: it stores all the instructions and provides those to the CPU while executing.
- Status Registers: this type of register stores truth values, which helps the CPU to make decisions while executing instructions.
- Temporary Registers: Their main purpose is to store all the temporary data required by the CPU.
- I/O Registers: These registers store all the input & output data for the CPU.
These registers work together when the CPU is working and calculating tons of data. So, a register can be 8-bit, 16-bit, 32-bit, or 64-bit.
For example, A CPU with 10 cores and 20 threads means two virtual cores per single physical core. And the idea of multithreading comes from multiple sets of registers. So, against 10 CPU cores, it has 20 sets of registers, meaning 2 registers per core.
Speaking of CPU core count, if you want to know how many cores are in your processor, you can count that with simple methods.
So, when a CPU works, all the registers work together and help the CPU to execute all the instructions faster with 100% precision.
How Computer Memory Works?
The computer’s temporary memory A.K.A RAM works tightly with the CPU. Technically speaking, Primary & secondary storage, are the two main computer storage areas. The primary section consists of RAM, Cache, and Registers. Whereas a hard drive, a removable disk, ROM, BIOS, etc., are part of the secondary storage areas.
Primary storage memories are faster than permanent ones. That’s why most of the instructions, input & output operations, logical data processing, and so on are stored in the temporary section. If the CPU had to fetch instruction data from the hard drive, the processing would be much slower.
But most data goes into the RAM (Random Access Memory) first, whether it comes from the keyboard or the hard drive. Next, the RAM transfers that data to the CPU’s cache memory. As you know, cache memory is much faster than RAM but has much less memory capacity.
So, it holds that data for the CPU and transfers it when the CPU calls for it. In this cache segment, there is L1, or primary cache, which is the fastest among all the caches. And also there is an L2 cache which is also called an external cache.
L2 cache catches the recent data accesses from the CPU that were not captured by the L1. Furthermore, when the CPU doesn’t find the data it needs in the L2 cache, it finds it in the level 3 or L3 cache.
If any of these cache levels didn’t grab that data for the CPU, the processor then starts looking for that particular data in the RAM.
After finding that data, it passes through the registers. Registers sit at the top of the CPU’s memory hierarchy. So, it can quickly accept the data, store it, decode all those instructions, and pass it to the CPU.
Secondary storage is the largest storage for a computer system. You can store large data like OS files, apps, and media files in this storage. So, primary storage fetches all the data it needs from the secondary storage because the CPU can’t access it directly.
So, when the data passes from the secondary to the primary, the instruction execution cycle begins. The central processing unit or CPU includes a control unit (CU) & arithmetic logic unit (ALU) for data executions.
These units do all the data execution or processing and then pass that processed data into the system’s output unit. That’s how the total cycle ends, and this is the total working procedure of a computer’s memory.
That’s why the memory unit of a computer system plays an important role. The memory of a CPU starts working when you start the PC and keep working till you shut it down. So, let’s take a look at how memory works in a glimpse.
Can the CPU’s memory store data permanently?
CPU’s memory such as cache, and register can store the data till the system is turned on. When you turn it off, the data within those memories get destroyed too.
Which memory collects data from the secondary storage?
The main memory of the computer system, the RAM, fetches all the data from the secondary storage like a hard drive, solid drive, or removable disk. Then it passes the data to the CPU.
What does the CPU store?
The CPU has specific memory for storing data in it. And in this memory, it stores all the processing data and programs that are currently required for executing instructions.
Now you know that the CPU can store data in the register and cache memory. There are several types of registers and caches in a CPU, and each of these has individual purposes.
Though these CPU memories don’t have enough capacity, they can pass or receive data at a super fast speed. In this article, I have shown an in-depth analysis of CPU memory and how it works. I am sure you got them all still, if you need more, please leave your queries in the comment box.
See you at the next one, and have fun!