Memory Systems and
Addressing Schemes
LECTURE 2
Memory Systems and Addressing Schemes
What is Memory?
Memory is a large array of words or bytes, each with its own address. Interaction is achieved
through a sequence of reads or writes of specific memory address that the CPU fetches from and
stores in memory.
Types of memory.
The memory unit consists of cache memory, primary memory and secondary memory.
1. Primary Memory
Primary memory is the main memory of computer. It is used to store data and instructions
during the processing of data. Primary memory is semiconductor memory.
Primary memory is of two kinds—
1. Random Access Memory (RAM) and
2. Read Only Memory (ROM).
RAM (Random Access Memory):
RAM is volatile. It stores data when the computer is on.
The information stored in RAM gets erased when the computer is turned off.
RAM provides temporary storage for data and instructions.
Two types:
1. Static RAM (SRAM): Faster but more expensive, used in cache memory.
2. Dynamic RAM (DRAM): Slower but cheaper, used in the main memory of
most computers.
ROM (Read-Only Memory):
ROM is a Non-volatile memory that stores critical programs needed for the system's
initial booting process (e.g., BIOS).
Is a read only memory.
The storage in ROM is permanent in nature, and is used for storing standard processing
programs that permanently reside in the computer.
Data stored in ROM cannot be easily modified.
2. Secondary Memory:
The secondary memory stores data and instructions permanently.
The information can be stored in secondary memory for a long time
(years), and is generally permanent in nature unless erased by the
user. It is a non-volatile memory.
It provides back-up storage for data and instructions.
Hard disk drive, floppy drive and optical disk drives are some examples
of storage devices.
The data and instructions that are currently not being used by CPU,
but may be required later for processing, are stored in secondary
memory.
Secondary memory has a high storage capacity than the primary
memory.
Secondary memory is also cheaper than the primary memory.
It takes longer time to access the data and instructions stored in
secondary memory than in primary memory.
3. Cache Memory:
NOTE:
The data and instructions that are required during the processing of data are brought from
the secondary storage devices and stored in the RAM. For processing, it is required that the
data and instructions are accessed from the RAM and stored in the registers. The time
taken to move the data between RAM and CPU registers is large. This affects the speed of
processing of computer, and results in decreasing the performance of CPU.
Cache memory is a small, very high speed memory placed in between RAM
and CPU.
Cache memory increases the speed of processing.
Stores frequently accessed data to speed up operations.
CPU first checks cache for the required data. If data is not found in cache,
then it looks in the RAM for data.
Levels of cache:
L1 Cache: Closest to the CPU, very fast but small.
L2/L3 Cache: Slightly larger but slower than L1, shared between CPU
cores.
Memory Hierarchy
The memory hierarchy is structured to balance speed, capacity, and cost. It
typically includes:
Registers: Fastest, located within the CPU.
Cache: Divided into levels (L1, L2, L3) based on proximity to the CPU.
Main Memory (RAM): Slower than cache but larger in capacity.
Secondary Storage: Includes HDDs and SSDs, used for long-term data storage.
Memory Access
Memory Access Types:
1. Sequential Access: Data is accessed in a specific order (e.g., tape drives).
2. Random Access: Data can be accessed at any location without needing to
read through other data (e.g., RAM).
Addressing Schemes:
Addressing schemes determine how data is accessed in memory. They can be
classified into several types:
1. Direct Addressing
The address field in the instruction specifies the exact address in memory.
Example: If an instruction specifies address 1000, the data is fetched from that
specific location.
2. Indirect Addressing
The address field points to a location that contains the actual address of the data.
Example: If the instruction specifies address 2000, and the content of address
2000 is 1000, the data is fetched from address 1000.
3. Indexed Addressing:
Combines a base address with an index value to calculate the effective address.
Example: If the base address is 1000 and the index is 20, the effective address is
1020.
4. Register Addressing
Register addressing is an addressing mode in computer architecture where the operand
for an instruction is located in a CPU register rather than in main memory.
In this mode, the instruction specifies the register where the data resides, allowing the
CPU to quickly access the operand.
Example: Instructions may specify a register (e.g., R1) directly.
5. Base-Offset Addressing
Uses a base address from a register and an offset to determine the effective address.
Example: If the base register contains 1000 and the offset is 50, the effective address
is 1050.
Registers in the CPU
•Registers: Small, fast memory located within the CPU that temporarily hold data and instructions.
Types of Registers:
oData Registers: Store operands for arithmetic operations.
oAddress Registers: Hold memory addresses.
oControl Registers: Store instructions for controlling CPU operations.
oAccumulator: Stores intermediate arithmetic results.
•Role in CPU Operation:
Registers store data for immediate processing and play a crucial role in the execution cycle,
moving data to and from the main memory.
Virtual Memory
Virtual Memory: A memory management technique that uses both RAM and
disk space to simulate a larger memory capacity than physically available.
Types of virtual memory
Paging: Divides memory into fixed-size pages that are stored in both RAM and
secondary storage. The operating system swaps pages between the two as needed.
Segmentation: Divides programs into variable-sized segments based on logical
divisions (e.g., code, data, stack).
Benefits of Virtual Memory:
Allows running larger programs than physically available memory.
Improves multitasking by efficiently managing limited RAM.