Professional Documents
Culture Documents
Memory System
Contents
• Characteristics and hierarchy of memory systems
• Cache memory
• Main memory
• Secondary memory
• Virtual memory
• Memory management
Characteristics and Hierarchy of
Memory Systems
Characteristics of Memory System
• The memory unit is a essential component in any digital
computer since it is needed for storing programs and data.
1. Location
• Processor
• Internal (main)
• External (secondary)
2. Capacity
• An obvious characteristics of memory is its capacity.
• Capacity of a memory is typically expressed in terms of
bytes (1 byte=8bits) or words.
• Common word length are 8,16 and 32 bits
Characteristics of Memory System
3. Unit of Transfer
• Unit of transfer is equal to the number of electrical lines into
and out of the memory module.
• For main memory, this is the number of bits read out of or
written into memory at a time.
• For external memory, data are transferred in much larger
units than a word, referred to as blocks
Addressable Units
• In some systems, the addressable unit is the word.
• If we have A bits length of an address, then the number of
addressable unit is N=2A
Characteristics of Memory System
4. Method of Accessing
• Another distinction among memory types is the method of
accessing units of data.
a) Sequential Access
Memory is organized into units of data called, records.
Access must be in specific linear sequence and a shared
read write mechanism is used. (example: Tape units)
b) Direct Access
Individual blocks have unique address based on physical
location.
Access is by jumping to vicinity plus sequential search to
reach the final location
Access time depends on location and previous location
(example: Disk units)
Characteristics of Memory System
c) Random Access
Individual addresses identify locations exactly
Access time is independent of location or previous access
and is constant
(example: main memory/RAM)
d) Associative Memory
The word is retrieved based on a portion of its contents
rather than its address.
Access time is independent of location or previous access
(example: cache memory)
Characteristics of Memory System
5. Performance Parameters
a) Access time(latency)
For random access: it is the time from the instant that an
address presented to the memory to the time that the
data have been stored or made available for use.
For non random access: it is the time it takes to position
the read-write mechanism at the desired location.
b) Memory cycle time
Access time plus any additional time required before a
second access can commence.
Note: memory cycle time is concerned with the system
bus, not the processor.
Characteristics of Memory System
c) Transfer rate
This is the rate at which data can be transferred into or
out of a memory unit.
For random access:
[Transfer rate = 1/cycle time]
For non random access memory:
TN= TA+ n/R
Where: TN= the average time to read or write N-bits
TA=average access time
n=number of bits
R=transfer rate, in bits per second (bps)
Characteristics of Memory System
6. Physical Types
Semiconductor: RAM
Magnetic surface: Disk & Tape
Optical and magneto optical: CD & DVD
7. Physical Characteristics
Volatile/Non-volatile
Erasable/Non-erasable
8. Organisation
Physical arrangement of bits into words
Hierarchy of Memory
• The design constraints on computers memory can be
summed up by three questions:
1. How much? =Capacity
2. How fast?=access time
3. How expensive? =cost
• Memory systems can be implemented by variety of
technologies, across this spectrum of technologies, the
following relationships holds:
Faster access time, greater cost per bit
Greater capacity, smaller cost per bit
Greater capacity, slower access time
Hierarchy of Memory
• Generally, the objective behind designing a memory
hierarchy is to have a memory system that performs as
if it consists entirely of the fastest unit and whose cost
is dominated by the cost of the slowest unit
Hierarchy of Memory
• As one goes down the hierarchy, the following occur
a) Decrease cost per bit
b) Increasing capacity
c) Increasing access time
d) Decrease frequency of access of the memory by the
processor
• The effectiveness of memory hierarchy depends on the
principle of moving information into the fast memory
infrequently and accessing it many times before replacing
it with new information.
• This principle is possible due to a phenomenon called
locality of reference
Hierarchy of Memory
Locality of reference: with a given period of time, programs
tend to reference a relatively confined area of memory
repeatedly.
There exists two forms of locality:
Spatial locality
Temporal locality
• Spatial Locality (locality in space): refers to the
phenomenon that when a given address has been referenced,
it is most likely that addresses near it will be referenced with
in a short period of time.
• Temporal Locality (locality in time): refers to the
phenomenon that once a particular memory item has been
referenced, it is most likely that it will be referenced next.
Example: an instruction in a program loop
Cache Memory
Cache Memory Principle
• Cache is at the first level of memory hierarchy and used to
keep the information expected to be used more frequently by
the CPU.
• Sits between normal main memory and CPU
• Contains a copy of portion of main memory
• May be located on CPU chip or module
Cache Memory Principle
• At any given time some active portion of the main memory is
duplicated in the cache.
• Therefore when the processor makes a request for a memory
reference, the request is first sought in the cache.
• If the request corresponds to an element that is currently residing
in the cache, get from cache (fast)==cache hit.
• On the other hand, if the request corresponds to an element that is
not currently in the cache, read required block from main memory
to cache== cache miss.
A cache hit ratio, hc: probability of finding the requested
element in the cache.
A cache miss ratio, (1-hc): probability of not finding the
requested element in the cache.
• Cache includes tags to identify which block of main memory is in
each cache slot
Cache/Main Memory Structure
Cache/Main Memory Structure
• Main memory consists up to 2n addressable words, with each
word having a unique n-bit address.
• For mapping purposes, let us assume this memory consists of
a number of fixed length blocks of k words each.
M=2n/k (number of blocks in main memory)
• The cache consists of m blocks, called lines. Each line
contains k-words, plus a tag of a few bits and other control
bits.
Note:
The length of a line, not including tag and control bits, is the
line size (m)- (m<<M)
A tag is usually a portion of the main memory address.
Typical Cache Organization
Cache Mapping Function
• A request for accessing a memory element is made by the
processor through issuing the address of the requested
element.
• To determine the whereabouts of the requested element
address translation has to be made.
This is one of the functions performed by the memory
management unit (MMU)
Cache Mapping Function
Cache Memory Organization
• There are three main different organization techniques
used for cache memory.
• The techniques differ in two main aspects:
1. The criterion used to place, in the cache, an incoming
block from the main memory.
2. The criterion used to replace a cache block by an
incoming block (on cache full)
Cache Memory Organization
1. Direct Mapping: maps each block of main memory into
only one possible cache line.
Many to one mapping techniques
The mapping is expressed as:
i=j modulo m
Where
i=cache line number
j=main memory block number
m=number of lines in the cache
Example
Cache Memory Organization
• The main advantage of the direct-mapping technique is its
simplicity in determining where to place an incoming main
memory block in the cache.
• The main disadvantage is the inefficient use of the cache.
This is due to, a number of main memory block may compete
for a given cache line even if there exist other empty cache
lines.
• According to direct mapping technique the MMU interprets
the address issued by the processor by dividing the address
into three fields:
Cache Memory Organization
Generally,
Address length= (s+w)bits
Number of addressable units=2s+w words/or bytes
Block size=line size=2w words/or bytes
Number of blocks in main memory=2s+w/2w=2s
Number of lines in the cache=2r=m
Size of cache=2r+w words/or bytes
Size of tag=(s-r)bits
Where
• w-->a unique word within a block of main memory
• s-->specify one of 2s blocks of main memory
• The cache logic interprets these s bits as a tag of (s-r) bits and as a
line field of r-bits
• m=2r-->identifies line of cache
Cache Memory Organization
2. Fully Associative Mapping: an incoming main memory
block can be placed in any available cache block.
The address issued by the processor need only have two fields
i.e. the Tag and Word fields
Tag-->uniquely identifies the block while residing in the cache
Word-->identifies the element within the block that is requested by
the processor
The MMU interprets the address issued by the processor by
dividing it into two fields.
Virtual address: