Unit- 2
Computer Memory, Number
Systems & Set Theory
Memory
Hierarchy
Definition:
Registers are small, high-speed storage units located inside the CPU. They temporarily hold
data and instructions that the CPU is currently processing.
Explanation:
Registers are the fastest memory in the computer system.
Used for immediate operations, such as holding operands and results of
arithmetic/logical operations.
They store control information, memory addresses, instructions, and intermediate
results.
Very limited in size, usually between 32 to 128 bits per register.
Example: Accumulator, Instruction Register (IR), Program Counter (PC), Stack Pointer (SP).
Cache Memory (L1, L2, L3)
Definition:
Cache memory is a small-sized, high-speed memory placed between the CPU and the
main memory (RAM) to reduce the time taken to access data from RAM.
Explanation:
Stores frequently used instructions and data so that they can be quickly accessed by
the CPU.
Improves the performance and speed of the processor.
Three levels:
◦ L1 Cache: Closest to the CPU core, very fast, smallest (usually 32 KB – 256 KB).
◦ L2 Cache: Slower than L1 but larger (512 KB – several MBs), may be shared by cores.
◦ L3 Cache: Shared among multiple CPU cores, larger and slower than L1/L2.
Example: Modern Intel i7 processors have 3-level cache structures.
Main Memory (RAM)
Definition:
Main memory or RAM is the primary memory of the computer that stores data
and programs temporarily while they are in use.
Explanation:
RAM is volatile, meaning data is lost when the power is turned off.
It allows random access to memory locations, meaning any byte of memory can be accessed
without touching previous bytes.
Faster than secondary memory but slower than cache and registers.
Two main types:
◦ DRAM (Dynamic RAM) – slower, needs frequent refreshing.
◦ SRAM (Static RAM) – faster and costlier, used in cache.
Example: 8GB or 16GB DDR4 RAM in laptops and PCs.
Secondary Memory (Hard
Disk, SSD)
Definition-
Secondary memory is non-volatile storage used to permanently store data, programs,
and the operating system.
Explanation:
Not directly accessed by the CPU – Data must be loaded into RAM first.
Two major types:
◦ Hard Disk Drives (HDDs): Use spinning disks and magnetic storage; slower, cheaper, and higher
capacity.
◦ Solid-State Drives (SSDs): Use flash memory, faster and more durable, but costlier than HDDs.
Used to store files, software, operating systems, etc.
Example: 1TB HDD or 512GB SSD in laptops.
Tertiary Storage (Optical,
Magnetic tapes)
Definition:
Tertiary storage refers to external or archival storage used for backup, long-term
storage, or rarely accessed data.
Explanation:
Slower and cheaper than secondary storage.
Often used for archiving large volumes of Data.
Types:
◦ Optical Disks: CDs, DVDs, Blu-rays – read/write using lasers.
◦ Magnetic Tapes: Store data sequentially; used in large-scale backups and archives.
Not commonly used for regular computing tasks.
Random Access
Memory (RAM)
Random Access Memory (RAM) is a
volatile memory in a computer system
that temporarily stores data and machine
code currently being used. It allows data
to be read from and written to almost
instantly, which makes it essential for
system performance.
Key Features
Volatile: Loses data when power is
turned off.
Fast Access: Much faster than
secondary storage (e.g., HDD, SSD).
Temporary Storage: Holds operating
system, application programs, and data
currently in use.
Read & Write: Supports both read and
write operations.
Types of RAM:
DRAM (Dynamic RAM)
DRAM (Dynamic RAM) is a type of volatile
memory that stores each bit of data in a
separate capacitor within an integrated
circuit. It needs to be refreshed thousands of
times per second to retain data, hence the
term "dynamic".
Working Principle:
Each memory cell in DRAM consists of:
◦ A capacitor (stores charge as data – 0 or
1)
◦ A transistor (controls access to the
capacitor)
Due to charge leakage, DRAM cells must be
refreshed regularly (typically every 64ms).
SRAM (Static RAM)
Faster and expensive, no refreshing needed.
SRAM (Static RAM) is a type of volatile memory that
uses flip-flops (made from transistors) to store each bit
of data. Unlike DRAM, it does not need to be refreshed,
hence called "static".
Working Principle:
Each bit is stored using a Bis-table flip-flop circuit
(usually 6 transistors per bit).
The state remains stable (static) as long as power is
supplied.
Types of SRAM
Asynchronous SRAM
◦ Operates independently of the system clock.
◦ Used in network devices, cache, and embedded systems.
◦ Faster response to any address change.
Synchronous SRAM (Sync SRAM)
◦ Operates in sync with system clock.
◦ Better suited for high-speed applications like CPUs.
◦ Often used in cache memory and graphics cards.
Non-Volatile SRAM (NV SRAM)
◦ Combines SRAM with EEPROM or Flash.
◦ Retains data even when power is lost.
◦ Used in critical systems, embedded controllers.
Read Only Memory
(ROM)
- Non-volatile memory used to store firmware.
Types of ROM:
1. PROM (Programmable ROM)
2. EPROM (Erasable PROM)
3. EEPROM (Electrically Erasable PROM)
Secondary Storage
Devices
1. Magnetic Tape: Sequential access, used for backups.
2. Magnetic Disk: Hard Drives, fast and reliable.
3. Optical Disk: CDs, DVDs; use lasers to read/write data.
Number Systems
- Represent numerical values.
1. Binary (Base 2)
2. Octal (Base 8)
3. Decimal (Base 10)
4. Hexadecimal (Base 16)
Number System
Conversions
- Decimal to Binary, Octal, Hex
- Binary to Decimal, Octal, Hex
- Use successive division, grouping, and position values for conversion.
Alphanumeric Codes
1. ASCII (American Standard Code for Information Interchange)
2. EBCDIC (Extended Binary Coded Decimal Interchange Code)
- Used for encoding characters and symbols in binary.
Set Theory -
Introduction
- A set is a collection of distinct elements.
Types:
1. Finite and Infinite Sets
2. Null Set, Singleton Set
3. Equal, Equivalent, Subset, Power Set
Operations on Sets
1. Union (A ∪ B)
2. Intersection (A ∩ B)
3. Difference (A - B)
4. Complement (A')