4-Cache Key Formula One Pager
4-Cache Key Formula One Pager
a) # of Byte Select bits (or also called # of Byte Offset bits) = log2M,
where M is the number of Bytes per cache line (or cache sets).
The Byte Select bits (or Byte Offset bits) are the least significant log2M address bits.
N = # of cache sets (or total # of cache lines) = cache capacity/cache line capacity
c) # of Tag bits = total Memory Address bits – # of Index bits - # of Byte Select bits
a) # of Byte Select bits (or also called # of Byte Offset bits) = log2M,
where M is the number of Bytes per cache line (or cache sets).
The Byte Select bits (or Byte Offset bits) are the least significant log2M address bits.
For example, for a 2-way set associative cache, the total cache capacity is 4 cache lines, and
each cache line has 2 Bytes, then
# of set = 4 lines/ (2 lines/set) = 2 sets
# of set bits = log 2 2 = 1
c) # of Tag bits = total Memory Address bits - # of set bits - # of Byte Select bits
3. How to figure out how many LRU bits are needed per Way for a N-way Set Associative cache?
# of LRU bits per Way = log2N
# of LRU bits for a N-way Set Associative cache = N x log2N
4. How to figure out how much storage is required to implement the tag array for a 256KB, 4-way set
associative cache using 64-byte lines and LRU replacement policy implemented using counters.
Addresses are 32 bits.
Steps to Solve Such Problem: Tag array refers to not just the tags (address tags) but also all other
bookkeeping bits such as LRU bits, Valid bit and Dirty bit.
Since the cache uses 64-byte lines, so log264 = 6, therefore there are 6 bits for Byte Select
LRU bits requires 2 bits/line (for 4-way Set Associative cache, log24 = 2 bits per line)
LRU bits: 2 bits/line x 4 lines/Set = 8 bits/Set
Therefore:
Total storage required to implement the tag array for this cache is 10KB (Kilo Bytes).
5. For the cache in 4. above, to reduce thrashing, we could consider making the cache a 8-way set
associative cache (double the way per set) while keeping the overall size of the data portion of the
cache the same. How much more (or less) storage is now needed? Aside from the increased
storage, what other resources that would require a larger die are necessary?
256KB x 1 line/64 bytes x 1 set/8 lines = 218/(26 x 23) = 218/29 = 29 = 512 sets
Therefore 9 bits of address are used for index
64 bytes per line: log264 = 6, therefore there are 6 bits for Byte Select
# of Tag bits = 32 – 9 – 6 = 17 bits per Way
17 bits/Way x 8 Ways/Set = 136 bits/Set
LRU bits requires 3 bits/line (for 8-way Set Associative cache, log28 = 3 bits per line)
LRU bits: 3 bits/line x 8 lines/Set = 24 bits/Set
Therefore the total storage (or total space) required to implement the tag array for this cache is
now 11 KB, that is an increase of 1 KB from the design in 4 above which was 10KB.
Aside from the increased storage, we now require 8 comparators because it is now 8-way set
associative cache. The design from problem 4 above only require 4 comparators since that was a
4-way set associative cache.
We now require 16 comparators since we use the 16 entry, fully associative victim cache (just as
with the 16-way set associative cache).
7. If a cache is using MESI protocol, how many MESI bits are required per cache line?
# of MESI bits per cache line = log24 since MESI has 4 states: M for Modified, E for Exclusive,
S for Shared, I for Invalid.
8. Average Memory Access Time (AMAT) = (Hit Rate x Hit Time) + (Miss Rate x Miss Time)
(See Lecture slides “4-Caches-with Notes.pptx” page 33).