MEMORY ORGANIZATION
1
2
MEMORY UNIT
Sandesh
3 Memory Unit
An essential component in any general purpose computer since
it is needed to store programs and data.
memory unit that communicates directly with the CPU = main
memory
devices that provide backup storage = auxiliary memory.
Auxiliary memory devices are used to store system programs,
large data files and other backup information. Only
programs and data currently needed by the processor
reside in main memory. All other information is stored in
main memory and transferred to main memory when
needed.
4 Cache Memory
• Memory that lies in between main memory
and CPU
Holds those parts of the program and
data that are most heavily used
• increases the overall processing speed of
the computer by providing frequently
required data to the CPU at a faster speed.
5
Main Memory
• Memory unit that communicates directly with
CPU
• Programs and data currently needed by the
processor reside here
• Also known as primary memory
• RAM and ROM
6
Auxiliary Memory
• Made of devices that provide backup storage
• Magnetic tapes, Magnetic disks
• At the bottom of the hierarchy are the relatively
slow magnetic tapes used to store removable
files whereas at the top level, magnetic disks
used as backup storage
10
M
a
g
n Main
I/O Processor
e Memory
t
Magnetic
i disk
c
t
a
p
e Cach
s CP
Memory
e
U
Fig: Memory Hierarchy in a Computer
System
11
MAIN MEMORY
Sumanti
12
Main memory
Random Access Memory (RAM)
The main memory is the central storage unit in a
computer system.
Integrated circuit RAM consist essentially of
internal flip flops that store the binary information.
The dynamic RAM offers reduced power
consumption and larger storage capacity in a
single memory chip.
Read Only Memory (ROM)
Most of the main memory in a general purpose
computer is made up of RAM integrated circuit chip but
a portion of the memory may be constructed with ROM
chip.
ROM is used for storing program that are permanently
resident in the computer and for tables of constants.
A rom that do not change in value once the
production of the computer is completed.
13 TYPES OF RAM
SRAM DRAM
• Does not lose its content • Loses its content after few
until computer is turned off seconds
• Information is stored in form of • Information is stored in the
voltage form of charge
• faster • slower
14
ROM
• Permanent memory
• Stores information required for computer
operations
• Types of rom(PROM,EPROM,EEPROM)
1 Boot Strap loader
5
Initial program whose function is to start the computer
operating system after the power is turned on. and it is
stored in the rom portion of the main memory .
Computer start up :starting the execution of initial program after
computer is turned on
Boot strap loader loads the portion of disk to main memory
and control is then transferred to os.
2
1
RAM AND ROM CHIP
Shiv
RAM AND ROM CHIPS
22
RAM chip:
RAM chip is better suited for communication with the CPU if it has one
or more control inputs that select the chip only when needed.
Another common feature is a bidirectional data bus that allows the
transfer of data either from memory to CPU during a read operation ,or
from CPU to memory during write operation.
The RAM integrated circuit chips are further classified into two possible
operating modes, static and dynamic.
Fig. RAM chip
23
24
A 128 * 8 RAM chip has a memory capacity of 128 words of eight bits (one
byte) per word. This requires a 7-bit address and an 8-bit bidirectional data
bus.
The 8-bit bidirectional data bus allows the transfer of data either from
memory to CPU during a read operation or from CPU to memory during
a write operation.
The read and write inputs specify the memory operation, and the two chip
select (CS) control inputs are for enabling the chip only when the
microprocessor selects it.
The bidirectional data bus is constructed using three-state buffers.
The output generated by three-state buffers can be placed in one of the three
possible states which include a signal equivalent to logic 1, a signal equal to
logic 0, or a high-impedance state.
ROM
The primary component of the main memory is RAM integrated circuit
chips, but a portion of memory may be constructed with ROM chips.
A ROM memory is used for keeping programs and data that are
permanently resident in the computer.
Apart from the permanent storage of data, the ROM portion of main
memory is needed for storing an initial program called a bootstrap
loader. The primary function of the bootstrap loader program is to
start the computer software operating when power is turned on.
ROM chips are also available in a variety of sizes and are also used as
per the system requirement. The following block diagram
demonstrates the chip interconnection in a 512 * 8 ROM chip.
ROM
2 chip
5
A ROM chip is
unidirectional.
A ROM chip has a similar organization as a RAM chip. However, a ROM
can only perform read operation; the data bus can only operate in an output
mode.
The 9-bit address lines in the ROM chip specify any one of the 512 bytes
stored in it.
The value for chip select 1 and chip select 2 must be 1 and 0 for the unit to
operate. Otherwise, the data bus is said to be in a high-impedance state.
Memory Address Map
The interconnection between memory and the processor
is then established from knowledge of the size of memory
needed and the type of RAM and ROM chip available.
The addressing of memory can be established by means
of a table that specify the memory address assigned to
each chip. The table is called memory address map.
It is a pictorial representation of assigned address space
for each chip in the system.
Memory Connection to CPU
RAM and ROM chips are connected to the CPU
through the data and address buses.
The low order line in the address bus select the byte
within the chips and other lines in the address bus
select a particular chip through its chip select inputs.
The selection between RAM and ROM is achieved
through bus line 10 .
The RAMs are selected when the bit in this line is 0 and
the ROM when the bit is 1.
ASSOCIATIVE MEMORY
A memory unit accessed by content is called an
associative memory or content addressable memory
(CAM).This type of memory is accessed simultaneously
and in parallel on the basis of data content rather than
by specific address or location.
Hardware organization
Thekey register provides a mask for choosing a
particular field or key in the argument world. the entire
argument is compared with each memory word if the
key register contains all 1’s.
The functional registers like the argument
register A and key register K each have n bits, one for
each bit of a word.
The match register M consists of m bits, one for each
memory word.The words which are kept in the memory
are compared in parallel with the content of the
argument register
The key register (K) provides a mask for choosing a particular
field or key in the argument word. If the key register contains a
binary value of all 1's, then the entire argument is compared
with each memory word.
Otherwise, only those bits in the argument that have 1's in their
corresponding position of the key register are compared. Thus,
the key provides a mask for identifying a piece of information
which specifies how the reference to memory is made.
Only the three leftmost bits of A are compared with memory
words because A has 1’s in these position.
A 101 111100
K 111 000000
Word 1 100 111100 NO MATCH
Word 2 101 000001 MATCH
Word 2 matches the unmasked argument field because
the three leftmost bits of the argument and the word
are equal.
Match logic
The magic logic for each word can be derived from the
comparison algorithm for two binary numbers.
The equality of two bits can be expressed logically by
the Boolean function
Xj=AiFj +A’i+F’j
Wherex1=1 if the pair of bits in position j are equal;
otherwise, x1=0.
Fora word i to be equal the argument in A we must
have all x1 variables equal to 1.the Boolean condition
is
Mi=x , x ,x ,………..x
1 2 3 n
M1=(x1+k1’)(x2+k2)(x3+k3)…..(xn+kn)
Read operation
If more than one word in memory matches the
unmasked argument field, all the matched words will
have 1’s in the corresponding bit position of the match
register. it is then necessary to scan the bits of the
match register one at a time.
The matched words are read in sequence by applying a
read signal to each word line whose corresponding Mi
bit is a 1.
Write operation
An associative memory must have a write
capability for storing the information to be searched.
Writing in an associative memory can take different
forms, depending on the application.
CACHE MEMORY
Analysis of a large number of typical programs has shown
that references to memory at any given interval of time
tend to be confined within a few localized memory areas in
memory. This phenomenon is known as the property of
locality of reference.
The active portion of the program and data are
placed in a fast small memory, the average memory
access time can be reduced, thus reducing the total
execution time of the program. Such a fast small memory
is referred to as a cache memory.
The basic operation of a cache memory is as follows:
When the CPU needs to access memory, the cache is
examined. If the word is found in the cache, it is read from
the fast memory.
If the word addressed by the CPU is not found in the cache,
the main memory is accessed to read the word.
A block of words one just accessed is then transferred from
main memory to cache memory. The block size may vary
from one word (the one just accessed) to about 16 words
adjacent to the one just accessed.
The performance of the cache memory is frequently measured
in terms of a quantity called hit ratio.
When the CPU refers to memory and finds the word in cache, it
is said to produce a hit.
If the word is not found in the cache, it is in main memory and
it counts as a miss.
The ratio of the number of hits divided by the total CPU
references to memory (hits plus misses) is the hit ratio.
The cache is the fastest component in the memory hierarchy
and approaches the speed of CPU components.
The transformation of data from main memory to cache
memory is referred to as a mapping process. There types of
mapping procedures are of practical interest when
considering the organization of cache memory:
1. Associative Mapping
2.Direct Mapping
3.Set-Associative Mapping
The main memory can store 32k words of 12 bits each.The
cache is capable of stories storing 512 of these words at any
given time.
Associative mapping
The associative memory stores both the
address and content (data) of the memory word.This
permits any location in cache to store any word from
main memory .the diagram shows three words
presently stored in the cache. The address value of 15
bits is shown as a five digit octal number and its
corresponding 12 bits word is placed in the argument
as a four-digit octal number.
Direct mapping
The CPU address of 15 bits is divided into two
fields. The nine least significant bits constitute the
index field and the remaining six bits from the tag
field.
The figure shows that main memory needs an address
that includes both the tag and the index bits.
The number of bits in the index field is equal to the
number of address bits required to access the cache
memory.
Set-Associative memory Mapping
It was mentioned previously that the
disadvantage of direct mapping is that two with the
same index in their address but with different tag
values cannot reside in cache memory at the same
time. A third type of cache organization, called set-
associative mapping.
The most common replacement algorithm used are:
random replacement ,first-in first-out (FIFO), and least
recently used LRU.
Writing into Cache
CPU finds a word in cache during a read
operation,the main memory is not involved in the
transfer. The simplest and most commonly used
procedure is to update main memory with every
memory write operation, with cache memory called
Write-through method.
The second procedure is called the Write-back
method.In this method only the cache location is
updated during a write operation.
Cache Initialization
The cache is initialized when power is applied to the
computer or when the main memory is loaded with a
complete set of programs from auxiliary memory.
After initialization the cache is considered to be empty but
in effect it contains non valid data.
Each word in cache a Valid bit to indicate whether or not
the word contains valid data.
The cache is initialized by clearing all the valid data bits to
0.If the valid bit happens to be 0,the new word
automatically replaces the invalid data.
27
VIRTUAL MEMORY
Sanja
2 Address space and Memory space
9
An address used by the programmer is virtual
memory , the set of such address is called address
space.
An address in main memory is location ,the set of
such location is called memory space.
.
30
32
33 Address Mapping using Pages
Blocks (or page frame): Blocks are the groups of equal
size which are broken down from physical memory
and ranges from 64 to 4096words each.
Pages: refers to a portion of subdivided virtual
memory having same size as blocks i.e. groups of
address space.
Page frame: portions of programs are moved from
auxiliary memory to main memory in records equal to
the size of a page.The term “page frame”is sometimes
used to denote a block.
34 Example: consider computer with address space = 8K and memory space = 4K.
If we spit both spaces into
groups of 1k words we get
8 pages and 4 blocks.
.
35
Page Replacement
A virtual memory system is a combination of hardware and
software techniques. A memory management software
system handles all the software operations for the efficient
utilization of memory space.
When a program starts execution one or more pages are
transferred into main memory and the page table is set
to indicate their position.The program is executed from
main memory until it attempts to reference a page is
called page fault.
.
36
There are numerous page replacement algorithms, two of
which are:
1. First-in First-out (FIFO): replaces a page that has
been in memory longest time.
2. Least Recently Used (LRU): assumes that least recently used
page is the better candidate for
removal than the least recently loaded page.
37
When a page fault occurs in a virtual memory
system, it signifies that the page referenced by the
program is not in main memory.
A new page is then transferred from auxiliary memory
to main memory. If main memory is full, it would be
necessary to remove a page from a memory block to
make a room for a new page.
The policy for choosing pages to remove is
determined from the replacement algorithm that is
used.
46
THANK
YOU!