Documente Academic
Documente Profesional
Documente Cultură
CC2202 1
Last Week
• We learnt
—Combinational Circuit
—Truth Table and K-Map
CC2202 2
Characteristics of Memory System
CC2202 3
Characteristics
• Location
—CPU
– Registers
—Internal
– RAM
—External
– Storage Disk / Tape
• Capacity
—Word size
– The natural unit of organization
—Number of words
– or Bytes
CC2202 4
Characteristics I
• Unit of Transfer
—Internal
– Usually governed by data bus width
—External
– Usually a block which is much larger than a word
—Addressable unit
– Smallest location which can be uniquely addressed
– Word internally
CC2202 5
Characteristics II
• Access Methods
— Sequential
– Start at the beginning and read through in order
– Access time depends on location of data and previous location
– e.g. tape
— Direct
– Individual blocks have unique address
– Access is by jumping to vicinity plus sequential search
– Access time depends on location and previous location
– e.g. disk
— Random
– Individual addresses identify locations exactly
– Access time is independent of location or previous access
– e.g. RAM
— Associative
– Data is located by a comparison with contents of a portion of the
store
– Access time is constant independent of location or previous access
– e.g. cache
CC2202 6
Memory Hierarchy
CC2202 7
Memory Hierarchy - Diagram
Optical disc
• Compact Disk Read-Only Memory (CD-ROM)
— uses laser technology to store data,
instructions and information
• Compact Disk Rewriteable (CD-RW)
— Erasable CD onto which users can write and
rewrite data, instructions and information
multiple times.
• Digital Video Disc Rewriteable (DVD+RW)
— can be erased and written to, or recorded
on, more than 1000 times.
• DVD Random Access Memory (DVD-RAM)
— can be erased and written to, or recorded on,
more than 100,000 times. DVD-RAM discs
can be read by DVD-RAM drives and some
DVD-ROM players
• Magneto Optical disk
— Size of a floppy disk capable of writing and rewriting data upon
• WORM (Write Once Read Many or Write Once Read Multiple times)
— Mostly used in software, manual or document given out by manufacturers since
can be written to only once, but readCC2202
from multiple times. 8
Performance
CC2202 9
Performance
1 1
R= =
CT TA + TR
CC2202 10
Characteristics III
• Physical Types
—Semiconductor
– RAM
—Magnetic
– Disk & Tape
—Optical
– CD & DVD
• Physical Characteristics
—Decay
—Volatility
—Erasable
—Power consumption
CC2202 11
Design Constraints
CC2202 12
Trend in the Memory Hierarchy
CC2202 13
Cache Memory Principles
CC2202 14
Cache operation - overview
CC2202 15
Cache/main-memory Structure
CC2202 16
Cache/main-memory Structure
CC2202 17
Cache Design
• Size
— Size does matter
— Cost
– More cache is expensive
— Speed
– More cache is faster (up to a point)
– Checking cache for data takes time
• Mapping Function- Algorithm is needed to map main
memory blocks to cache lines. Three techniques:
— direct,
— associative and
— set associative.
• Replacement Algorithm
— Once the cache is filled, when a new main memory block is brought
into the cache, one of the existing blocks in cache must be replaced.
– Least Recently Used (LRU),
– First-in First-out (FIFO),
– Least Frequently Used (LFU) or
– Random algorithm is used.
CC2202 18
Cache Design
• Block Size
• Number of Caches
CC2202 19
Mapping Function
CC2202 20
Direct Mapping
CC2202 22
Direct Mapping
Cache Line Table
CC2202 23
Direct Mapping Cache Organization
CC2202 24
Direct Mapping Example
16 Kline Cache
CC2202 25
Direct Mapping Summary
CC2202 26
Direct Mapping pros & cons
• Pros
—Simple
—Inexpensive
• Cons
—Fixed location for given block
– If a program accesses 2 blocks that map to the same line
repeatedly, cache misses are very high
CC2202 27
Associative Mapping
CC2202 28
Fully Associative Cache Organization
CC2202 29
Associative Mapping Example
16 Kline Cache
CC2202 30
Associative Mapping Address Structure
Word
Tag 22 bits 2 bits
CC2202 32
Associative Mapping Summary
• Pros
—Flexible – When a new block is read into the cache,
any block in cache can be replaced.
—Maximize hit ratio when appropriate replacement
algorithm is used.
• Cons
—Requires complex circuitry to examine the tags of all
cache lines in parallel.
CC2202 34
Set Associative Mapping
CC2202 35
Set Associative Mapping
Example
CC2202 36
Two Way Set Associative Cache Organization
CC2202 37
Set Associative Mapping Address Structure
Word
Tag 9 bits Set 13 bits 2 bits
CC2202 38
• e.g
—Address Set+Word Tag Data Set
—FFFFFC 7FFC 1FF 24682468 1FFF
CC2202 39
Two Way Set Associative Mapping Example
02C
CC2202 40
Set Associative Mapping Summary
CC2202 41
Replacement Algorithms
• Direct mapping
—No choice
—Each block only maps to one line
—Replace that line
• Associative & Set Associative
—Hardware implemented algorithm (speed)
—Least Recently used (LRU)
– e.g. in 2 way set associative
—First in first out (FIFO)
– replace block that has been in cache longest
—Least frequently used
– replace block which has had fewest hits
—Random
CC2202 42