Unit Iii
Unit Iii
COMPUTER ORGANIZATION
II B.Tech II semester
Unit-III PPT Slides
Text Books: (1) Computer Systems Architecture by M. Morris Mano
INDEX
UNIT-III PPT SLIDES
Sl. No Module as per Session planner Lecture No
2. Main memory L8
3. Auxiliary memory L9
- Word, Block
Access Method
The overall goal of using a memory hierarchy is to obtain the highest-possible average
access speed while minimizing the total cost of the entire memory system.
It is described by 3 characteristics:
-- Access time
-- Capacity
-- Cost
Decoder
3 2 1 0
CS1
CS2
128×8 Data
RD
RAM 1
WR
AD7
CS1
CS2
128×8 Data
RD
RAM 2
WR
AD7
CS1
CS2
128×8 Data
RD
RAM 3
WR
AD7
CS1
CS2
128×8 Data
RD
RAM 4
WR
AD7
CS1
CS2
1-7 128×8 Data
ROM
8
AD9
9
SECONDARY STORAGE
MAGNETIC HARD DISKS
Disk
Disk drive
Disk controller
ORGANIZATION OF DATA ON A DISK
Sector 0, track 1
Sector 3, track n
Sector 0, track 0
OPTICAL
DISKS Pit Land Polycarbonate plastic
(a) Cross-section
Pit Land
Reflection Reflection
No reflection
0 1 0 0 1 0 0 0 0 1 0 0 0 1 0 0 1 0 0 1 0
CD-Recordable (CD-R)
CD-ReWritable (CD-RW)
DVD
DVD-RAM
MAGNETIC TAPE SYSTEMS
File File
mark File
mark
• •
• • 7 or 9
• • bits
• •
When the CPU refers to memory and finds the word in cache, it
produces a hit. If the word is not found in cache, it counts it as
a miss.
The ratio of the number of hits divided by the total CPU
references to memory (hits + misses) is the hit ratio. The hit
ratios of 0.9 and higher have been reported
Cache Memory
A block of words containing the one just accessed is then transferred from
main memory to cache memory.
For example,
A computer with cache access time of 100ns, a main memory access time
of 1000ns and a hit of 0.9 produce an average access time of 200ns. This is
a considerable improvement over a similar computer without a cache
memory, whose access time is 1000ns.
AVERAGE ACCESS TIME FORMULA
In order to find avg memory access time we have the
formula :
Tavg = h*Tc +(1-h)*M
where
h = hit rate
(1-h) = miss rate
Tc = time to access information from cache
M = miss penalty (time to access main memory)
Cache Memory
Associative Mapping
Direct Mapping
Set – Associative Mapping.
Associative Mapping
The associative mapping stores both the address and content (data) of the
memory word.
Octal
Argument register
The 9 least significant bits constitute the index field and the
remaining 6 bits form the tag fields.
The main memory needs an address but includes both the tag and the
index bits.
The cache memory requires the index bits only i.e., 9 bits.
If there are 2k words in the cache memory & 2n words in the main
memory then k-address bits to refer cache and n address bits to refer
main memory are required .
Example:
512 words = 29 words in Cache
32K words = 215 words in Main memory
k = 9, n = 15 bits required to access cache and Min memory respectively
Direct Mapping
Direct Mapping
Direct Mapping
Each index address refers to two data words and their associated tags.
Set – Associative Mapping
• The words stored at addresses 01000 and 02000 of main memory are stored in
cache memory at index address 000.
• Similarly, the words at addresses 02777 and 00777 are stored in cache at index
address 777.
• When the CPU generates a memory request, the index value of the address is
used to access the cache. The tag field of the CPU address is then compared with
both tags in the cache to determine if a match occurs.
• 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.“
• The hit ratio will improve as the set size increases because more words with the
same index but different tags can reside in cache.
• However, an increase in the set size increases the number of bits in words of
cache and requires more complex comparison logic.
• 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).
Set – Associative Mapping
Each tag requires 6 bits & each data word has 12 bits, so the word length is
2(6+12) =36 bits
An index address of 9 bits can accommodate 512 cache words. It can accommodate
1024 memory words.
When the CPU generates a memory request, the index value of the address is used to
access the cache.
The tag field of the CPU address is compared with both tags in the cache.
· Random replacement
· FIFO
· Least Recently Used (LRU)
Writing into cache
An important aspect of cache organization is concerned with memory write requests.
When the CPU finds a word in cache during a read operation, the main memory is not
involved in the transfer.
However, if the operation is a write, there are two writing methods that the
system can proceed.
Write-through method (The simplest & commonly used way)
Update main memory with every memory write operation, with cache memory
being update in parallel if it contains the word at the specified address.
This method has the advantage that main memory always contains the same data as
the cache.
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.
Cache Initialization
• One more aspect of cache organization is the problem of 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 some non-valid data.
• It is customary to include with 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 bits to 0.
• The valid bit of a particular cache word is set to 1 the first time this word is
loaded from main memory and stays set unless the cache has to be initialized
again.
• The introduction of the valid bit means that a word in cache is not replaced
by another word unless the valid bit is set to 1 and a mismatch of tags occurs.
• If the valid bit happens to be 0, the new word automatically replaces the
invalid data.
• Thus the initialization condition has the effect of forcing misses from the
cache until it fills with valid data.
REPLACEMENT ALGORITHMS
CPU A B C A D E A D C F
Reference
Miss Miss Miss Hit Miss Miss Miss Hit Hit Miss
Cache A A A A A E E E E E
FIFO B B B B B A A A A
C C C C C C C F
D D D D D D
42 /
19