How Main Memory Is Useful in Computer System? Explain The Memory Address Map of RAM and ROM
How Main Memory Is Useful in Computer System? Explain The Memory Address Map of RAM and ROM
How Main Memory Is Useful in Computer System? Explain The Memory Address Map of RAM and ROM
Main Memory
The main memory is the central storage unit in a computer system.
Primary memory holds only those data and instructions on which computer is currently
working.
It has limited capacity and data is lost when power is switched off.
It is generally made up of semiconductor device.
These memories are not as fast as registers.
The data and instruction required to be processed reside in main memory.
It is divided into two subcategories RAM and ROM.
The designer of a computer system must calculate the amount of memory required for
the particular application and assign it to either RAM or ROM.
The interconnection between memory and processor is then established from
knowledge of the size of memory needed and the type of RAM and ROM chips available.
The addressing of memory can be established by means of a table that specifies the
memory address assigned to each chip.
The table, called a memory address map, is a pictorial representation of assigned
address space for each chip in the system, shown in table 9.1.
To demonstrate with a particular example, assume that a computer system needs 512
bytes of RAM and 512 bytes of ROM.
The RAM and ROM chips to be used are specified in figure 9.1 and figure 9.2.
Hardware Organization
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 st 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.
To illustrate with a numerical example, suppose that the argument register A and the key
register K have the bit configuration shown below.
Only the three leftmost bits of A are compared with memory words because K has 1's in
these position.
A 101 111100
K 111 000000
Word1 100 111100 no match
Word2 101 000001 match
Word 2 matches the unmasked argument field because the three leftmost bits of the
argument and the word are equal.
The number of bits in the index field is equal to the number of address bits required to
access the cache memory.
The internal organization of the words in the cache memory is as shown in figure 9.7.
Suppose that the CPU now wants to access the word at address 02000.
The index address is 000, so it is used to access the cache. The two tags are then
compared.
The cache tag is 00 but the address tag is 02, which does not produce a match.
Therefore, the main memory is accessed and the data word 5670 is transferred to the
CPU.
The cache word at index address 000 is then replaced with a tag of 02 and data of 5670.
The disadvantage of direct mapping is that two words with the same index in their
address but with different tag values cannot reside in cache memory at the same time.
The comparison logic is done by an associative search of the tags in the set similar to an
associative memory search: thus the name "set-associative”.
When a miss occurs in a set-associative cache and the set is full, it is necessary to replace
one of the tag-data items with a new value.
The most common replacement algorithms used are: random replacement, first-in first-
out (FIFO), and least recently used (LRU).
Write-Back (Copy-Back)
The second procedure is called the write-back method.
In this method only the cache location is updated during a write operation.
The location is then marked by a flag so that later when the word is removed from the
cache it is copied into main memory.
The reason for the write-back method is that during the time a word resides in the
cache, it may be updated several times.
However, as long as the word remains in the cache, it does not matter whether the copy
in main memory is out of date, since requests from the word are filled from the cache.
It is only when the word is displaced from the cache that an accurate copy need be
rewritten into main memory.
Virtual Memory
Virtual memory is used to give programmers the illusion that they have a very large
memory at their disposal, even though the computer actually has a relatively small main
memory.
A virtual memory system provides a mechanism for translating program-generated
addresses into correct main memory locations.
Swati Sharma , CE Department | 2140707 – Computer Organization 8
Unit 9 – Memory Organization
Address space
An address used by a programmer will be called a virtual address, and the set of such addresses
is known as address space.
Memory space
An address in main memory is called a location or physical address. The set of such locations is
called the memory space.
Auxiliary Memory Main Memory 32k=215
Program 1
Data 1,1
Data 1,2 Program 1
Program 2
Data 2,1
Data 1,1
Address space 1024k=210
Figure 9.9: Relation between address and memory space in a virtual memory system
As an illustration, consider a computer with a main-memory capacity of 32K words (K =
1024). Fifteen bits are needed to specify a physical address in memory since 32K = 215.
Suppose that the computer has available auxiliary memory for storing 220 = 1024K
words.
Thus auxiliary memory has a capacity for storing information equivalent to the capacity
of 32 main memories.
Denoting the address space by N and the memory space by M, we then have for this
example N = 1024K and M = 32K.
In a multiprogramming computer system, programs and data are transferred to and
from auxiliary memory and main memory based on demands imposed by the CPU.
Suppose that program 1 is currently being executed in the CPU. Program 1 and a portion
of its associated data are moved from auxiliary memory into main memory as shown in
figure 9.9.
Portions of programs and data need not be in contiguous locations in memory since
information is being moved in and out, and empty spaces may be available in scattered
locations in memory.
In our example, the address field of an instruction code will consist of 20 bits but physical
memory addresses must be specified with only 15 bits.
Thus CPU will reference instructions and data with a 20-bit address, but the information
at this address must be taken from physical memory because access to auxiliary storage
for individual words will be too long.
Figure 9.10 Address and Memory space split into group of 1K words
The page field specifies the page within the segment and word field gives specific word
within the page.
A page field of k bits can specify up to 2k pages.
A segment number may be associated with just one page or with as many as 2k pages.
Thus the length of a segment would vary according to the number of pages that are
assigned to it.
The mapping of the logical address into a physical address is done by means of two
tables, as shown in figure 9.12.
The segment number of the logical address specifies the address for the segment table.
The entry in the segment table is a pointer address for a page table base.
The page table base is added to the page number given in the logical address.
The sum produces a pointer address to an entry in the page table.
The concatenation of the block field with the word field produces the final physical
mapped address.
The two mapping tables may be stored in two separate small memories or in main
memory.
In either case, memory reference from the CPU will require three accesses to memory:
one from the segment table, one from the page table and the third from main memory.
This would slow the system significantly when compared to a conventional system that
requires only one reference to memory.