Chapter 7
Chapter 7
architecture
Chapter 7:
memory organization
Outlines
2
Characteristics of Memory Systems
Memory unit is used for storage, and retrieval of data and instructions.
A typical computer system is equipped with a hierarchy of memory subsystems, some internal to
the system and some external.
Internal memory systems are accessible by the CPU directly and external memory systems are
accessible by the CPU through an I/O module.
Memory systems are classified according to their key characteristics. The most important are
listed below:
Location
The classification of memory is done according to the location of the memory as:
Registers: The CPU requires its own local memory in the form of registers.
Internal (main): is often equated with the main memory (RAM)
External (secondary): consists of peripheral storage devices like Hard disks, magnetic tapes, etc.
3
Unit of Transfer
Word: For internal memory, unit of transfer is equal to the number of data lines into and out of the
memory module.
Block: For external memory, data are often transferred in much larger units than a word, and these
are referred to as blocks.
Access Method
Sequential: Tape units have sequential access.
Data is accessed sequentially; the records may be passed (or rejected) until the record that is
searched is found.
Random: Each addressable location in memory has a unique addressing mechanism.
Any location can be selected at random and directly addressed and accessed. Main memory and
cache systems are random access.
Physical Characteristics
Volatile/nonvolatile: In a volatile memory, information decays naturally or is lost when electrical
power is switched off.
Erasable/non-erasable: Nonerasable memory cannot be altered (except by destroying the storage
unit). ROM’s are non-erasable.
4
Memory Hierarchy
Memory is used for storing programs and data that are required to perform a
specific task.
For CPU to operate at its maximum speed, it required an uninterrupted and high
speed access to these memories that contain programs and data.
Some of the criteria need to be taken into consideration while deciding which
memory is to be used:
Cost
Speed
Memory access time
Data transfer rate
Reliability
Figure below shows the hierarchy of memory in a typical memory with a trend in
access time, amount of storage, and cost per byte.
5
Memory Hierarchy
Memory Hierarchy is to obtain the highest possible access speed while minimizing
the total cost of the memory system
Auxiliary memory
Magnetic
tapes I/O Main
processor memory
Magnetic
disks
CPU Cache
memory
Magnetic Tape
6
Memory Hierarchy cont...d
7
Main Memory
Due to its direct connection with the CPU, it is also known as central memory.
The main memory holds the data and the programs that are needed by the CPU.
The main memory mainly consists of RAM, which is available in static and
dynamic mode.
Large memory
Made up of Integrated chips
Types:
1. RAM (Random access memory)
2. ROM (Read only memory)
8
RAM (Random Access Memory)
Random access memory (RAM) is the best known form of computer memory.
RAM is considered "random access" because you can access any memory cell
directly if you know the row and column that intersect at that cell.
Types of RAM:-
1. Static RAM (SRAM)
a bit of data is stored using the state of a flip-flop.
Retains value indefinitely, as long as it is kept powered.
Mostly uses to create cache memory of CPU.
Faster and more expensive than DRAM.
2. Dynamic RAM (DRAM)
Each cell stores bit with a capacitor and transistor.
Large storage capacity
Needs to be refreshed frequently.
Used to create main memory.
Slower and cheaper than SRAM.
9
ROM
ROM is used for storing programs that are Permanently resident in the computer and for
tables of constants that do not change in value once the production of the computer is
completed
The ROM portion of main memory is needed for storing an initial program called bootstrap
loader,
Bootstrap Loader:- A program whose function is to start the computer software operating
when power is turned on.
There are five basic ROM types:
ROM - Read Only Memory
PROM - Programmable Read Only Memory
EPROM - Erasable Programmable Read Only Memory
EEPROM - Electrically Erasable Programmable Read Only Memory
10
RAM and ROM Chips
A RAM chip is better suited for communication with the CPU if it has one or more
control inputs that select the chip when needed
The Block diagram of a RAM and ROM chip is shown figure below, the capacity of the
memory is 128 words of 8 bits (one byte) and 512 words of 8 bits per word respectively.
12
Memory connection to the CPU
Memory Configuration : 512 bytes RAM + Address bus CPU
512 bytes ROM 16-11 10 9 8 7-1 RD WR Data bus
• 1 x 512 byte ROM + 4 x 128 bytes RAM
• Memory Address Map : Decoder
• Address line 9 8 3 2 1 0
CS1
• RAM 1 0 0 : 0000 - 007F CS2
Data
128 x 8
• RAM 2 0 1 : 0080 - 00FF RD
WR
RAM 1
• RAM 3 1 0 : 0100 - 017F AD7
• RAM 4 1 1 : 0180 - 01FF CS1
• Address line 10 CS2
Data
RD 128 x 8
• ROM 1 : 0200 - 03FF WR
RAM 2
Data
RD 128 x 8
RAM 3
• RAM select : CS2 WR
AD7
• ROM select : CS2 의 Invert
CS1
CS2
Data
RD 128 x 8
RAM 4
WR
AD7
CS1
CS2
Data
1- 7 512 x 8
8
9 } AD9 ROM
13
Cache memory
If the active portions 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 cache memory
The cache is the fastest component in the memory hierarchy and approaches the speed of
CPU component
When 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
Hit Ratio :-the ratio of the number of hits divided by the total CPU references (hits + misses)
to memory
hit : the CPU finds the word in the cache
miss : the word is not found in cache (CPU must read main memory)
14
Structure of Cache and Main Memory
Slot number Memory address
Tag Block
0 0
1 1
2 Block
. 3
(K words)
.
C-1 . .
Block length
(K words) .
(a) Cache
.
Block
2n-1
Word
length
Figure: The structure of the cache
and main memory (b) Main memory
15
mapping process
The transformation of data from main memory to cache memory is referred to as a
mapping process,
The basic characteristic of cache memory is its fast access time
Therefore, very little or no time must be wasted when searching the words in the cache
there are three types of mapping:
1. Associative mapping
2. Direct mapping
3. Set-associative mapping
To understand the mapping procedure, we have the following example:
16
Replacement Algorithms of Cache Memory
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:
1. random replacement:- With the random replacement policy the control chooses one tag-
data item for replacement at random.
2. first-in, first out (FIFO):- procedure selects for replacement the item that has been in the
set the longest.
3. least recently used (LRU): The LRU algorithm selects for replacement the item that has
been least recently used by the CPU.
Both FIFO and LRU can be implemented by adding a few extra bits in each word of cache.
17
Auxiliary memory
Devices that provide backup storage are called auxiliary memory.
They are used for storing system programs, large data files, and other backup
information.
The transfer rate is the number of characters or words that the device can transfer per
second, after it has been positioned at the beginning of the record.
• Magnetic Disk
A disk is a circular platter constructed of metal or of plastic coated with a
magnetic material.
Data are recorded on and later retrieved from the disk via a conducting coil
named the head.
During a read or write operation, the head is stationary while the platter rotates
beneath it.
Writing is achieved by producing a magnetic field which records a magnetic
pattern on the magnetic surface.
18
Data Organization and Formatting of Magnetic
disk
Figure below depicts the data layout of a disk.
The head is capable of reading or writing from a portion of the platter rotating beneath it.
This gives rise to organization of data on the platter in a concentric set of rings called
Tracks.
Each track is the same width as the head. Adjacent tracks are separated by gaps that
minimize errors due to misalignment of head.
Data is transferred to and from the disk in blocks. And the block is smaller than the
capacity of a track.
Data is stored in block regions which is an angular part of a track and is referred to as a
sector.
Typically 10-100 sectors are there per track. These may be either of fixed or variable
length.
19
Figure : Disk data layout
o Optical Memory & Magnetic Tape are other two external memories. 20
physical address vs logical address
Address uniquely identifies a location in the memory.
two types of addresses that are logical address and physical address.
The logical address is a virtual address and can be viewed by the user.
The user can’t view the physical address directly.
The logical address is used like a reference, to access the physical address.
The fundamental difference between logical and physical address is that
logical address is generated by CPU during a program execution whereas,
21
Virtual memory
It is a memory management technique that provides an "idealized abstraction of the storage
resources that are actually available on a given machine" which "creates the illusion to users of a
very large memory."
22
23
24
thank you!!!!!!!
25