Unit 4 Coa - Memory-1
Unit 4 Coa - Memory-1
Unit 4 Coa - Memory-1
MEMORY
Memory Hierarchy
A memory unit is an essential component in any digital computer since it is needed for storing
programs and data.
Data RAM is a volatile memory which ROM is a non-volatile memory which could
retention could store the data as long as the retain the data even when power is turned off.
power is supplied.
Working Data stored in RAM can be Data stored in ROM can only be read.
type retrieved and altered.
Use Used to store the data that has to It stores the instructions required during
be currently processed by CPU bootstrap of the computer.
temporarily.
CPU The CPU can access the data stored The CPU can not access the data stored on it
Interaction on it. unless the data is stored in RAM.
Size and Large size with higher capacity, with Small size with less capacity, with respect to
Capacity respect to ROM RAM
Storage A RAM chip can store only a few A ROM chip can store multiple megabytes (MB)
gigabytes (GB) of data. of data.
Cache Performance:
▪ Cache Performance: When the processor needs to read or write a location in 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 does 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
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.
▪ Hit ratio = hit / (hit + miss) = no. of hits/total accesses
▪ We can improve Cache performance using higher cache block size, and higher
associativity, reduce miss rate, reduce miss penalty, and reduce the time to hit in the
cache.
Cache Mapping
There are three different types of mapping used for the purpose of cache memory which is as
follows:
1. Direct mapping
2. Associative mapping,
3. Set-Associativ mapping.
1. Direct mapping
▪ In Direct mapping, assign each memory block to a specific line in the cache. If a line is
previously taken up by a memory block when a new block needs to be loaded, the old
block is trashed. An address space is split into two parts index field and a tag field.
▪ The cache is used to store the tag field whereas the rest is stored in the main memory.
Direct mapping`s performance is directly proportional to the Hit ratio.
▪ For purposes of cache access, each main memory address can be viewed as consisting of
three fields.
▪ The least significant w bits identify a unique word or byte within a block of main
memory.
▪ In most contemporary machines, the address is at the byte level. The remaining s bits
specify one of the 2s blocks of main memory.
▪ The cache logic interprets these s bits as a tag of s-r bits (most significant portion) and a
line field of r bits.
▪ This latter field identifies one of the m=2r lines of the cache. Line offset is index bits in
the direct mapping.
2. Associative Mapping
▪ In this type of mapping, the associative memory is used to store content and addresses
of the memory word.
▪ Any block can go into any line of the cache. This means that the word id bits are used to
identify which word in the block is needed, but the tag becomes all of the remaining
bits.
▪ This enables the placement of any word at any place in the cache memory. It is
considered to be the fastest and the most flexible mapping form. In associative mapping
the index bits are zero.
3. Set-associative Mapping
▪ This form of mapping is an enhanced form of direct mapping where the drawbacks of
direct mapping are removed. Set associative addresses the problem of possible
thrashing in the direct mapping method.
▪ It does this by saying that instead of having exactly one line that a block can map to in
the cache, we will group a few lines together creating a set.
▪ Then a block in memory can map to any one of the lines of a specific set. Set-associative
mapping allows that each word that is present in the cache can have two or more words
in the main memory for the same index address.
▪ Set associative cache mapping combines the best of direct and associative cache
mapping techniques. In set associative mapping the index bits are given by the set offset
bits. In this case, the cache consists of a number of sets, each of which consists of a
number of lines. The relationships are
Design of 512×8 RAM using 128×8 RAM
▪ If we see RAM physically then we notice that RAM is made up of a few chips. We can
design the required RAM size using basic RAM chips. We can observe a basic RAM chip
as follows:
2n = N
where n is the no. of address lines and N is the total memory in bytes.