Chapter 10 Co Bim III
Chapter 10 Co Bim III
Chapter 10 Co Bim III
Chapter 10
Memory Organization
10.1 Memory Hierarchy
Memory unit is an essential component in any digital computer since it is needed for storing programs and
data.
The memory unit that communicates directly with the CPU is called the main memory. Devices that provide
backup storage are called auxiliary memory.
Only programs and data currently needed by the processor reside in main memory. All other information is
stored in auxiliary memory and transferred to main memory when needed.
The memory hierarchy consists of all storage devices employed in a computer system from the slow but
high-capacity auxiliary memory to a relatively faster main memory, to an even smaller and faster cache
memory accessible to the high-speed processing logic.
The main memory occupies a central position by being able to communicate directly with the CPU and with
auxiliary memory devices through an I/O processor,
Access time of CPU and main memory are different. So, to co-ordinate the speed between these, a fast
memory is needed called as cache memory.
While the I/O processor manages data transfer between auxiliary memory and main memory, the cache
organization is concerned with the transfer of information between main memory and CPU.
As the storage capacity of the memory increases, the cost per bit for storing binary information decreases
and the access time of the memory becomes longer.
The auxiliary memory has a large storage capacity, is relatively inexpensive, but has low access speed
compared to main memory.
The cache memory is very small, relatively very small, relatively expensive, and has very high access speed.
CPU has direct access to both cache and main memory but not to auxiliary memory. The transfer from
auxiliary to main memory is usually done by means of direct memory access of large blocks of data.
Many OS are designed to enable the CPU to process a number of independent programs concurrently. This
concept, called multiprogramming, refers to the existence of two or more programs in different parts of
memory hierarchy at the same time. In this way, it is possible to keep all parts of the computer busy by
working with several programs in sequence.
The part of the computer system that supervises the flow of information between auxiliary memory and
main memory is called memory management system.
capacitor tends to discharge with time and the capacitors must be periodically recharged by refreshing the
dynamic memory.
The dynamic RAM offers reduced power consumption and larger storage capacity in a single memory chip.
Most of the main memory in a general-purpose computer is made up of RAM integrated circuit chips, but a
portion of the memory may be constructed with ROM chips.
RAM is used for storing the bulk of the programs and data that are subject to change. ROM is used for
storing programs that are permanently resident in the computer and for tables of constants that do not
change in the value once the production of the computer is completed.
Among other things, the ROM portion of main memory is needed for storing an initial program called as
bootstrap loader. The bootstrap loader is a program whose function is to start the computer software
operating when power is turned on.
Since RAM is volatile, its contents are destroyed when power is turned off. The contents of ROM remain
unchanged after power is turned off and on again.
When power is turned on, the hardware of the computer sets the program counter to the first address of the
bootstrap loader which loads a portion of the OS from disk to main memory and control is then transferred
to the OS, which prepares the computer for general use.
RAM Chips
A RAM chip is better suited to communicate with CPU if it has one or more control inputs that select the chip
only when needed. The block diagram of a RAM chip is shown below:
ROM Chips
Since a ROM chip can only read, data bus is unidirectional (output mode only).
Component column specifies RAM or ROM chip. We use four 128 words
RAM to make 512 byte size.
Hexadecimal address column assigns a range of addresses for each chip.
10 lines in address bus column: lines 1 through 7 for RAM and 1 through 9 for
ROM. Distinction between RAM and ROM chip is made by line 10. When line
10 is 1, it selects ROM and when it is 0, CPU selects RAM.
X’s represents a binary number ranging from all-0’s to all-1’s.
Associative memories are expensive compared to RAMs because of the add logic associated with each cell.
Hardware Organization
Associative memory consists of a memory array and logic for m words and 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 words. Each word in memory is compared in parallel with the content of
the argument register. The words that match the bits of the argument register set a corresponding bit in the
match register. After matching process, those bits in the match register that have been set indicate the fact
that their corresponding words have been matched.
Reading is accomplished by a sequential access to memory for those words whose corresponding bits in the
match register have been set.
The key register provides a mask for choosing a particular field or key in the argument word. The entire
argument is compared with each memory word if the key register contains all 1’s. 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 or identifying piece of information which specifies how the reference to memory is made.
Cache Mapping
The process of transferring the data from main memory to cache is known as mapping process. There are three
types of cache mapping techniques:
Associative mapping
Direct mapping
Set-associative mapping
The main memory can store 32K words of 12 bits each. The cache is capable of storing 512 of these words at
any given time. For every word stored in cache, there is a duplicate copy in main memory. The CPU
communicates with both memories. It first sends a 15-bit address to cache. If there is a hit, the CPU accepts the
12-bit data from cache. If there is a miss, the CPU reads the word from main memory and the word is then
transferred to cache.
is then transferred to the associative cache memory. If the cache is full, an address-data pair must be displaced
to make room for a pair that is needed and not presently in the cache. The decision as to what pair is replaced is
determined from the replacement algorithm that the designer chooses for the cache. A simple procedure is to
replace cells of the cache in round robin order whenever a new word is requested from main memory. This
constitutes a first in first out (FIFO) replacement policy.
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 form the tag field.
The n bit memory address is divided into two fields: k bits for the index field and n-k bits for the tag field.
The direct mapping cache organization uses the n bit address to access the main memory and the k bit index
to access the cache.
Each word in cache consists of the data word and its associated tag. When a new word is first brought into
the cache, the tag bits are stored alongside the data bits. When the CPU generates a memory request, the
index field is used for the address to access the cache.
Set-Associative Mapping
It is an improvement over the direct mapping organization in that each word of cache can store two or more
words of memory under the same index address.
Each data word is stored together with its tag and the number of tag-data items in one word of cache is said
to form a set.
Each index address refers to two data words and their associated tags. Each tag requires six bits and each
data word has 12 bits, so the word length is 2(6 + 12) = 36 bits.
An index address of nine bits can accommodate 512 words. Thus, the size of cache memory is 512*36. It
can accommodate 1024 words of main memory since each word of cache contains two data words.
Example: consider main memory: 32K words (K = 1024) = 2 15 and auxiliary memory 1024K words = 220. Thus
we need 15 bits to address physical memory and 20 bits for virtual memory (virtual memory can be as large as
we have auxiliary storage).
Fig: Relation between address and memory space in a virtual memory system
In virtual memory system, address field of an instruction code has a sufficient number of bits to specify all
virtual addresses. In our example above we have 20-bit address of an instruction (to refer 20-bit virtual address)
but physical memory addresses are specified with 15-bits. So a table is needed to map a virtual address of 20-
bits to a physical address of 15-bits. Mapping is a dynamic operation, which means that every address is
translated immediately as a word is referenced by CPU.
The dynamic storage relocation hardware is a mapping process similar to paging system.
Segment: It is more convenient to divide programs and data into logical parts called segments despite of fixed-
size pages. A segment is a set of logically related instructions or data elements. Segments may be generated by
the programmer or by OS. Examples are: a subroutine, an array of data, a table of symbols or user’s program.
Logical address: The address generated by the segmented program is called a logical address. This is similar to
virtual address except that logical address space is associated with variable-length segments rather than fixed-
length pages.
Segmented-Page Mapping
The length of each segment is allowed to grow and contract according to the needs of the program being
executed. One way of specifying the length of a segment is by associating with it a number of equal-sized
pages.
Consider diagram below:
Logical address = Segment + Page + Word
Where segment specifies segment number, page field specifies page within the segment and word field
specifies specific word within the page.
H\W, See Numerical example to clear the concept of MMU (Computer System Architecture, 3rd edition, page
no. 481, Morris Mano)