Professional Documents
Culture Documents
Computer Architecture - II
Memory Organization
Memory Hierarchy
In a computer system memory unit is the storage
place used to store programs and data on a
temporary or permanent basis.
Typically the memory technologies can categorized in
to three groups
semiconductor memory devices
Registers, SRAM, DRAM, FLASH
which operates on solid state principles making them faster.
magnetic memory devices
HDD and FDD
optical memory devices
CD and DVDs are optical memory devices
Memory Hierarchy
I/O
Processor
Book Library
customer Librarian
Hypothetical Library
Imagine a library
There is a librarian who is responsible of lending and
returning books and a store room, where the books are
kept.
When a customer arrives and ask for a book the
librarian goes to the store room, find the book, come
back and give the book to the customer.
When the customer returns the book, the librarian go
to the store room, place the book there and return to
the counter waiting for another customer.
The librarian has to do the same complete cycle for
each book, even for a popular ones that are requested
frequently.
Hypothetical Library
Suppose library get upgraded and the librarian got a
'cache', a small bookshelf behind his counter which can
store 20 books.
A new day starts and the small bookshelf is empty.
The first customer come and ask for the book ABC'.
The librarian go the store room, find the book and give
it to the customer.
When customer returns the book, instead of going the
round trip to the store room, the librarian put it in the
small bookshelf.
Hypothetical Library
Cache miss
- b is not in cache, so cache 12 Request
12
must fetch it from memory.
(e.g., block 12)
- If level cache is full, then some
current block (a victim) must 0 1 2 3
be replaced (evicted). 4 5 6 7
memory
8 9 10 11
12 13 14 15
18
Cache Operation
1. Direct mapping
2. Associative mapping
3. Set-associative mapping
without a cache memory
Memory locations (words)
5 4 3
CPU Block 0
2 1 0
Block 1
d bits memory register
d bits
Block 3
i.e. in here,
Block number=4
Memory locations=6
without a cache memory
Memory locations (words)
CPU
Block 0
For example if the CPU has 5 bit memory register, it can call 25
memory addresses from main memory.
If the main memory has a block size of23, then there will be 22 blocks.
Suppose the CPU address the memory location 11011 then that
memory location is 011 (3rd location) in 01 (or in block 1).
with cache memory
CPU
Main Memory
Block 0
d bits memory register
Cache Memory
Block 1
Block 0
Block 2
Block 1
Block 3
???
Direct mapping Main Memory
Block 0
Block .
Block 1 Block 31
Direct mapping Main Memory
0%2=0
1%2=1
CPU Block 0
2%2=0
3%2=1
Block 1
31%2=1
d bits memory register
Block 2
Cache Memory
Block 0 Block 3
Block 1 Block .
Block 31
Direct mapping
0%2=0
1%2=1
2%2=0
3%2=1
31%2=1
Cache Memory
Then it compare each tag field stored in that set with the
tag field of the memory address.
If there is a match then its a hit and the word is read from
cache.
Set-Associative mapping
Otherwise the CPU goes to the main memory, using the
memory address and read the required word and then that
word transfer to the corresponding SET of the cache and
store that block together with the tag.
Table Presence
address bit
000 0 Main memory
001 11 1 Block 0
010 00 1 Block 1
011 10 01 0101010011 Block 2
100 0 Main memory Block 3
101 01 1 address register
110 10 1
MBR
111 10
01 1