先决条件 – 计算机内存的类型(RAM 和 ROM)
随机存取存储器 (RAM)用于实时存储 CPU 正在使用的程序和数据。随机存取存储器上的数据可以被多次读取、写入和擦除。 RAM 是存储当前使用的数据的硬件元素。它是一种易失性存储器。内存类型:
- 静态 RAM或 (SRAM) 使用六晶体管存储单元的状态存储一些数据。
- 动态 RAM或 (DRAM) 使用构成 DRAM 存储单元的一对晶体管和电容器存储位数据。
只读存储器 (ROM)是一种已预先记录数据的存储器。即使在计算机关闭后,存储在 ROM 中的数据仍会保留,即非易失性。 ROM类型:
- 可编程 ROM ,在创建存储芯片后写入数据。它是非挥发性的。
- 可擦除可编程 ROM ,该非易失性存储芯片上的数据可以通过将其暴露在高强度紫外线下来擦除。
- 电可擦除可编程 ROM ,其中该非易失性存储芯片上的数据可以使用场电子发射进行电擦除。
- Mask ROM ,在存储芯片的制造过程中将数据写入其中。
下表区分了 ROM 和 RAM:
Difference | RAM | ROM |
---|---|---|
Data retention | RAM is a volatile memory which could store the data as long as the power is supplied. | ROM is a non-volatile memory which could retain the data even when power is turned off. |
Working type | Data stored in RAM can be retrieved and altered. | Data stored in ROM can only be read. |
Use | Used to store the data that has to be currently processed by CPU temporarily. | It stores the instructions required during bootstrap of the computer. |
Speed | It is a high-speed memory. | It is much slower than the RAM. |
CPU Interaction | The CPU can access the data stored on it. | The CPU can not access the data stored on it unless the data is stored in RAM. |
Size and Capacity | Large size with higher capacity. | Small size with less capacity. |
Used as/in | CPU Cache, Primary memory. | Firmware, Micro-controllers |
Accessibility | The data stored is easily accessible | The data stored is not as easily accessible as in RAM |
Cost | Costlier | cheaper than RAM. |