Sunteți pe pagina 1din 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]
1
250 mhz

1sec
6
.004 10 sec per cycle
6
250 10 cycles

4 10

sec per cycle 4 ns per cycle

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

1 cycle
9
6
0.1333 10 cycles per sec 133.3 10 cycles per sec
9
7.5 10
sec

133.3 Mhz

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
0
1
2
3

tag
11011111010
00110001100
01010010111
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 216 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

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]

i.
ii.
iii.
iv.
v.
4.

73B2
DF45
8C7C
07E9
318B

Tag
01110011101
11011111010
10001100011
00000111111
00110001100

L
10
00
11
01
01

W
010
101
100
001
011

line
line
line
line
line

2
0
3
1
1

word
word
word
word
word

2
5
4
1
3

No
Yes
No
No
Yes

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
8

5.

Set
4

Word
7

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 leastsignificant 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
20

Set
8

Word
4

b. Where in the cache is the word from memory location 3A2C6F0D mapped [4 points]
Converting to binary:
3
0011

A
1010

2
0010

C
1100

6
0110

F
1111

0
0000

D
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

S-ar putea să vă placă și