Computer memory stores information and data for immediate use. Memory has wide uses and operates at a much higher speed but lower capacity compared to secondary storage. Much of modern memory is implemented using semiconductors (semiconductor memory), especially with transistors and other electrical components.

Two main kinds of semiconductor memory include volatile and non-volatile memory. Non-volatile memory (NVM) can generally retain stored information even after power is removed. To contrast, volatile memory needs constant or regular power to retain data.

Data is typically stored in memory cells each storing one bit. This is extendible to storing huge amounts of data if necessary in words. Most computers store a byte at each memory location.

Types

Volatile memory

Non-volatile memory

In hardware

We have two main parts of memory: a decoder and an array of memory cells. We can think about memory as a matrix of bit storage with the following parameters:

  • WE is the write enable. For WE=0, the memory operates in read-mode. At WE=1, the memory operates in write-mode.
  • A[m-1:0] specifies the memory address. This is fed into a decoder that one-hot decodes it into each word.
  • O[2^m-1:0] is the one-hot representation of the memory address.
  • D[n-1:0] represents how many bits wide the memory is. Each bit can be input (written to) or output (read from). Where refers to a “word” of memory data, corresponding to one row of the memory cell array, and where refers to the word width (i.e., 32 bits). The data lines are often bidirectional.

The decoder will change the binary addresses of each cell array into a one-hot code, i.e., they take in inputs and have outputs. -bit processors have address lines, called the address space of the computer. Most computers will store a byte at each memory location. Bigger memories get slower.1 Intuitively, there needs to be more circuitry for the decoder, the wires need to be longer, and so on. Longer wires mean a higher capacitance (and higher time constant). To mitigate this, we use cache memory.

The practice of using lower byte addresses for less significant bytes is little-endian. The opposite, where lower byte addresses are used for more significant bytes is big-endian.

In software

Every computer program runs in memory. A useful diagram of a running program’s memory is below. This can be the reverse way (like in Nios II). Programming languages are divided into memory-safe and memory-unsafe languages. Safe languages include out of the box a garbage collector to maintain user-allocated memory and prevent memory leaks. To contrast, memory-unsafe languages (like C/C++) allow generally broader manipulation of memory and pointers (that hold memory addresses).

The nullptr or NULL memory address is, by convention, set to address 0. However, this isn’t guaranteed by the language standards or architectures, so a literal word value of 0 is used instead by the compiler.

Footnotes

  1. ”This is a physics statement, deeply fundamental.” - Prof Rose