Gate
Exam
In a k-way set associative cache, the cache is divided into v sets, each of which
consists of k lines. The lines of a set are placed in sequence one after another.
The lines in set s are sequenced before the lines in set (s+1). The main memory
blocks are numbered 0 onwards. The main memory block numbered j must be
mapped to any one of the cache lines from
(A) (j mod v) *k to (j mod v) *k + (k − 1)
(B) (j mod v) to (j mod v) + (k − 1)
(C) (j mod k) to ( j mod k) + (v − 1)
(D) (j mod k) * v to ( j mod k) * v + (v − 1)
Read Solution (Total 1)
-
- For a K-way set associative cache memory, the mapping function is as follows :
i = j mod v where,
i = is the cache set number to which the memory block j is to be mapped to.
j = memory block number
v = number of the sets in the cache
also total number of lines in the cache is given by K = v * k , where k = is the number of lines per cache set.
Now, as the lines of the set are placed in a sequence one after another and also the lines in set s are sequenced before the lines in set (s+1) the cache memory sets and the corresponding lines look like this (assuming the sets and lines are numbered starting with 0) :
cache set 0 ---- lines 0 to k-1,
cache set 1 ---- lines k to 2k-1,
cache set (v-1) ---- lines ((v-1)*k) to ((v*k) -1) ---------> ( i )
if we substitute j = v-1 in option (A) it becomes : ((v-1) mod v ) *k to ((v-1) mod v ) *k +( k - 1 )
= (v-1)*k to (v-1)*k + ( k-1 )
= (v-1)*k to ( (v*k) - k + k -1)
= (v-1)*k to ((v*k)-1) , which is same as ( i )
hence option A is the correct answer.
- 10 years agoHelpfull: Yes(1) No(0)
Gate Other Question