
Homework 4 Solutions
Prof. Loh
CS3220 - Processor Design - Spring 2005
1. Caches In the following parts, all caches will have a capacity of 256 bytes, and 4-byte (32-bit) words. Assume an
address of 16-bits (A[0..15]). You do not need to draw each and every single entry in the cache, but instead, use
ellipses (“...”) when appropriate to reduce the amount of tedious drawing that would otherwise be required.
(a) Design a direct mapped cache (with the specifications given above: 256 byte capacity, 4 byte words), where each
cache line stores only a single word. Be sure to label which bits are used to index into the cache, to compare to
the tag, etc. How large is the cache in bits (including the bits for the tag, a valid bit, and a dirty bit)? If a cache
hit takes 1ns, and a cache miss takes 10ns to service, how long will it take to access the following sequence of
addresses, assuming that all entries of the cache are initially invalid?
4, 8, 12, 16, 4, 4, 20, 4, 16, 68, 132, 72, 8, 12, 68, 4, 100, 52, 20, 4, 8, 12, 16, 4, 4, 256, 4, 16, 516
Data: 32 bits118
Tag V D
0
1
2
.
.
.
a[7,2]a[15,8]
hit?
63
42 bits/entry
64 entries total
With 4-byte words, we divide the address by four to get a word index. We then take the word index modulo 64
(since there are 64 rows in the cache) to get a row index.
4→1 (M), 8→2 (M), 12→3 (M), 16→4 (M), 4→1 (H), 4→1 (H), 20→5 (M), 4→1 (H), 16→4 (H), 68→17 (M),
132→33 (M), 72→18 (M), 8→2 (H), 12→3 (H), 68→17 (H), 4→1 (H), 100→25 (M), 52→13 (M), 20→5 (H),
4→1 (H), 8→2 (H), 12→3 (H), 16→4 (H), 4→1 (H), 4→1 (H), 256→0 (M), 4→1 (H), 16→4 (H), 516→1 (M)
Total: 12 misses, 17 hits, 137 ns.