Sei sulla pagina 1di 3

CS 271: Fall, 2015 Assignment 3 Answer Key

Start reading chapter 5 on internal memory. If you wish to get partial credit, please show your
work.     

Total = 62 points

1. a. Find the cycle time, in nanoseconds, for a 250 MHz clock. [2 points]

b. Find the clock frequency, in MHz, for a clock having a cycle time of 7.5ns. [2 points]

2. a. Suppose a computer is word-addressable and a main memory address is 17 bits in


length. What is the size of the addressable memory? [2 points]

217 = 27 210 = 128 KWords

b. Suppose a computer has a main memory of 256M words. What is the size, in bits, of a
main memory address? [2 points]

256M = 28 220 = 228. Therefore a main memory address is 28 bits.

3. A computer system has a main memory of 64K words where a word is a byte in length. It
also has a 32 byte cache organized as 4 lines of 8 words. The cache mapping function is
the direct mapping function. The tags in the cache are currently:

cache line tag


0 11011111010
1 00110001100
2 01010010111
3 10001000111

a. How many bits is a main memory address? [2 points]

64K = 216, so there are 16 bits in a main memory address.

CS 271: Fall 2015 Page 1 Assignment 3 Answer Key


b. When main memory is viewed as blocks, where a block is the size of a cache line, how
many blocks are there in main memory? [2 points]

A memory block is equal to 8 words, and 2 16 23 = 216-3 = 213. Therefore there are
213 = 8K blocks in main memory.

c. When using a direct mapping function, a main memory address is viewed as consisting
of 3 fields. For this machine, what is the size of each field in bits? [6 points]

Tag Line Word


11 2 3

d. For each of the following main memory addresses, to what (a) cache line and (b) word
slot is it mapped? Also, (c) tell whether each memory location is currently in the cache
or not. Each address is given in hexadecimal notation. [6 points each]

Tag L W
i. 73B2 01110011101 10 010 line 2 word 2 No
ii. DF45 11011111010 00 101 line 0 word 5 Yes
iii. 8C7C 10001100011 11 100 line 3 word 4 No
iv. 07E9 00000111111 01 001 line 1 word 1 No
v. 318B 00110001100 01 011 line 1 word 3 Yes

4. A set associative cache consists of 64 lines divided into four-line sets. Main memory
consists of 4K blocks of 128 words each. Show the format of a main memory address.
[4 points]

Main memory consists of 128 4K words = 27 212 = 219 words. This means that a
main memory address is 19 bits long. A cache line is the size of a memory block, so a
cache line is 128 = 27 words. Thus the word field is 7 bits. If there are 64 cache
lines divided into 4 line sets, there must be 64 4 = 16 sets. Thus the set field is 4
bits. This leaves 8 bits for the tag field.

Tag Set Word


8 4 7

5. A microprocessor has a 32-bit word size and a 16KB 4-way set associative cache where
each cache line holds four words. If we assume that the machine is byte-addressable, the
word field for this problem is 4 bits. Since a word is 4 bytes and there are 4 words per
cache line, the most-significant 2 bits selects one of the four words in the line and the least-
significant 2 bits selects one of the four bytes within the word.

CS 271: Fall 2015 Page 2 Assignment 3 Answer Key


a. If a main memory address is 32 bits, what is the format of a main memory address?
[6 points]

The word field is given as 4 bits. Each cache line is 16 bytes: a line is 4 words; a
word is 4 bytes. Since the cache is 4-way set associative, there are 4 lines to a
set. Thus a set is 4 lines 16 bytes per line = 64 bytes, and there are 16KB 64
bytes = 214 26 = 28 sets. The set field, therefore is 8 bits. Since the main
memory address is 32 bits long, the tag field is 32 - (8 + 4) = 20 bits.

Tag Set Word


20 8 4

b. Where in the cache is the word from memory location 3A2C6F0D mapped [4 points]

Converting to binary:

3 A 2 C 6 F 0 D
0011 1010 0010 1100 0110 1111 0000 1101

Word: 1101b = 13d = Dh. If the machine is byte-addressable, this means byte 1
from word 3.
Set: 11110000 = 240d = F0h
Tag: 00111010001011000110b = 238278d = 3A2C6h

CS 271: Fall 2015 Page 3 Assignment 3 Answer Key

Potrebbero piacerti anche