Docsity

Homework Solutions for CPSC 2105: Introduction to Computer Organization, Assignments of Computer Architecture and Organization

Toggle sidebar
bg1
CPSC 2105 Introduction to Computer Organization
Homework Set 8 Due Monday, April 3, 2006
HOMEWORK KEY WITH ANSWERS AND COMMENTS.
1. Suppose a computer using direct mapped cache has 232 words of main memory and a
cache of 1024 blocks, where each cache block contains 32 words.
a) How many blocks of main memory are there?
b) What is the format of a memory address as seen by the cache, that is, what are the
sizes of the tag, block, and word fields?
c) To which cache block will the memory reference 0000 63FA map?
ANSWER: Recall that 1024 = 210 and 32 = 25, from which we may conclude 1024 = 32 32.
a) The number of blocks is 232 / 25 = 2(32 – 5) = 227 = 27 220 = 128 M = 134, 217, 728.
b) 32 words per cache line Offset address is 5 bits.
1024 blocks in the cache Block number is 10 bits.
232 words 32 bit address 32 – (5 + 10) = 10 – 15 = 17 bit tag.
Bits 31 15 14 5 4 0
Contents Tag Block Number Offset within block
c) The number of bits allocated to the block number and offset are 15. We examine
the last four hex digits of 0000 63FA, as they correspond to 16 binary bits.
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Hex 6 3 F A
Binary 0 1 1 0 0 0 1 1 1 1 1 1 1 0 1 0
11 0001 1111 = 0x31F 1 1010 = 0x1A = 26
0x31F = 3256 + 116 + 15 = 768 + 16 + 15 = 799.
2. Suppose a computer using fully associative cache has 224 words of main memory and a
cache of 128 blocks, where each cache block contains 64 words.
a) How many blocks of main memory are there?
b) What is the format of a memory address as seen by the cache, that is, what are the
sizes of the tag and word fields?
Answer: Recall that 128 = 27 and 64 = 26.
a) The number of blocks is 224 / 26 = 2(24 – 6) = 218 = 28 210 = 256 K = 262, 144.
b) For associative mapping the address has only tag and word offset in the block.
64 word block 6 bit offset.
24 bit address (24 – 6) = 18 bit tag.
Bits 23 6 5 0
Contents Tag Offset in block
pf2

Partial preview of the text

Download Homework Solutions for CPSC 2105: Introduction to Computer Organization and more Assignments Computer Architecture and Organization in PDF only on Docsity!

CPSC 2105 Introduction to Computer Organization

Homework Set 8 Due Monday, April 3, 2006

HOMEWORK KEY WITH ANSWERS AND COMMENTS.

  1. Suppose a computer using direct mapped cache has 2^32 words of main memory and a cache of 1024 blocks, where each cache block contains 32 words. a) How many blocks of main memory are there? b) What is the format of a memory address as seen by the cache, that is, what are the sizes of the tag, block, and word fields? c) To which cache block will the memory reference 0000 63FA map? ANSWER: Recall that 1024 = 2^10 and 32 = 2^5 , from which we may conclude 1024 = 32  32. a) The number of blocks is 2^32 / 2^5 = 2(32 – 5)^ = 227 = 2^7  220 = 128 M = 134, 217, 728. b) 32 words per cache line  Offset address is 5 bits. 1024 blocks in the cache  Block number is 10 bits. 232 words  32 bit address  32 – (5 + 10) = 10 – 15 = 17 bit tag. Bits 31 15 14 5 4 0 Contents Tag Block Number Offset within block c) The number of bits allocated to the block number and offset are 15. We examine the last four hex digits of 0000 63FA, as they correspond to 16 binary bits. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 Hex 6 3 F A Binary 0 1 1 0 0 0 1 1 1 1 1 1 1 0 1 0 11 0001 1111 = 0x31F 1 1010 = 0x1A = 26 0x31F = 3256 + 116 + 15 = 768 + 16 + 15 = 799.
  2. Suppose a computer using fully associative cache has 2^24 words of main memory and a cache of 128 blocks, where each cache block contains 64 words. a) How many blocks of main memory are there? b) What is the format of a memory address as seen by the cache, that is, what are the sizes of the tag and word fields? Answer: Recall that 128 = 2^7 and 64 = 2^6. a) The number of blocks is 2^24 / 2^6 = 2(24 – 6)^ = 2^18 = 2^8  210 = 256 K = 262, 144. b) For associative mapping the address has only tag and word offset in the block. 64 word block  6 bit offset. 24 bit address  (24 – 6) = 18 bit tag. Bits 23 6 5 0 Contents Tag Offset in block
  1. Suppose a cache memory with access time of 8 nanoseconds fronting a main memory with access time of 80 nanoseconds. What is the effective access time if a) The hit ratio is 0.8? b) The hit ratio is 0.9? c) The hit ratio is 0.99? HINT: Use the equation TE = hTC + (1 – h)TM TE is the effective access time. TC is the access time of the cache memory. TM is the access time of the main memory. Answer: Here we have TC = 8.0 and TM = 80.0. a) h = 0. TE = 0.88.0 + (1 – 0.8)80. = 0.88.0 + 0.280.0 = 6.4 + 16 = 22.4 nanoseconds. b) h = 0. TE = 0.98.0 + (1 – 0.9)80. = 0.98.0 + 0.180.0 = 7.2 + 8 = 15.2 nanoseconds. c) h = 0. TE = 0.998.0 + (1 – 0.99)80. = 0.998.0 + 0.0180.0 = 7.92 + 0.8 = 8.72 nanoseconds. Just to be compulsive, we offer an alternate method of solution. Start with the equation TE = hTC + (1 – h)TM and specify TC = 8.0 and TM = 80.0 to get TE = h8.0 + (1 – h)80.0 = 8.0h + 80.0 – 80.0h = 80.0 – 72.0h Given TE = 80.0 – 72.0h, we get a) h = 0.8 TE = 80.0 – 72.00.8 = 80.0 – 57.6 = 22. b) h = 0.9 TE = 80.0 – 72.00.9 = 80.0 – 64.8 = 15. c) h = 0.99 TE = 80.0 – 72.00.99 = 80.0 – 71.28 = 8.