ROM, RAM, register, cash



Electrical/electronic circuit

Release date:2022/10/5         

In Japanese
<Premise knowledge>
Microcontroller components


This section describes memories such as ROM, RAM, registers, and cache, which are the components of microcontrollers. The following is a configuration example of a microcontroller.


■RAM, register, cash

Registers, caches, and RAM (Random Access Memory) are all memories for storing data such as CPU calculation results. Registers and caches are also a type of RAM. The RAM used for registers and caches is Static RAM, and the main memory is Dynamic RAM. When we say RAM, we often refer to this main memory.

These memories differ in access speed and storage capacity. Since the registers are located close to the CPU, they have the fastest access speed, and they temporarily store the operation results to speed up the CPU operations. The cache is also located close to the CPU, which temporarily stores frequently accessed data in the main memory to reduce access to the main memory and read data at high speed. The difference between registers and caches is that registers speed up operations, while caches speed up memory access. Main memory is the slowest to access but can store large amounts of data.


<Difference between Static RAM and Dynamic RAM>

SRAM is faster than DRAM, not only because of its proximity to the CPU, but also because of its structure. SRAM uses a flip-flop circuit and retains memory with transistors. On the other hand, since DRAM uses capacitors to store data, it takes time to move charges. Transistors are faster but more expensive, and capacitors are cheaper and have more capacity.

■Additional description of RAM

RAM is a volatile memory that loses its contents when the power is off. Computers used in automobiles, etc. are connected to a battery, and some of them maintain power even when the key is turned off to retain the contents of RAM. Such RAM is called backup RAM or KAM (Keep Alive Memory). The cassette of the Family Computer of the video game I played a long time ago also used backup RAM to save save data, and the battery was inside the cassette. It often happened that the battery died and the save data was lost.

I will explain the breakdown of RAM in the main memory. As shown in the figure below, it is roughly divided into three areas: program area, data area, and stack area. The program area stores the program for calling variables. The data area is further divided into a static area and a heap area, and mainly stores global variables and static variables. The stack area is used to temporarily save registers in the CPU and store local variables.



In addition, if you add memory to your PC to increase the processing speed, it will be this RAM. It is not the ROM described later (Due to the characteristics of ROM, it does not improve processing performance even if it is expanded).

■ROM

ROM is a read-only memory (some special ROMs are writable, see below), and it is called non-volatile memory (NVM) because it retains its contents even without a power supply. Programs for software operation and data for running programs are written in ROM. Programs and data do not change while the software is running, so they are written when the microcontroller is manufactured. This is called mask ROM. Also, the software itself is sometimes called ROM (it seems that it means that it is written to ROM).

There is EEPROM (Electrically Erasable Programmable ROM) that can be erased electrically as writable ROM (although not "Read Only"). Unlike backup RAM, data can be retained without requiring an external power supply. In that case, you may think that you should use EEPROM instead of backup RAM. However, since EEPROM has a limit of 100,000 data write times, it is not suitable for frequent data writes. Since DRAM can be written 10 to the 15th power, there is virtually no limit to the number of writes. Another rewritable ROM is flash memory, which is also a type of EEPROM, but the difference is that the structure is simplified by erasing data in blocks, and as a result, flash memory achieves a large capacity. This includes USB memory, etc. Flash memory has fewer write operations than EEPROM, and some have tens of thousands to thousands of write operations. Although flash memory is a type of EEPROM, it is often not called EEPROM and is used separately.

■Summary of RAM and ROM











List of related articles



Electrical/electronic circuit