Module 5-Memory Organization
Module 5-Memory Organization
Sonal Hutke
• Chapter 5
1) List and explain the characteristics of memory.
2) Consider a 2-way set associative mapped cache of size 16 KB with block size 256 bytes. The size of the
main memory is 128 KB.Find 1. Number of bits in tag 2. Tag directory size
3) Explain the concept of locality of reference
4) A block set associative cache memory consists of 128 blocks divided into 4 block sets.The main memory
consists of 16384 blocks and each block contains 256 eight-bit words. i) How many bits are required for
addressing main memory. ii) How many bits are needed to represent TAG, SET and WORD fields.
5) Compare with suitable parameters SRAM with DRAM
6) Consider a 4-way set associative mapped cache with block size 4 KB. The size of the main memory is 16
GB and there are 10 bits in the tag. Find 1. Size of cache memory 2. Tag directory size
7) Write a short note on cache coherency.
8) Explain different memory Mapping Techniques
9) Consider a Cache memory of 16 words. Each block consists of 4 words. The size of the main memory is 128
bytes. Draw the Associative Mapping and Calculate the TAG and WORD size.
Sonal Hutke
What is Computer Memory?
• Computer memory is just like the human brain.
• It is used to store data/information and instructions.
• It is a data storage device where data is to be processed and
instructions required for processing are stored.
• It can store both the input and output.
• Characteristics of Computer Memory
• It is faster computer memory as compared to secondary memory.
• It is semiconductor memories.
• It is usually a volatile memory, and main memory of the computer.
• A computer system cannot run without primary memory.
Sonal Hutke
How Does Computer Memory Work?
• When you open a program, it is loaded from secondary
memory into primary memory. Because there are various types
of memory and storage, an example would be moving a
program from a solid-state drive (SSD) to RAM. Because
primary storage is accessed more quickly, the opened software
can connect with the computer’s processor more quickly. The
primary memory is readily accessible from temporary memory
slots or other storage sites.
• Memory is volatile, which means that data is only kept
temporarily in memory. Data saved in volatile memory is
automatically destroyed when a computing device is turned off.
When you save a file, it is sent to secondary memory for
storage.
Sonal Hutke
• There are various kinds of memory accessible. It’s operation
will depend upon the type of primary memory used. but
normally, semiconductor-based memory is more related with
memory. Semiconductor memory made up of IC (integrated
circuits) with silicon-based metal-oxide-semiconductor (MOS)
transistors.
Sonal Hutke
Types of Computer Memory
In general, computer memory is of three types:
• Primary memory
• Secondary memory
• Cache memory
1. Primary Memory
• It is also known as the main memory of the computer system. It is
used to store data and programs or instructions during computer
operations. It uses semiconductor technology and hence is
commonly called semiconductor memory.
Sonal Hutke
Primary memory is of two types:
• RAM (Random Access Memory): It is a volatile memory. Volatile
memory stores information based on the power supply. If the
power supply fails/ interrupted/stopped, all the data and
information on this memory will be lost. RAM is used for booting
up or start the computer. It temporarily
stores programs/data which has to be executed by the processor.
RAM is of two types:
• SRAM (Static RAM): S RAM uses transistors and the circuits of this
memory are capable of retaining their state as long as the power is
applied. This memory consists of the number of flip flops with each flip
flop storing 1 bit. It has less access time and hence, it is faster.
• DRAM (Dynamic RAM): D RAM uses capacitors and transistors and
stores the data as a charge on the capacitors. They contain thousands of
memory cells. It needs refreshing of charge on capacitor after a few
milliseconds. This memory is slower than S RAM.
Sonal Hutke
Sonal Hutke
• ROM (Read Only Memory): It is a non-volatile memory. Non-
volatile memory stores information even when there is a power
supply failed/ interrupted/stopped. ROM is used to store
information that is used to operate the system. As its name
refers to read-only memory, we can only read the programs
and data that is stored on it. It contains some electronic fuses
that can be programmed for a piece of specific information. The
information stored in the ROM in binary format. It is also known
as permanent memory.
Sonal Hutke
ROM is of three types:
• PROM (Programmable Read Only Memory): This read-only
memory is modifiable once by the user. The user purchases a blank
PROM and uses a PROM program to put the required contents into
the PROM. Its content can’t be erased once written.
• EPROM (Erasable Programmable Read Only Memory): EPROM is
an extension to PROM where you can erase the content of ROM by
exposing it to Ultraviolet rays for nearly 40 minutes.
• EEPROM (Electrically Erasable Programmable Read Only
Memory): Here the written contents can be erased electrically. You
can delete and reprogramme EEPROM up to 10,000 times. Erasing
and programming take very little time, i.e., nearly 4 -10
ms(milliseconds). Any area in an EEPROM can be wiped and
programmed selectively.
Sonal Hutke
2. Secondary Memory
• It is also known as auxiliary memory and backup memory. It is a non-
volatile memory and used to store a large amount of data or
information. The data or information stored in secondary memory is
permanent, and it is slower than primary memory. A CPU cannot
access secondary memory directly. The data/information from the
auxiliary memory is first transferred to the main memory, and then
the CPU can access it.
• Characteristics of Secondary Memory
• It is a slow memory but reusable.
• It is a reliable and non-volatile memory.
• It is cheaper than primary memory.
• The storage capacity of secondary memory is large.
• A computer system can run without secondary memory.
• In secondary memory, data is stored permanently even when the
power is off.
Sonal Hutke
Memory Characteristics and Organization
Sonal Hutke
• Memory Hierarchy Design
1. Registers
• Registers are small, high-speed memory units located in the
CPU. They are used to store the most frequently used data and
instructions. Registers have the fastest access time and the
smallest storage capacity, typically ranging from 16 to 64 bits.
Sonal Hutke
2. Cache Memory
• Cache memory is a small, fast memory unit located close to the
CPU. It stores frequently used data and instructions that have been
recently accessed from the main memory. Cache memory is
designed to minimize the time it takes to access data by providing
the CPU with quick access to frequently used data.
• 3. Main Memory
• Main memory, also known as RAM (Random Access Memory), is the
primary memory of a computer system. It has a larger storage
capacity than cache memory, but it is slower. Main memory is used
to store data and instructions that are currently in use by the CPU.
Sonal Hutke
• Types of Main Memory
• Static RAM: Static RAM stores the binary information in flip
flops and information remains valid until power is supplied. It
has a faster access time and is used in implementing cache
memory.
• Dynamic RAM: It stores the binary information as a charge on
the capacitor. It requires refreshing circuitry to maintain the
charge on the capacitors after a few milliseconds. It contains
more memory cells per unit area as compared to SRAM.
Sonal Hutke
4. Secondary Storage
• Secondary storage, such as hard disk drives (HDD) and solid-state
drives (SSD), is a non-volatile memory unit that has a larger storage
capacity than main memory. It is used to store data and instructions
that are not currently in use by the CPU. Secondary storage has the
slowest access time and is typically the least expensive type of
memory in the memory hierarchy.
5. Magnetic Disk
• Magnetic Disks are simply circular plates that are fabricated with
either a metal or a plastic or a magnetized material. The Magnetic
disks work at a high speed inside the computer and these are
frequently used.
6. Magnetic Tape
• Magnetic Tape is simply a magnetic recording device that is covered
with a plastic film. It is generally used for the backup of data. In the
case of a magnetic tape, the access time for a computer is a little
slower and therefore, it requires some amount of time for accessing
the strip.
Sonal Hutke
Characteristics of Memory Hierarchy
• Capacity: It is the global volume of information the memory can
store. As we move from top to bottom in the Hierarchy, the capacity
increases.
• Access Time: It is the time interval between the read/write request
and the availability of the data. As we move from top to bottom in
the Hierarchy, the access time increases.
• Performance: Earlier when the computer system was designed
without a Memory Hierarchy design, the speed gap increased
between the CPU registers and Main Memory due to a large
difference in access time. This results in lower performance of the
system and thus, enhancement was required. This enhancement
was made in the form of Memory Hierarchy Design because of
which the performance of the system increases. One of the most
significant ways to increase system performance is minimizing how
far down the memory hierarchy one has to go to manipulate data.
• Cost Per Bit: As we move from bottom to top in the Hierarchy, the
cost per bit increases i.e. Internal Memory is costlier than External
Memory. Sonal Hutke
Cache Memory in Computer Organization
Sonal Hutke
Characteristics of Cache Memory
• Cache memory is an extremely fast memory type that acts as a
buffer between RAM and the CPU.
• Cache Memory holds frequently requested data and
instructions so that they are immediately available to the CPU
when needed.
• Cache memory is costlier than main memory or disk memory
but more economical than CPU registers.
• Cache Memory is used to speed up and synchronize with a
high-speed CPU.
Sonal Hutke
Cache Performance
• When the processor needs to read or write a location in the main
memory, it first checks for a corresponding entry in the cache.
• If the processor finds that the memory location is in the cache,
a Cache Hit has occurred and data is read from the cache.
• If the processor es not find the memory location in the cache,
a cache miss has occurred. For a cache miss, the cache allocates a
new entry and copies in data from the main memory, then the
request is fulfilled from the contents of the cache.
• The performance of cache memory is frequently measured in terms
of a quantity called Hit ratio.
Sonal Hutke
What is a Cache Hit and a Cache Miss?
Cache Hit: When the CPU finds the required data in the cache memory, allowing for quick access.
On searching in the cache if data is found, a cache hit has occurred.
Cache Miss: When the required data is not found in the cache, forcing the CPU to retrieve it from
the slower main memory. On searching in the cache if data is not found, a cache miss has occurred
Sonal Hutke
Locality of Reference
• Locality of reference allows caches to
store frequently accessed or nearby
data, significantly reducing access time
and improving system performance.
• Locality of reference is a key concept
that explains how caches work well in
computer systems.
• It describes the tendency of programs
to access a relatively small portion of
memory repeatedly over a short period
of time.
Sonal Hutke
There are two main types of locality of reference:
• 1. Temporal Locality (Time)
Definition: If a memory location is accessed, it is likely to be accessed
again in the near future.
Example: In loops, the same variables or instructions are repeatedly
accessed, so storing them in the cache improves performance.
Benefit to Caches: Caches retain recently used data. If data is accessed
multiple times within a short period, the processor can retrieve it
quickly from the cache instead of going back to main memory.
Sonal Hutke
2. Spatial Locality (Space)
Definition: If a memory location is accessed, nearby memory locations
(i.e., data stored in adjacent memory addresses) are likely to be
accessed soon.
Example: When iterating through arrays or accessing sequential
instructions, adjacent memory locations are accessed repeatedly.
Benefit to Caches: Caches usually fetch entire blocks of data (multiple
words or bytes) instead of a single piece of data. This is efficient
because data near the recently accessed data is also likely to be used,
taking advantage of spatial locality.
Sonal Hutke
How Locality of Reference
Improves Cache Performance
• Temporal Locality: When a piece
of data or an instruction is
repeatedly accessed, having it in
the cache allows the CPU to avoid
fetching it from slower main
memory multiple times.
• Spatial Locality: When a memory
block is loaded into the cache,
bringing adjacent blocks as well
helps to satisfy future accesses,
since nearby data is likely to be
accessed.
Sonal Hutke
for (int i = 0; i < 1000; i++)
{
sum += array[i];
}
Temporal Locality: The variable ‘I’ and sum are accessed multiple times, so
they remain in the cache.
Spatial Locality: As the program accesses ‘array[i]’, the cache loads blocks
of data from the array. Future iterations of the loop benefit from data
already present in the cache due to the block load.
Sonal Hutke
CACHE MAPPING TECHNIQUES:
Cache mapping techniques are methods used to determine where
data from main memory will be stored in the cache.
1. Direct Mapping
2. Fully Associative Mapping
3. Set-Associative Mapping
Sonal Hutke
• The cache organization is about
mapping data in memory to a location
in cache.
• A Simple Solution: One way to go
about this mapping is to consider last
few bits of long memory address to
find small cache address, and place
them at the found address.
• Problems With Simple Solution: The
problem with this approach is, we
lose the information about high order
bits and have no way to find out the
lower order bits belong to which
higher order bits.
Sonal Hutke
• Solution is Tag: To handle
above problem, more
information is stored in
cache to tell which block
of memory is stored in
cache. We store additional
information as Tag.
Sonal Hutke
1. Direct Mapping
• Structure: Each block of main memory maps to only
one specific cache line.
• Advantages: Simple and fast to compute the location
of a memory block in the cache.
• Disadvantages: Can lead to frequent cache misses,
known as conflict misses, when multiple memory
blocks map to the same cache line.
• Address Breakdown:
• Index bits: Used to find the cache line.
• Tag bits: Used to verify if the data in the cache line
corresponds to the requested memory block.
• Block offset: Used to find the exact data inside the block.
Sonal Hutke
Sonal Hutke
• Solution to above problem – Associativity What if we could store
data at any place in cache, the above problem won’t be there? That
would slow down cache, so we do something in between.
Sonal Hutke
2. Fully Associative Mapping
• Structure: Any block of memory can be placed in any cache line.
• Advantages: No conflict misses since any memory block can go
anywhere in the cache.
• Disadvantages: More complex hardware implementation, slower
lookup (requires searching all tags).
• Address Breakdown:
• Tag bits: The entire block's address, minus the block offset, serves as the
tag.
• Block offset: Used to find the exact data within the block.
Sonal Hutke
Sonal Hutke
Thank You!
(sonalj@sies.edu.in)
Sonal Hutke