Professional Documents
Culture Documents
Faculty: T Gopalakrishnan
A block-set associative cache memory consists of 128 blocks divided into four block sets
The main memory consists of 16,384 blocks and each block contains 256 eight bit
words.
a. How many bits are required for addressing the main memory?
b. How many bits are needed to represent the TAG, SET and WORD fields?
Solution-
Given-
Number of blocks in cache memory = 128
Number of blocks in each set of cache = 4
Main memory size = 16384 blocks
Block size = 256 bytes
1 word = 8 bits = 1 byte
Main Memory Size-
We have-
Size of main memory
= 16384 blocks
= 16384 x 256 bytes
= 222 bytes
Thus, Number of bits required to address main memory = 22 bits
We have-
Block size
= 256 bytes
= 28 bytes
Thus, Number of bits in block offset or word = 8 bits
A computer has a 256 KB, 4-way set associative, write back data cache with block size
of 32 bytes. The processor sends 32 bit addresses to the cache controller. Each cache
tag directory entry contains in addition to address tag, 2 valid bits, 1 modified bit and 1
replacement bit.
a. 11
b. 14
c. 16
d. 27
b) Select The size of the cache tag directory is-
a. 160 Kbits
b. 136 Kbits
c. 40 Kbits
d. 32 Kbits
Solution-
Given-
Cache memory size = 256 KB
Set size = 4 blocks
Block size = 32 bytes
Number of bits in physical address = 32 bits
We have-
Block size
= 32 bytes
= 25 bytes
Thus, Number of bits in block offset = 5 bits
Thus,
For part-01, Option (C) is correct.
For part-02, Option (A) is correct.
Question No 5:
Consider a fully associative mapped cache of size 16 KB with block size 256 bytes. The
size of main memory is 128 KB. Find-
a. Number of bits in tag
b. Tag directory size
Solution-
Given-
Cache memory size = 16 KB
Block size = Frame size = Line size = 256 bytes
Main memory size = 128 KB
We consider that the memory is byte addressable.
Number of Bits in Physical Address-
We have,
Size of main memory
= 128 KB
= 217 bytes
Thus, Number of bits in physical address = 17 bits
We have,
Block size
= 256 bytes
= 28 bytes
Thus, Number of bits in block offset = 8 bits
We have,
Block size
= 256 bytes
= 28 bytes
Thus, Number of bits in block offset = 8 bits
Number of Bits in Tag-
Question No :6
Consider a 2-way set associative mapped cache of size 16 KB with block size 256 bytes.
The size of main memory is 128 KB. Find-
1. Number of bits in tag
2. Tag directory size
Solution-
Given-
Set size = 2
Cache memory size = 16 KB
Block size = Frame size = Line size = 256 bytes
Main memory size = 128 KB
We have,
Size of main memory
= 128 KB
= 217 bytes
Thus, Number of bits in physical address = 17 bits
We have,
Block size
= 256 bytes
= 28 bytes
Thus, Number of bits in block offset = 8 bits
Number of Lines in Cache-
Question No :7
Consider a 4-way set associative mapped cache with block size 4 KB. The size of main
memory is 16 GB and there are 10 bits in the tag. Find-
1. Size of cache memory
2. Tag directory size
Solution-
Given-
Set size = 4
Block size = Frame size = Line size = 4 KB
Main memory size = 16 GB
Number of bits in tag = 10 bits
We have,
Size of main memory
= 16 GB
= 234 bytes
Thus, Number of bits in physical address = 34 bits
We have,
Block size
= 4 KB
= 212 bytes
Thus, Number of bits in block offset = 12 bits
We have-
Number of bits in set number = 12 bits
Thus, Total number of sets in cache = 212 sets
We have-
Total number of sets in cache = 212 sets
Each set contains 4 lines
Thus,
Total number of lines in cache
= Total number of sets in cache x Number of lines in each set
= 212 x 4 lines
= 214 lines
Question No :8
Assume a byte-addressable main memory consists of 2^14 bytes, cache has 16 blocks, and each
block has 8 bytes.
Question No:9:
Question No 10:
Question No :11
Question No :12
A set-associative cache consists of 64 lines, or slots, divided into four-line sets. Main memory
contains 4K blocks of 128 words each. Show the format of main memory addresses
Question No :13
A two-way set-associative cache has lines of 16 bytes and a total size of 8 kbytes. The 64-Mbyte
main memory is byte addressable. Show the format of main memory addresses.
Solution
Question No :14
Consider a 4-way set associative mapping with 16 cache blocks. The memory block
requests are in the order-
0, 255, 1, 4, 3, 8, 133, 159, 216, 129, 63, 8, 48, 32, 73, 92, 155
If LRU replacement policy is used, which cache block will not be present in the cache?
1. 3
2. 8
3. 129
4. 216
Also, calculate the hit ratio and miss ratio.
Solution-
We have,
There are 16 blocks in cache memory numbered from 0 to 15.
Each set contains 4 cache lines.
In set associative mapping, a particular block of main memory is mapped to a
particular set of cache memory.
The set number is given by-
Cache line number = Block address modulo Number of sets in cache
For the given sequence-
Requests for memory blocks are generated one by one.
The set number of the block is calculated using the above relation.
Within that set, the block is placed in any freely available cache line.
If all the blocks are already occupied, then one of the block is replaced in accordance
with the employed replacement policy.
Thus,
Out of given options, only block-216 is not present in the main memory.
Option-(D) is correct.
Hit ratio = 1 / 17
Miss ratio = 16 / 17
Question 15:
Consider a machine with a byte addressable main memory of 216 bytes and block size of 8 bytes.
Assume that a direct mapped cache consisting of 32 lines is used with this machine.
a. How is a 16-bit memory address divided into tag, line number, and byte number
b. b. Into what line would bytes with each of the f
0001 0001 0001 1011
1100 0011 0011 0100
1101 0000 0001 1101
1010 1010 1010 1010
Solution a:
Solution b:
Line 3.
Line 6.
Line 3.
Line 21.
Question 16:
Consider a memory system that uses a 32-bit address to address at the byte level, plus a cache
that uses a 64-byte line size.
a. Assume a direct mapped cache with a tag field in the address of 20 bits. Show the address
format and determine the following parameters: number of addressable units, number of blocks
in main memory, number of
b. Assume an associative cache. Show the address format and determine the following
parameters: number of addressable units, number of blocks in main memory, number of lines in
cache, size of tag.
c. Assume a four-way set-associative cache with a tag field in the address of 9 bits. Show the
address format and determine the following parameters: number of addressable units,
number of blocks in main memory, number of lines in set, number of sets in cache, number of
lines in cache, size of tag.
Solution :
Question No 17:
Consider a computer with the following characteristics: total of 1Mbyte of main memory; word
size of 1 byte; block size of 16 bytes; and cache size of 64 Kbytes.
a. For the main memory addresses of F0010, 01234, and CABBE, give the corresponding tag,
cache line address, and word offsets for a directmapped cache.
b. Give any two main memory addresses with different tags that map to the same cache slot for
a direct-mapped cache.
c. For the main memory addresses of F0010 and CABBE, give the corresponding tag and offset
values for a fully-associative cache.
d. For the main memory addresses of F0010 and CABBE, give the corresponding tag, cache set,
and offset values for a two-way set-associative cache.
Solution a:
Solution b:
Solution C:
Solution d:
Cache Performance based problems
Question No 1:
A computer system has a MM access time of 200 ns supported by a cache having a 10 ns
access time and a hit rate of 99%.
Solution :
Suppose access to cache and main memory occurs concurrently. (The accesses overlap.)
Question No 2:
Suppose a single cache fronting a main memory, which has 80 nanosecond access time.
Note that with these hit rates, only 0.1 · 0.01 = 0.001 = 0.1% of the memory references are
handled by the much slower main memory