MASTER OF COMPUTER APPLICATIONS
Course Code : MCS-012
Course Title : Computer Organisation and Assembly Language Programming
Assignment Number : MCA(I)/012/Assignment/15-16
Maximum Marks : 100
Weightage : 25%
A computer has 1MB RAM and has word size of 16 bits. It has cache memory having 16 blocks with a block size of 32 bits. Explain how a main memory address will be mapped to a cache address, if
(i) Direct cache mapping is used
(ii) Associative cache mapping is used
(iii) Two way set associative mapping scheme is used.
Given:
Main memory Size = 1 MB (RAM)
Convert it to Words if word size is 16 bits
Main memory Size = 65536 Words
Main Memory word size = 16 bits
Cache Memory Size = 16 Blocks
Cache Memory Block size = 32 bits
⇒1 Block of Cache = 2 Words of RAM
⇒Assume Memory location address 520 is equivalent to Block address 260.
⇒ Total number of possible Blocks in Main Memory = 65536 /2 = 32768 blocks
Associative Mapping:
The block can be anywhere in the cache.
Direct Mapping:
Size of Cache = 16 blocks
Location of Block 260 in Cache = 260 modulo 16 = 4
2 Way set associative mapping:
Number of blocks in a set = 2
Number of sets = Size of Cache in blocks / Number of blocks in a set
= 32768 / 2 = 16384
Block 260 will be located anywhere in (260 modulo 8) set, that is set 4.