You are on page 1of 24

DEPARTMENT OF TECHNICAL EDUCATION

ANDHRA PRADESH
Name : U.Rajya Lakshmi
Designation : Lecturer
Branch : Computer Engg.,
Institute : Govt.Polytechnic for Women,
PALAMANER.
Year/Semester : III Semester
Subject : Computer Architecture
Subject Code : CM-303
Topic : Memory Organization
Duration : 50 Min
Sub Topic : Direct mapping of Cache Memory
Teaching aids : PPT,drawings
CM303.48 1
Do you Know

• What are the advantages of cache memory?

• What are the different mapping methods of


cache?

CM303.48 2
Recap of previous lesson

• Cache memory is a small and fast memory


• Located in between CPU and Main memory
• Various mapping methods
• Associative mapping
• Direct mapping
• Set associative mapping

• Associative mapping cache stores both the data


and address of a memory word
CM303.48 3
Objectives

On completion of this period you would be able to


know

• The direct mapping method of cache memory

CM303.48 4
Disadvantages of associative mapping
Contd.,
• Expensive

• Complicated because complex logical circuits are


required to implement

• Due to high cost of logic circuits other methods are


used like direct and set-associative mappings

CM303.48 5
Direct Mapping
Contd.,

• Stores the word as well as its tag field in cache

• Address sent by the CPU is divided in to two


fields
– Tag field
and
– index field

CM303.48 6
Direct Mapping
Contd.,

• In general main memory capacity is 2m and cache


capacity is 2n

• The m bit address is divided in to n-bit index and (m-n)


bit tag field as shown in fig.1

m-n bits n bits

tag index

m bits
Fig.1

CM303.48 7
Direct Mapping
Contd.,

• Uses m-bit address to access main memory


and

• Uses n-bit address to access cache memory

• Internal organization of cache in direct


mapping method is shown in fig.2

CM303.48 8
Organization Of Cache Memory In Direct
Mapping
Index
Tag data
address
000
001
002
003
004

2n-2
2n-1
Cache memory
Fig.2
CM303.48 9
Operation of Direct Mapping organization
Contd.,

• when m bit address is sent by the CPU,


– index part (n bits) is used to search cache

– Tag field of the address is compared with the


tag in the word read from the cache

– If two tags match , there is a hit

CM303.48 10
Operation of Direct Mapping organization
Contd.,

– If tags are not matched, there is a miss and


the required word is read from main memory

– stores the required word along with its tag,


replacing the previous value

CM303.48 11
Example of Direct Mapping organization
Contd.,

Consider a computer system with


main memory capacity = 32 KB
Cache memory capacity = 512 B
6 bits 9 bits
tag index

00000
Octal address

Main memory 000 Cache memory


32 KB 512 B
Address=15 bits Address=9 bits
Data=12 bits Data=12 bits
777
77777
Fig.3
CM303.48 12
Example of Direct Mapping organization
Contd.,
Address Main memory Cache memory
00000 0240 index 000 00 0240
00001 1001 001 00 1001
00002 1232 002 00
00003 7603 003 00 1232
00004 3454 004 00 7603

3454
02004 1543
777 02
02776 0276
2701
02777 2701

Fig.4
CM303.48 13
Example of Direct Mapping organization

• If CPU wants to access the word at 02004


– index part (9 bits) is 004 used to search cache
– Then two tags are compared
– The cache tag is 00 but address tag is 02
– Tags are not matched, word is accessed from
main memory
– The cache word at index 004 is then replaced
with a tag of 02 and data of 1543

CM303.48 14
Disadvantage of Direct Mapping organization

• Two words with same index but with different


tags cannot be stored in cache at the same time

• Only one tag-data pair can be stored, which


reduces hit ratio

CM303.48 15
Summary

• In this class you have studied


• Disadvantages of associative Cache organization
• Complex logic is required
• expensive
• Direct mapping
• Stores word along with its tag
• Simple to implement
• Disadvantage
– two words with different tags cannot be stored at
a time
CM303.48 16
QUIZ

CM303.48 17
1. Disadvantage of Associative mapping process

• Not flexible
• Complex logic
• Locality of reference

CM303.48 18
1. Disadvantage of Associative mapping process

• Not flexible
• Complex logic
• Locality of reference

CM303.48 19
2. The two parts of CPU generated address in
direct mapping of cache
a) Tag and data
b) Data and logic
c) Index and data
d) Tag and index

CM303.48 20
2. The two parts of CPU generated address in
direct mapping of cache
• Tag and data
• Data and logic
• Index and data
• Tag and index

CM303.48 21
Frequently asked Questions

1. Explain the direct mapping of cache memory


organization with the help of an example

CM303.48 22
Short Answer Questions

1. Write the advantages of cache memory


2. List the various mapping methods of cache
memory

CM303.48 23
Assignment Questions

1. A computer has a memory unit 64K X 16 and


a cache of 1K memory words. The cache
uses direct mapping with a block size of four
words.
a) how many bits are there in the tag,index
fields?

CM303.48 24

You might also like