GATE / CS ARCHIVE

GATE CSE 2013 / QUESTION 20

Set-associative cache line range

Computer Organization & Architecture · Cache Memory · Full GATE CSE 2013 paper

GATE 2013, Q20 1 mark · MCQ
Report issue

Cache Memory

Question 20, GATE 2013: A cache has v sets of k consecutive lines each, sets numbered from 0 in order. Memory block j maps to which line interval? A(j mod v)k through(j mod v)k+k−1; B(j mod v) through(j mod v)+k−1; C(j mod k) through(j mod k)+v−1; D(j mod k)v through(j mod k)v+v−1.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Block j maps to set s=j mod v. Each earlier set occupies k consecutive lines, so this set starts at sk and ends at sk+k−1. Substituting s gives the interval in A.

First choose the set, not a particular way: s=j mod v. There are s earlier sets, each occupying k line positions, so the first line of set s is sk. The k allowed ways occupy offsets 0 through k−1, hence last line sk+k−1. For example, v=4, k=2, j=6 gives s=2 and lines 4, 5. This example also shows why omitting the factor k, as in B, gives the wrong physical positions.

Original paper, page 5 · Answer key