0% found this document useful (0 votes)
485 views

Cache Memory and Associative Memory 2.2.2

Cache memory is a small, fast memory located close to the processor that stores frequently accessed data from main memory in order to reduce access time. Cache memory is organized into multiple levels (L1, L2, L3) with different sizes and access speeds. Associative memory, also called content-addressable memory (CAM), allows data to be accessed based on its content rather than a specific address. It works by comparing input data to stored data in parallel and returning a match. Associative caches improve on direct-mapped caches by reducing contention through greater flexibility in data placement.

Uploaded by

Arjun Nain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
485 views

Cache Memory and Associative Memory 2.2.2

Cache memory is a small, fast memory located close to the processor that stores frequently accessed data from main memory in order to reduce access time. Cache memory is organized into multiple levels (L1, L2, L3) with different sizes and access speeds. Associative memory, also called content-addressable memory (CAM), allows data to be accessed based on its content rather than a specific address. It works by comparing input data to stored data in parallel and returning a match. Associative caches improve on direct-mapped caches by reducing contention through greater flexibility in data placement.

Uploaded by

Arjun Nain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Cache Memory and Associative Memory 2.2.

A faster and smaller segment of memory whose access time is as close as registers are
known as Cache memory. In a hierarchy of memory, cache memory has access time lesser
than primary memory. Generally, cache memory is very smaller and hence is used as a
buffer.

Need of cache memory

Data in primary memory can be accessed faster than secondary memory but still, access
times of primary memory are generally in few microseconds, whereas CPU is capable of
performing operations in nanoseconds. Due to the time lag between accessing data and
acting of data performance of the system decreases as the CPU is not utilized properly, it
may remain idle for some time. In order to minimize this time gap new segment of memory
is Introduced known as Cache Memory.

How does cache work?

In order to understand the working of cache we must understand few points:


 Cache memory is faster, they can be accessed very fast
 Cache memory is smaller, a large amount of data cannot be stored
Whenever CPU needs any data, it searches for corresponding data in the cache (fast
process) if data is found, it processes the data according to instructions, however, if data is
not found in the cache CPU search for that data in primary memory (slower process) and
loads it into the cache. This ensures frequently accessed data are always found in the cache
and hence minimizes the time required to access the data.

Cache performance

 On searching in the cache if data is found, a cache hit has occurred.


 On searching in the cache if data is not found, a cache miss has occurred.

Performance of cache is measured by the number of cache hits to the number of searches.
This parameter of measuring performance is known as the Hit Ratio.
Hit ratio = (Number of cache hits)/(Number of searches)

Types of Cache Memory

L1 or Level 1 Cache: It is the first level of cache memory that is present inside the
processor. It is present in a small amount inside every core of the processor separately. The
size of this memory ranges from 2KB to 64 KB.
L2 or Level 2 Cache: It is the second level of cache memory that may present inside or
outside the CPU. If not present inside the core, It can be shared between two cores
depending upon the architecture and is connected to a processor with the high-speed bus.
The size of memory ranges from 256 KB to 512 KB.
L3 or Level 3 Cache: It is the third level of cache memory that is present outside the CPU
and is shared by all the cores of the CPU. Some high processors may have this cache. This
cache is used to increase the performance of the L2 and L1 cache. The size of this memory
ranges from 1 MB to 8MB.

Cache vs RAM

Although Cache and RAM both are used to increase the performance of the system there
exists a lot of differences in which they operate to increase the efficiency of the system.  

RAM  Cache

The cache is smaller in size. Memory


RAM is larger in size compared to cache. ranges from 2KB to a few MB
Memory ranges from 1MB to 16GB  generally.

It stores data that is currently processed by the


processor. It holds frequently accessed data.

OS interacts with secondary memory to get data OS interacts with primary memory to
to be stored in Primary Memory or RAM get data to be stored in Cache.

It is ensured that data in RAM are loaded before


access to the CPU. This eliminates RAM miss CPU searches for data in Cache, if not
never. found cache miss occur.

Associative Memory
An associative memory can be treated as a memory unit whose saved information can be
recognized for approach by the content of the information itself instead of by an address or
memory location. Associative memory is also known as Content Addressable Memory
(CAM).
The block diagram of associative memory is shown in the figure. It includes a memory array
and logic for m words with n bits per word. The argument registers A and key register K
each have n bits, one for each bit of a word.
The match register M has m bits, one for each memory word. Each word in memory is
related in parallel with the content of the argument register.
The words that connect the bits of the argument register set an equivalent bit in the match
register. After the matching process, those bits in the match register that have been set denote
the fact that their equivalent words have been connected.
Reading is proficient through sequential access to memory for those words whose equivalent
bits in the match register have been set.
An associative memory can be treated as a memory unit whose saved information can be
recognized for approach by the content of the information itself instead of by an address or
memory location. Associative memory is also known as Content Addressable Memory
(CAM).
The block diagram of associative memory is shown in the figure. It includes a memory array
and logic for m words with n bits per word. The argument register A and key register K each
have n bits, one for each bit of a word.
The match register M has m bits, one for each memory word. Each word in memory is
related in parallel with the content of the argument register.
The words that connect the bits of the argument register set an equivalent bit in the match
register. After the matching process, those bits in the match register that have been set denote
the fact that their equivalent words have been connected.
Reading is proficient through sequential access to memory for those words whose equivalent
bits in the match register have been set.

The key register supports a mask for selecting a specific field or key in the argument word.
The whole argument is distinguished with each memory word if the key register includes all
1's.
Hence, there are only those bits in the argument that have 1's in their equivalent position of
the key register are compared. Therefore, the key gives a mask or recognizing a piece of data
that determines how the reference to memory is created.
The following figure can define the relation between the memory array and the external
registers in associative memory.

The cells in the array are considered by the letter C with two subscripts. The first subscript
provides the word number and the second determines the bit position in the word. Therefore,
cell Cij is the cell for bit j in word i.
A bit in the argument register is compared with all the bits in column j of the array supported
that Kj = 1. This is completed for all columns j = 1, 2, . . ., n.
If a match appears between all the unmasked bits of the argument and the bits in word i, the
equivalent bit Mi in the match register is set to 1. If one or more unmasked bits of the
argument and the word do not match, Mi is cleared to 0.
Associative Cache
A type of CACHE designed to solve the problem of cache CONTENTION that plagues the
DIRECT MAPPED CACHE. In a fully associative cache, a data block from any memory
address may be stored into any CACHE LINE, and the whole address is used as the cache
TAG: hence, when looking for a match, all the tags must be compared simultaneously with
any requested address, which demands expensive extra hardware. However, contention is
avoided completely, as no block need ever be flushed unless the whole cache is full, and
then the least recently used may be chosen.
A set-associative cache is a compromise solution in which the cache lines are divided into
sets, and the middle bits of its address determine which set a block will be stored in: within
each set the cache remains fully associative. A cache that has two lines per set is called two-
way set-associative and requires only two tag comparisons per access, which reduces the
extra hardware required. A DIRECT MAPPED CACHE can be thought of as being one-way
set associative, while a fully associative cache is n-way associative where n  is the total
number of cache lines. Finding the right balance between associativity and total cache
capacity for a particular processor is a fine art-various current cpus employ 2 way, 4-way
and 8-way designs.
Associative memory is also known as content addressable memory (CAM) or associative
storage or associative array. It is a special type of memory that is optimized for performing
searches through data, as opposed to providing a simple direct access to the data based on the
address.
It can store the set of patterns as memories when the associative memory is being presented
with a key pattern, it responds by producing one of the stored patterns which closely
resembles or relates to the key pattern.
It can be viewed as data correlation here. input data is correlated with that of stored data in
the CAM.
It forms of two types:
Associative memory of conventional semiconductor memory (usually RAM) with added
comparison circuity that enables a search operation to complete in a single clock cycle. It is a
hardware search engine, a special type of computer memory used in certain very high
searching applications. Applications of Associative memory:
It can be only used in memory allocation format.
It is widely used in the database management systems, etc.
Advantages of Associative memory:
1. It is used where search time needs to be less or short.
2. It is suitable for parallel searches.
3. It is often used to speedup databases.
4. It is used in page tables used by the virtual memory and used in neural networks.
Disadvantages of Associative memory:
1. It is more expensive than RAM.
2. Each cell must have storage capability and logical circuits for matching its
content with external argument.

Associative Memory

The time required to find an object stored in memory can be significantly reduced if the
stored data can be identified by the content of the data for its own use rather than by access.
A memory unit accessed by a material is known as an associative memory or a content
addressable memory (CAM). This type of memory is accessed simultaneously and in
parallel based on the data content rather than the specific address or location. if a word is
written in associative memory, no address is given. Memory is capable of finding empty
unused space to store the word, or part of the word specified. memory detects all words that
match the specified content and marks them for reading. 

Cache Memory

If the active part of the program and data can be kept in fast memory, the total execution
time can be reduced significantly. Such memory is known as cache memory, which is
inserted between the CPU and the main memory. To make this arrangement effective. The
cache needs to be much faster than main memory. This approach is more economical than
the use of fast memory devices to implement the entire main memory. 

Differences between associative and cache memory:

S.
No. Associative Memory Cache Memory

A memory unit access by content is A fast and small memory is called


1 called associative memory. cache memory.

It reduces the time required to find the It reduces the average memory access
2 item stored in memory. time.

3 Here data accessed by its content. Here, data are accessed by its address.

It is used where search time is very It is used when particular group of


4 short. data is accessed repeatedly.

Its basic characteristic is its logic circuit Its basic characteristic is its fast
5 for matching its content. access.

It is expensive as compared to
6 It is not as expensive as cache memory. associative memory.

It is suitable for parallel data search It is useful in increasing the efficiency


7 mechanism. of data retrieval. 

References
Reference Books:

 J.P. Hayes, “Computer Architecture and Organization”, Third Edition.

 Mano, M., “Computer System Architecture”, Third Edition, Prentice Hall.

 Stallings, W., “Computer Organization and Architecture”, Eighth Edition, Pearson Education.
Text Books:

 Carpinelli J.D,” Computer systems organization &Architecture”, Fourth Edition, Addison


Wesley.

 Patterson and Hennessy, “Computer Architecture”, Fifth Edition Morgaon Kauffman.


Reference Website

 Differences between Associative and Cache Memory - GeeksforGeeks

You might also like