Docsity

Homework 4 Solutions - Processor Design | CS 3220, Assignments of Computer Science

Toggle sidebar
bg1
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.
pf3
pf4
pf5

Partial preview of the text

Download Homework 4 Solutions - Processor Design | CS 3220 and more Assignments Computer Science in PDF only on Docsity!

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?

8 1 1 Data: 32 bits

Tag V D 0 1 (^2). ..

a[15,8]a[7,2]

hit?

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.

(b) Repeat for a fully associative cache (remember to include LRU bits for the non-direct-mapped caches!).

14 1 1 Data: 32 bits

Tag V D 0 1 (^2). ..

a[15,2]

hit?

hit 0

hit 1

hit 63

LRU

48 bits per entry 64 entries

hit 0

hit 1

hit 63

data

Hit/miss pattern is the same: 137ns.

(c) Repeat for a 4-way set-associative cache.

tag V LRU

D

data 10 2 32

way 0 way 1 way 2 way 3

a[15,6]

a[5,2]

data

hit?

46 bits per entry 16 entries per way 4 ways

Hit/miss pattern is the same: 137ns.

2. Pipeline Control Refer to the online notes on pipeline control for this problem. Assuming we have the pipeline

organization shown on page 2 of the notes, show the cycle-by-cycle state of the scoreboard to execute the following

instructions:

A. ADD R1 R

B. SUB R2 R

C. XOR R1 R

D. MUL R5 *R

E. ADD R4 R

F. ADD R1 R

Assume all “regular” arithmetic operations take one cycle to execute. Assume multiplication takes 2 cycles. Assume

that all memory accesses hit in the cache and take one cycle. Complete all cycles up to and including when instruction

F reaches the Load/Exec1 stage. Also, draw in the bypass paths used to route the register values from producers to

consumers (in the mini-pipeline diagrams on the right on the next page). This should look similar to the examples from

the notes. Use the following template:

RF

Load Store

BP1 BP

RF

Load Store

RF

Load Store

INT

INT

RF

Load Store

RF

Load Store

RF

Load Store

RF

Load Store

RF

Load Store

RF

Load Store

F D LE E2 SW

F D LE E2 SW

F D LE E2 SW

B A

F D LE E2 SW

F D LE E2 SW

F D LE E2 SW

F D LE E2 SW

F D LE E2 SW

F D LE E2 SW

INT1 INT2 LOADSTORE R0 R1 R2 R3 R4 R5 R6 R

RF

RF RF RF RF RF RF RF

INT1 INT2 LOADSTORE R0 R1 R2 R3 R4 R5 R6 R

INT1 INT2 LOADSTORE R0 R1 R2 R3 R4 R5 R6 R

INT1 INT2 LOADSTORE R0 R1 R2 R3 R4 R5 R6 R

INT1 INT2 LOADSTORE R0 R1 R2 R3 R4 R5 R6 R

INT1 INT2 LOADSTORE R0 R1 R2 R3 R4 R5 R6 R

INT1 INT2 LOADSTORE R0 R1 R2 R3 R4 R5 R6 R

INT1 INT2 LOADSTORE R0 R1 R2 R3 R4 R5 R6 R

INT1 INT2 LOADSTORE R0 R1 R2 R3 R4 R5 R6 R

CBA INT

BP1 INT

DCBA

INT1 BP

BP1 BP

BP

INT

BP

INT

E DCBA

F E DCB

F E D C

F E D

F E D

F E

A

B

F E

E

D

D

C

D

C

D

C B A

B A

C

D

B

E

E

E

F

A

INT

INT

INT

ST