Memory Fundamentals
1. The Classification of Memory
By Storage Medium
Semiconductor memory:
- RAM (random access memory): readable and writable, lost when the power is cut
- ROM (read-only memory): read-only, retained when the power is cut
- Flash memory: erasable and writable, commonly used in USB flash drives and SSDs
Magnetic memory:
- Hard disk: large capacity, permanent storage
- Magnetic tape: large capacity, sequential access
- Floppy disk: small capacity, portable
Optical memory:
- CD-ROM: a read-only optical disc
- DVD: a high-capacity optical disc
- Blu-ray disc: storage for high-definition video
By Access Method
Random access memory:
- The access time is independent of the address
- For example RAM, ROM, and the hard disk
Sequential access memory:
- The access time depends on the address
- For example magnetic tape and optical discs
Direct access memory:
- Somewhere between random and sequential access
- For example the hard disk (head positioning plus sector access)
By Function
Main memory:
- Exchanges data directly with the CPU
- Fast, but with a small capacity
- For example RAM and ROM
Auxiliary memory:
- Stores large amounts of data
- Slow, but with a large capacity
- For example the hard disk and optical discs
Cache memory:
- Raises the access speed
- Small in capacity, fast
- For example the cache
2. The Hierarchical Structure of Memory
The Principle of the Hierarchical Design
Basic idea:
- Exploits the different characteristics of the various memories
- Builds a multilevel storage system
- Achieves a balance between speed, capacity, and cost
The hierarchy:
Speed: fast → slow; Capacity: small → large; Cost: high → low
The Characteristics of Each Level
Registers:
- The fastest
- The smallest in capacity (a few dozen)
- The most expensive
- Integrated with the CPU
Cache:
- Very fast
- Relatively small in capacity (KB-MB)
- Relatively expensive
- Stores recently accessed data
Main memory:
- Relatively fast
- Relatively large in capacity (GB)
- Moderate in cost
- Stores programs and data
Auxiliary memory:
- Relatively slow
- The largest in capacity (TB)
- The cheapest
- Permanent storage
The Advantages of the Hierarchy
Performance improvement:
- Exploits the principle of locality
- Reduces the average access time
- Raises the performance of the system
Cost control:
- Allocates the storage resources sensibly
- Lowers the overall cost
- Meets different requirements
Expandability:
- Supports the expansion of the capacity
- Adapts to the progress of the technology
- Maintains compatibility
3. Semiconductor Memory
SRAM (Static RAM)
The working principle:
- Based on flip-flop circuits
- Needs no refresh
- Holds the data stably
Characteristics:
- Fast: short access time
- Low power consumption: small static power
- High cost: the circuit is complex
- Small capacity: low integration density
Applications:
- Cache
- The registers inside the CPU
- Situations that require high-speed access
DRAM (Dynamic RAM)
The working principle:
- Based on capacitive storage
- Needs a periodic refresh
- The data is gradually lost
Characteristics:
- Relatively slow: it needs a refresh
- Relatively high power consumption: large dynamic power
- Low cost: the circuit is simple
- Large capacity: high integration density
Applications:
- Main memory
- System memory
- Large-capacity storage
ROM (Read-Only Memory)
The basic concept:
- Can only be read, not written
- Retains the data when the power is cut
- Used to store fixed programs
The types:
- Mask ROM: written at the factory
- PROM: programmable once
- EPROM: erased with ultraviolet light
- EEPROM: erased electrically
Applications:
- The BIOS program
- The boot program
- Fixed data tables
Flash Memory
The working principle:
- Based on floating-gate transistors
- Electrically erased and programmed
- Non-volatile storage
Characteristics:
- Non-volatile: retained when the power is cut
- Erasable and writable: supports many programming cycles
- Fast: quick access
- Large capacity: high integration density
Applications:
- USB flash drives, SD cards
- SSD solid state drives
- Mobile phone storage
4. Connecting Main Memory to the CPU
The Bus Connection
The address bus:
- Transfers address information
- Determines the location that is accessed
- Its width determines the addressable range
The data bus:
- Transfers data information
- Transfers in both directions
- Its width determines the transfer efficiency
The control bus:
- Transfers control signals
- Coordinates the access timing
- Guarantees the data transfer
Memory Mapping
Unified addressing:
- Memory and the peripherals share one address space
- Simplifies the address management
- Makes the access from a program convenient
Independent addressing:
- Memory and the peripherals are addressed separately
- Dedicated I/O instructions are needed
- The address spaces are independent
Address Decoding
The function:
- Converts the address into the chip select signal
- Selects the specific memory chip
- Realises the address allocation
The methods:
- Full decoding: all the address lines take part
- Partial decoding: some of the address lines take part
- Line selection: the address lines are used directly
Exercise 1
Briefly describe the hierarchical structure of memory and the characteristics of each level.
Approach: Name the four levels from the fastest to the slowest, give the two or three characteristics that distinguish each, and close with the property that the hierarchy as a whole buys.
Steps:
- Registers:
- The fastest and the smallest in capacity
- Integrated with the CPU, the most expensive
- Stores the data of the current operation
- Cache:
- Very fast, relatively small in capacity
- Stores recently accessed data
- Exploits the principle of locality
- Main memory:
- Relatively fast, relatively large in capacity
- Stores programs and data
- Exchanges data directly with the CPU
- Auxiliary memory:
- Relatively slow, the largest in capacity
- Stores data permanently
- The cheapest
- The property the hierarchy buys:
- The levels balance speed against capacity against cost
- The principle of locality raises the overall performance
Answer: The memory hierarchy consists of the registers, the cache, the main memory, and the auxiliary memory. The registers are the fastest and the smallest and are integrated with the CPU; the cache is very fast but relatively small and holds recently accessed data; the main memory is relatively fast and relatively large and holds the programs and data; the auxiliary memory is relatively slow but the largest and holds the data permanently at the lowest cost. Through the hierarchical design the levels balance speed, capacity, and cost, and the principle of locality raises the overall performance.
Exercise 2
What is the difference between SRAM and DRAM?
Approach: Compare the two memories on the six axes that separate them — working principle, speed, power consumption, cost, capacity, and application — and then summarise the trade-off.
Steps:
- Working principle:
- SRAM: based on flip-flop circuits, needs no refresh
- DRAM: based on capacitive storage, needs a periodic refresh
- Speed:
- SRAM: fast, with a short access time
- DRAM: relatively slow, and it takes time to refresh
- Power consumption:
- SRAM: low power consumption, small static power
- DRAM: relatively high power consumption, large dynamic power
- Cost:
- SRAM: expensive, the circuit is complex
- DRAM: cheap, the circuit is simple
- Capacity:
- SRAM: small capacity, low integration density
- DRAM: large capacity, high integration density
- Applications:
- SRAM: used as the cache and the registers
- DRAM: used as the main memory
Answer: SRAM is built from flip-flops and needs no refresh, which makes it fast, low-power, and expensive but small in capacity, so it is used for the cache and the registers. DRAM is built from capacitors and needs a periodic refresh, which makes it slower and more power-hungry but cheap and large in capacity, so it is used for the main memory. The choice is a straight trade-off between speed and cost per bit.
| Term | Abbreviation | Explanation |
|---|---|---|
| Memory | - | The component that stores data and programs |
| Main memory | - | The memory the CPU can access directly |
| Auxiliary memory | - | The external memory with a large capacity |
| Cache | - | The high-speed cache between the CPU and the main memory |
| Register | - | A high-speed storage unit inside the CPU |
| Static RAM | SRAM | Random memory that keeps its state without a refresh |
| Dynamic RAM | DRAM | Random memory that has to be refreshed periodically |
| Read Only Memory | ROM | Memory that can only be read |
| Programmable ROM | PROM | A ROM that can be programmed once |
| Erasable PROM | EPROM | A ROM that is erased with ultraviolet light |
| Electrically Erasable PROM | EEPROM | A ROM that is erased electrically |
| Flash memory | - | Non-volatile memory that is erased in blocks |
| Memory hierarchy | - | Registers - Cache - Main memory - Auxiliary memory |
| Principle of locality | - | The regularity with which a program accesses memory |
| Temporal locality | - | Data that was just accessed is likely to be accessed again |
| Spatial locality | - | Data next to an accessed item is likely to be accessed too |
| Memory cycle | - | The minimum interval between two consecutive memory accesses |
| Access time | - | The time from the start of a request to its completion |
| Memory bandwidth | - | The amount of data transferred per unit of time |
| Address decoding | - | Converting an address into the selection of a memory cell |
| Dual In-line Memory Module | DIMM | The standard form factor of a memory module |
| Synchronous DRAM | SDRAM | Synchronous dynamic memory |
| Double Data Rate | DDR | SDRAM that transfers twice per cycle |
