January 11, 2021
The register is an integral part of the central processing unit. It is related to the CPU. Registers are high-speed storage components with limited storage capacity. They can be used to temporarily store instructions, data, and addresses. In the control unit of the central processing unit, the registers included are the instruction register (IR) and the program counter (PC). In the arithmetic and logic components of the central processing unit, the registers included are the accumulator (ACC).
Memory is the internal memory in the professional name, and the memory is composed of memory chips, circuit boards, gold fingers and other parts. It covers a large range, generally divided into read-only memory and random memory, and the most powerful cache memory (CACHE).
Read-only memory is widely used. It is usually a readable chip integrated on the hardware. Its function is to identify and control the hardware. Its characteristic is that it can only be read but cannot be written.
The characteristic of random access memory is that it is readable and writable, and all data disappears after the power is off. What we call memory stick refers to it. It is only a drop in the ocean of memory, one of the important components in a computer, and it is a bridge to communicate with the CPU. All programs in the computer are run in the memory, so the performance of the memory has a great impact on the computer. Memory (Memory) is also called internal memory, its function is to temporarily store the calculation data in the CPU, and the data exchanged with external memory such as hard disk. As long as the computer is running, the CPU will transfer the data that needs to be calculated into the memory for calculation. When the calculation is completed, the CPU will transmit the result. The operation of the memory also determines the stable operation of the computer.
In the memory hierarchy of a computer, register is the fastest, memory is the second, and hard disk is the slowest.
They are all transistor storage devices. Why are registers faster than memory?
MikeAsh wrote a good explanation and answered this question in a very simple way, which helps to deepen the understanding of hardware.
Reason 1: The distance is different
Distance is not the main factor, but it is best to understand. The memory is far from the CPU, so it takes longer to store.
Taking a 3Ghz CPU as an example, the current can oscillate 3 billion times per second, and it takes about 0.33 nanoseconds each time. Light can advance 30cm in 1 nanosecond, which means that light can advance 10cm in one CPU cycle. Therefore, if the memory is more than 5cm away from the CPU, it is impossible to complete data reading and writing within one clock cycle. This does not take into account the limitations of hardware and the fact that the current cannot reach the speed of light. In contrast, the registers are inside the CPU, and of course it will be faster to read.
Reason two: different hardware design
Apple’s newly launched iphone5s has an A7 CPU and more than 6000 registers (31 64-bit registers plus 32 128-bit registers). The memory of iphone5s is 1GB, which is about 8 billion bits. This means that high-performance, high-cost, and high-power-consumption designs can be used in registers. Anyway, there are only more than 6000 bits, but can not be used in memory, because the cost and energy consumption of each bit will be increased by a little bit. Magnified 8 billion times.
In fact, the design of the memory is relatively simple, each bit is a capacitor and a transistor, but the design of the register is completely different, with several more electronic components. And after the power is turned on, the transistors of the register are always powered, and the transistors of the memory are only powered when they are used, and those not used are not powered, which is conducive to power saving. These design factors determine that the register reads faster than the memory.
Reason 3: Different working methods
The working mode of the register has only 2 steps: (1) find the relevant bits (2) read these bits
The way memory works is much more complicated:
(1) Find the pointer of the data (the pointer may be stored in the register, so this step already includes all the work of the register.)
(2) The pointer is sent to the memory management unit (MMU), and the virtual memory address is translated into the actual physical address by the MMU.
(3) Send the physical address to the memory controller (memorycontroller), because the memory controller finds out which memory bank the address is on.
(4) Determine which memory block (chunk) the data is on, and read the data from that block.
(5) The memory is sent back to the memory controller first, and then back to the CPU, and then start to use.
The working flow of the memory has many more steps than the register, and each step will cause a delay, and the accumulation makes the memory much slower than the register.
In order to alleviate the huge difference in speed between registers and memory, hardware designers have made many efforts, including setting up a cache inside the CPU, optimizing the way the CPU works, and trying to read all the data used by instructions from the memory at once.