Docsity

MIPS Machine Instructions and Cache Behavior Analysis - Prof. D. D. Garcia, Exams of Computer Science

Toggle sidebar
bg1
University of California, Berkeley – College of Engineering
Department of Electrical Engineering and Computer Sciences
Fall 2005 Instructor: Dan Garcia 2005-12-17
 CS61C Final Exam 
Last Name
First Name
Student ID Number
Login
cs61c-
Login First Letter (please circle)
a b c d e f g h i j k l m
Login Second Letter (please circle)
a b c d e f g h i j k l m
n o p q r s t u v w x y z
The name of your LAB TA (please circle)
Jeremy Michael Navtej Zhangxi
Name of the person to your Left
Name of the person to your Right
All the work is my own. I have no prior knowledge of the exam
contents nor will I share the contents with othe rs in CS61C
who have not taken it yet. (please sign)
Instructions (Read Me!)
• This booklet contains 9 numbered pages including the cover page. Put all answers on these pages (feel
free to use the back of any page for scratch work); don’t hand in any stray pieces of paper.
• Please turn off all pagers, cell phones & beepers. Remove all hats & headphones. Place your
backpacks, laptops and jack ets at the front. Sit in every other seat. Nothing may be placed in the ā€œno fly
zoneā€ spare seat/desk between students.
• Fill in the front of this page and put your name & login on every sheet of paper.
• You have 180 minutes to complete this exam. The exam is closed book, no computers, PDAs or
calculators. You may use two pages (US Letter, front and back) of notes, plus the green reference
sheet from COD 3/e.
• There may be partial credit for incomplete answers; write as much of the solution as you can. We will
deduct points if your solution is far more complicated than necessary. When we provide a blank, please
fit your answer within the space provided. ā€œIEC formatā€ refers to the mebi, tebi, etc prefixes. You have 3
hours...relax.
• You must complete ALL THE QUESTIONS, regardless of your score on the midterm.
Clobbering only works from the Final to the Midterm, not vice versa.
Problem
M1
M2
M3
Ms
F2
F3
F5
Fs
Total
Minutes
20
20
20
60
24
24
24
120
180
Points
10
10
10
30
18
18
18
90
120
Score
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14

Partial preview of the text

Download MIPS Machine Instructions and Cache Behavior Analysis - Prof. D. D. Garcia and more Exams Computer Science in PDF only on Docsity!

University of California, Berkeley – College of Engineering

Department of Electrical Engineering and Computer Sciences

Fall 2005 Instructor: Dan Garcia 2005 - 12 - 17

 CS61C Final Exam 

Last Name

First Name

Student ID Number

Login cs61c-

Login First Letter (please circle) a^ b^ c^ d^ e^ f^ g^ h^ i^ j^ k^ l^ m

Login Second Letter (please circle) a b c d e f g h i j k l m

n o p q r s t u v w x y z

The name of your LAB TA (please circle) Jeremy Michael Navtej Zhangxi

Name of the person to your Left

Name of the person to your Right

All the work is my own. I have no prior knowledge of the exam contents nor will I share the contents with others in CS61C

who have not taken it yet. (please sign)

Instructions (Read Me!)

  • This booklet contains 9 numbered pages including the cover page. Put all answers on these pages (feel

free to use the back of any page for scratch work); don’t hand in any stray pieces of paper.

  • Please turn off all pagers, cell phones & beepers. Remove all hats & headphones. Place your

backpacks, laptops and jackets at the front. Sit in every other seat. Nothing may be placed in the ā€œno fly

zoneā€ spare seat/desk between students.

  • Fill in the front of this page and put your name & login on every sheet of paper.
  • You have 180 minutes to complete this exam. The exam is closed book, no computers, PDAs or

calculators. You may use two pages (US Letter, front and back) of notes, plus the green reference

sheet from COD 3/e.

  • There may be partial credit for incomplete answers; write as much of the solution as you can. We will

deduct points if your solution is far more complicated than necessary. When we provide a blank, please

fit your answer within the space provided. ā€œIEC formatā€ refers to the mebi, tebi, etc prefixes. You have 3

hours...relax.

  • You must complete ALL THE QUESTIONS , regardless of your score on the midterm.

Clobbering only works from the Final to the Midterm, not vice versa.

Problem M1 M2 M3 Ms F1 F2 F3 F4 F5 Fs Total Minutes 20 20 20 60 24 24 24 24 24 120 180 Points 10 10 10 30 18 18 18 18 18 90 120 Score

Name: _______________________________ Login: cs61c-____

Midterm Revisited M1) ā€œDoctor, our patient is encoding !ā€ ( 10 pts, 20 min)

a) A Binary Coded Decimal (BCD) uses a dedicated nibble for each decimal digit, so a byte could

represent all the numbers from 00-99. We will use our standard MIPS 32-bit word to encode a

BCD. What is the ratio (to one significant figure, in decimal) of overall bit patterns to the ones

that encode a valid BCD? (E.g., With a single decimal digit, it’d be 16/10 ā‰ˆ 2.) Show your work.

Your answer should not be an expression, it should be a decimal number rounded to 1

significant figure.

_______________

b) Suppose we have a very small 4 pixel Ɨ 8 pixel grayscale video display where each pixel can

independently be set to one of 4 shades of gray. How many unique images can possibly be

displayed? Leave your answer in IEC form (e.g., 64 kibi images, 8 mebi images, etc).

_______________

c) If we were to try to compare two floats using our MIPS signed integer compare slt,

when would we get an incorrect answer (i.e., describe in English the set of all possible inputs

that generate incorrect answers)? Assume neither encodes a NaN or ±0.

____________________________________________________________________________________

d) Put the corresponding letters for each 32-bit value in order from least to greatest. Hint: the

question isn’t asking you to write down what each one is, it only asks for the relative order!

A. 0xF0000000 (IEEE float)

B. 0xF0000000 (2's complement)

C. 0xF0000000 (sign-magnitude)

D. 0xFFFFFFFF (2's complement)

E. 0xFFFFFFFF (1's complement)

F. 0xF1000000 (IEEE float)

G. 0x70000000 (IEEE float)

H. 0x7FFFFFFF (2's complement)

I. 0x80000010 (IEEE float)

Least_____________________________________________________________________Greatest

Name: _______________________________ Login: cs61c-____

M3) ā€œFenry Hord invented the disassembly lineā€¦ā€ ( 10 pts, 20 min)

a) Given the MIPS code below, write the equivalent C function below in the structure we’ve

provided. Feel free to add comments to help your disassembly. To aid readability, you must

use the variable names from our comments below in your C solution where appropriate.

foo: addiu $sp, $sp, - 12 sw $a0, 0($sp) # src sw $a1, 4($sp) # size sw $ra, 8($sp) move $a0, $a1 # addiu $a0, $a0, 1 # jal malloc # move $t0, $v0 # dest lw $t1, 0($sp) # src lw $t2, 4($sp) addu $t2, $t2, $t1 # end foo_loop: beq $t2, $t1, foo_end # lbu $t4, 0($t1) # ori $t4, $t4, 0x20 # sb $t4, 0($t0) # addiu $t0, $t0, 1 # addiu $t1, $t1, 1 # j foo_loop foo_end: sb $0, 0($t1) # lw $ra, 8($sp) # addiu $sp, $sp, 12 jr $ra

b) If src contained letters , what is a more appropriate name for the subroutine foo?

(i.e., what would ā€œjal fooā€ do, from the point of view of the caller?)

Hint: you might find the green sheet handy here.

c) What if we called foo from printf as so: printf("… format string …", foo(source, size)).

Why is this bad form? Hint: think about what would happen if this were done many times.

d) Let’s say we removed the ā€œ sb $0, 0($t1) ā€ instruction and then made the same call to foo

from printf as in question (c) above: What are all the things that could happen?

________ foo (________ src, ________ size) { for(___________; ____________; ____________) { } }

Name: _______________________________ Login: cs61c-____

Post-Midterm Questions F1) ā€œWhere’s the sofr (sophomore, freshman) instr?ā€ ( 18 pts, 24 min)

On the right is the single-cycle

MIPS datapath presented

during lecture. Your job is to

modify the diagram to

accommodate a new MIPS

instruction. Your modification

may use simple adders,

shifters, mux chips, wires, and

new control signals. If

necessary, you may replace

original labels.

Function calls in MIPS typically

end with stack restoration and

jr $ra as shown below.

Because this happens often, we want to do this in one instruction instead of two. We’ll design a new

I-type instruction, srjr (stack restore, jump register), as follows:

addi $sp, $sp, 16 jr $ra ^

srjr $ra $sp 16

a) What is the RTL for srjr that will allow it to have the widest range of stack restoration?

Hint: stack restoration always occurs in non-negative word units … The jr is done already.

; PC = R[rs]

b) What is the most $sp could change as a result of a srjr call (in Bytes)? Use IEC format.

Bytes (plus or minus a byte).

c) Modify the picture above and list your changes below. You may not need all the boxes.

Please write them in ā€œpipeline stage orderā€ (i.e., changes affecting IF first, MEM next, etc)

(i)

(ii)

(iii)

(iv)

(v)

(vi)

d) We now want to set all the control lines appropriately. List what each signal should be

(an intuitive name or { 0 , 1 , x = don't care}). Include any new control signals you added.

RegDst RegWr nPC_sel ExtOp ALUSrc ALUctr MemWr MemtoReg

Rs Rt

Name: _______________________________ Login: cs61c-____

F3) ā€œFolks in Alaska are experts in Pipelining ā€¦ā€ ( 18 pts, 24 min)

Consider a processor with the following specification:

o Standard five (5) stage (F, D, E, M, W) pipeline.

o No forwarding.

o Stalls on ALL hazards.

o Non-delayed branches

o Branch comparison occurs during the second stage.

o Instructions are not fetched until branch comparison is done.

o Memory CAN be read/written on same clock cycle.

o The same register CAN be read & written on the same clock cycle (structural hazard).

o No out-of-order execution.

a) Count how many cycles will be needed to execute the code below and write out each

instruction’s progress through the pipeline by filling in the table below with pipeline stages

(F, D, E, M, W).

[1] add $a0, $a0, $t [2] lw $a1, 0($a0) [3] add $a1, $a1, $t [4] sw $a1, 0($t1) [5] add $t1, $t1, - 1 [6] bne $0, $0, end [7] add $t9, $t9, 1 Cycle  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Inst 1 F Inst 2 Inst 3 Inst 4 Inst 5 Inst 6 Inst 7

b) Considering the following two changes , fill in the table again:

o Our processor now forwards values

o Delayed branches

Cycle 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Inst 1 F Inst 2 Inst 3 Inst 4 Inst 5 Inst 6 Inst 7

Name: _______________________________ Login: cs61c-____

F4) Synchronous Digital Circus ( 18 pts, 24 min)

We are designing a circuit with a 1-bit input (I(t)) and a 2-bit output (O(t)), that will produce, at time

t, the number of zeros in the set {I(t-2), I(t-1), I(t)}. As an example,

the input: I: 1 1 0 0 1 0 0 1 1 0 1 1 1 0 0 0

…will produce the output: O: 0 0 1 2 2 2 2 2 1 1 1 1 0 1 2 3

a) Complete the FSM diagram below. Our states have been labeled Sxy

indicating that the previous 2 bits,{I(t-2), I(t-1)} would be {x, y}.

Fill in the truth table on the right. The previous state is encoded in

(P1,P0), the next state is encoded in (N1,N0), and the output is encoded

as (O1,O0). Make sure to indicate the value of the output on your state

transitions.

b) Provide fully reduced (i.e., fewest gates to implement…you can use any n - input gates)

Boolean expressions for the Output (O1,O0) and Next State (N1,N0) bits. If there is a name for

any of the circuits, write it on the left. E.g., ā€œThe always-1ā€, ā€œ3-input NANDā€, etc. A 2-input XOR

has the symbol of ā€œāŠ•ā€.

Scratch space _________________ O1 = _________________ O0 = _________________ N1 = _________________ N0 =

c) Draw the overall circuit using the fewest gates possible with and without feedback below.

You may add registers. ā€œFeedbackā€ means outputs are somehow fed back into inputs.

Assume we’ve correctly implemented the answer to (b) as a black box in the middle.

P1 P0 I O1 O0 N1 N
I O
O

With feedback

I

Without feedback

O
N1 O
O
O
P0 N
P
I
N
O
O
P0 N
P
I
S00 S
S10 S

2005Fa CS61C Final Exam Answers [not to leave 385 Soda] M1:Numbers

a) Overall bit patterns? 2

32

= 4,294,967,296 (the exact # is not required; roughly a bit more than

How many encode a valid BCD? 8 decimal digits, so 10^8 = 100,000,

Ratio is 2^32 /10^8 = 42.94967296 ā‰ˆ 40 (to one significant figure).

b) Each pixel is independent, and there are 4x8=32=

5

of them, so it’s 4

32

2

32

64

= 16 exbi images.

c) Comparing floats using signed int compare, huh? The relative ordering of all positive

numbers is the same (increasing from 0 to max_positive) for both encodings, so comparing two

positive floats with signed compare works. Also, for both encodings the bit patterns for

negative numbers all start with a leading 1 (0x80000000 through 0xFFFFFFFF) so comparing a

negative float with a positive float using signed int compare will also yield the correct

answer. However, when comparing two negative floats, the sign-magnitude nature of floats

means that as we increase the bit patterns from (0x80000000 through 0xFFFFFFFF) floats

move from 0 toward - āˆž, but signed ints move the other way from - āˆž (- 2

31

, really) toward 0.

Thus, we will get an incorrect answer when comparing two different negative numbers.

d) Put the corresponding letters for each 32-bit value in order from least to greatest:

A. 0xF0000000 (IEEE float) = - huge

B. 0xF0000000 (2's complement) = - 231 + 2^30 + 2^29 + 2^28

C. 0xF0000000 (sign-magnitude) = - ( 231 – 228 ) = - 231 + 2^28

D. 0xFFFFFFFF (2's complement) = - 1

E. 0xFFFFFFFF (1's complement) = - 0

F. 0xF1000000 (IEEE float) = - huger

G. 0x70000000 (IEEE float) = + huge

H. 0x7FFFFFFF (2's complement) = 2^31 - 1

I. 0x80000010 (IEEE float) = - small denorm (value doesn’t matter)

f, a, c, b, d, i, e, h, g

M2:C

a) static stack heap

1: 4+16+4+4=28 B 0 0

3: 0 282 + 24 = 64 B 0

4 : 0 0 280 B

b) Two solutions…Longest (with the best style)

int Delete (slicenode_t plan) { if(plan->type == RECTANGLE) { / leaf / free(plan); return(1); } else { if plan->type == CUT) { / inner node */ **slidenode_t L, R; L = plan->L; R = plan->R; free(plan); return(1+Delete(L)+Delete(R)); } else { printf("Delete(): plan->type was %d, expected %d or %d", plan->type, RECTAN CUT); exit(1); } } }

… and longest!

int Delete (slicenode_t plan) { if(plan->type == RECTANGLE) { / leaf */ **free(plan); return(1); } else { slidenode_t L, R; L = plan->L; R = plan->R; free(plan); return(1+Delete(L)+Delete(R)); } }

… and shortest!

int Delete (slicenode_t plan) { if(plan->type == RECTANGLE) { return(1+(0free(plan))); } else { /* inner node / return(1+Delete(plan->L)+Delete(plan->R)+(0free(plan))); } }

F1:Datapath

srjr $ra, $sp, 16

a) R[rt] = R[rt] + (ZeroExt(Imm) << 2); PC = R[rs]

b) 256 kibi (16 unsigned 0xFFFF bits of words = 18 unsigned bytes)

c)

i. Add mux so Ra input is sometimes Rs, sometimes Rt, call the control signal RegSrc

ii. Modify Extender so that it can do a ā€œZeroShiftExtendā€, widen ExtOp control line

d)

  • RedDst=rt (0)
  • RegWr= 1
  • nPC_sel=Jump
  • ExtOp=ZeroShiftExtend
  • ALUSrc=Extender (1)
  • ALUctr=ADD
  • MemWr= 0
  • MemtoReg=ALU (0)
  • [NEW]RegSrc=Rt

F2:Cache/VM

a) With 8-byte blocks (3 bits for offset) and a fully associative cache (0 bits for index), and a MIPS

machine (32-bit addresses), we have 29:0:

b) The cache size, or ā€œareaā€ is the ā€œheightā€ (128 = 2

7

blocks) times the ā€œwidthā€ (8 B/block = 2

3

B/block),

which is 2^10 bytes i.e., 1 KibiByte.

c) To minimize cache misses, we should never stride so far that the initial sum loop couldn’t fit

entirely into the 128-entry cache. So the farthest we could stride is the entire size of the cache ,

or 1 KiB. Any stride smaller than that will also have the property that the sum loop has a miss

for each block but the product loop has all hits.

d) Each block loaded by sum will be a miss, but product’s requests will be all hits. If the stride is

1 KibiB, that’s 2

7

misses for each of the outer loop iterations, and there are 4 MiB / 1 KiB (= 4

Ki) = 2

12

iterations. So that’s 2

7

misses/iteration * 2

12

iterations = 2

19

misses = 512 KiMisses.

e) If we are not page-aligned, what will happen is that the last page request for sum will kick the

first page out. As a result, the first page request for product won’t be there, and we’ll be

charged a page miss! The problem propagates, unfortunately. That is, the first product page we

just loaded will kick the second sum page out (since it’s the last to be accessed) so when the

second product page comes by it will also have a miss! So basically you have no cache savings

at all! However, there’s a small detail. When we shift our machinery down another stride and

increment i (which we do a total of 2

12

times), the last block loaded by the product loop will

be the first one requested by the sum loop! (But that’s a really small detail) So the answer is

simple – with block alignment every sum is a miss and every product is a hit. Without block

alignment every sum is a miss AND every product is a miss. Thus we double our misses.

f) Sure, Virtual and Physical address widths are independent. The VA width how much (virtual)

memory our program thinks we have (here 32-bits of it) and PA controls how much resident

memory we have, a completely independent quantity.

g) Sure, because we could have more resident pages (for the OS, other processes [either ours or

another users]) and there’d be less thrashing.

h) The and instruction was the last instruction in the page and the or is the first instruction in the

next page and we just experienced a page fault! Since pages are 4 KiB, the last instruction must

have the LS bits be page size – 4B, so we know the last three nibbles (offset) are 0XFFC. (i.e.,

one more instruction and the offset becomes 0x000 – a new page!)

F4:SDS

F4a) From S00 we have two transition possibilities, I=0 and I=1. I’ve felt it useful to think about

the past values I(t-2), I(t-1) and I(t) to figure out where to go. This is a simple box (a shift

register) that keeps the last two values in the state variables Sx and Sy. Every step we output ~Sx +

~Sy + ~I = ~P1 + ~P0 + ~I. Also every step N1=P0, N0=I. We don’t even need a truth table to

know this – it’s part of the definition of Sxy.

PP I OO NN (Input/Output label for edge) [#ZI(ABC) = NumberOfZerosIn(P1,P0,I)] 10 10 10

S00 0  11 S00 (0/ 3 ) # Had two 0s, another one means we stay here and output #ZI(000)= S00 1  10 S01 (1/ 2 ) # This is our first 1 in a while, register we’ve seen a 1 by

setting I(t-1) to 1 (i.e., S01) and output #ZI(001)=

S01 0  10 S10 (0/ 2 ) # Saw a 01 before but this 0 means we goto S10 and output #ZI(010)= 2 S01 1  01 S11 (1/ 1 ) # This is the 2 nd^1 in a row, go to S11 and output #ZI(011)= 1 S10 0  10 S00 (0/ 2 ) # Saw a 1 2 timesteps ago, nothing since. Goto S00,output #ZI(100)= S10 1  01 S01 (1/ 1 ) # Saw a 1 2 timesteps ago, a 1 now. Goto 01, output #ZI(101)= S11 0  01 S10 (0/ 1 ) # Saw 2 straight 1s, now a 0. Goto S10, output #ZI(110)= S11 1  00 S11 (1/ 0 ) # Everything is coming up 1s! Stay here (in S11), output #ZI(111)= 0

F4b)

Fully reduced expressions for O1,O0 and N1,N0, huh? Well, some are easier than others. We’ll do the

easier ones first. Looking at the truth table (not doing the mindless sum-of-products calculation), we

see:

N0=I
N1=P

Which we already knew from part (a)! There are no names for these circuits. Let’s now look at O

and O0. If we’re extremely clever, we remember the two bit patterns for an adder’s two output bits:

O1 is a minority circuit and O0 is a 3-input xnor. Let’s see if we can figure that out even if we don’t

remember these facts. Let’s study the truth table and look at the negative spaces (the times when the

output is zero). We see when P1 is 0 O0 looks like xnor(P0,I) = ~(P0 āŠ• I). When P1 is 1 O0 looks

xor(P0,I) = (P0 āŠ• I). That is, P0āŠ•I is being conditionally inverted by P1, which is what an xor

does! From this, we see that

O0 = ~[P1āŠ•(POāŠ•I)], i.e. the post-negation of two cascaded xors, which is the same as a 3-input

xnor!

O1 is a little harder. We can still study the table and see some patterns. That is, when P1 = 0 , O

looks like nand(P0,I) = ~(P0*I). When P1= 1 , O1 is like a nor(P0,I) = ~(P0+I). This yields

S00 S

S10 S

0/1^ 1/

__ ____ ____
O1 = P1(P0I) + P1*(P0+I)
__ __ _ __ _

= P1(PO+I) + P1(P0I)* # DeMorgan’s law __ __ __ _ __ _ = P1 P0 + P1 I + P1 P0 I # distribution

Now it might look like this is minimal, but we can check two ways that it’s not. First, there’s

symmetry to the bit patterns (the expression is true whenever at least two of the three components

P1,P0 or I are false) BUT there’s not symmetry to the expression. Also, we can see that ~P0~I

yields a 1 in O1 independent of P1 from the truth table. We can also do some funky Boolean

algebra…

Recall the following distributive + law-of-1s + identity simplification?

A+AB = A(1+B) = A(1) = A

Well, we can run it backwards. That is, we can start with A and generate A+AB.

We do that here with ~PI~P0:

__ __ __ __ __ __ _ __ __ __ __ _
P1 P0 = P1 P0(1) = P1 P0(1+I) = P1 P0 + P1 P0 I

So that means our three terms for O1 are now four :

__ __ __ _ __ _

O1 = P1 P0 + P1 I + P1 P0 I # from above __ __ __ _ __ _ __ __ _ O1 = P1 P0 + P1 I + P1 P0 I + P1 P0 I # distributive+law-of-1s+identity __ __ __ _ __ __ _ O1 = P1 P0 + P1 I + (P1+P1)P0 I # distribution __ __ __ _ __ _ O1 = P1 P 0 + P1 I + ( 1 )P0 I # complementarity __ __ __ _ __ _ O1 = P1 P0 + P1 I + P0 I # identity __________________ O1 = (P1P0 + P1I + P0I) # lots more Boolean algebra!

…a NotMajority, or AntiMajority, or Minority circuit!

We could also do this the standard plug-and-chug SoP (sum-of-products) way:

__ __ _ __ __ __ _ __ _

O1 = P1 P0 I + P1 P0 I + P1 P0 I + P1 P0 I # sum-of-products __ __ _ __ __ __ __ _ __ _ __ __ _ __ _ O1 = P1 P0 I + P1 P0 I + P1 P0 I + P1 P0 I + P1 P0 I + P1 P0 I # rev idempotent, commutativity __ __ _ __ _ __ __ _ __ O1 = P1 P0(I+I) + P1 I(P0+P0) + P0 I(P1+P1) # commutativity, rev distrib __ __ __ _ __ _ O1 = P1 P0( 1 ) + P1 I( 1 ) + P0 I( 1 ) # complementarity __ __ __ _ __ _ O1 = P1 P0 + P1 I + P0 I # identity __________________ O1 = (P1P0 + P1I + P0I) # lots more Boolean algebra!

…a NotMajority, or AntiMajority, or Minority circuit!

F5:Potpourri

a) One of 9. The lesson was [debug & test rigorously as if lives depend, expect the unexpected.

Design with failure as a possibility. Add redundancy]

1. Mariner I space probe

2. Soviet gas pipeline

3. Buffer overflow in Unix finger daemon

4. Kerberos Random # generator

5. AT&T network outage

6. Intel Pentium floating pt

7. Ping of death

8. Ariane 5 Flight 501

9. National Cancer Institute

b) SPUR: Security, Privacy, Usability, Reliability

c) What are the constraints on the timing?

To maintain tsetup time constraints (and starting from the rising edge of a clock), we have the

usual equation that helps us determine how fast we can run the clock. This is that the signal,

from when it leaves the FF, goes through all the gates, until it comes around again, has to

arrive on the inputs earlier than tsetup before the next clock rising edge. Thus, we have:

tclk-to-q, + tinverter + tor + tsetup < tclock

... and to maintain thold time constraints, which state that the signal cannot get back around

and change before (less time) the hold time thold has passed, yields the following constraint:

tclk-to-q, + tinverter + tor > thold

So, isolating for tinverter in both of these inequalities yields the constraints:

thold – (tclk-to-q, + tor) < tinverter < tclock – (tclk-to-q, + tor + tsetup)

d) How fast do branches for B need to be? Well, let’s figure out the equations:

CPUtimeA = CPUtimeB [1]

But we know the equation for CPUtime as:

CPUtime = InstructionCount * CPI * ClockTime [2]

So substituting that into [1] gives us

InstructionCountA * CPIA * ClockTimeA = InstructionCountB * CPIB * ClockTimeB [3]

But since it’s the same program,

InstructionCountA = InstructionCountB [4]

Equation [3] now simplifies to:

CPIA * ClockTimeA = CPIB * ClockTimeB [5]

And substituting

ClockTimei = 1/ClockFreqi [6]

into [5] gives

CPIA / ClockFreqA = CPIB / ClockFreqB [7]

So solving for CPIB:

CPIB = ClockFreqB / ClockFreqA (CPIA) [8]

CPIB = 4/2 CPIA= 2 * CPIA

So now we only have to solve for CPIA and CPIB from the table:

CPIA = 2(2/10) + 2(3/10) + 2(5/10) = (4+6+10)/10 = 20/10 = 2 cycles/instruction

CPIB = 1(2/10) + 1(3/10) + X(5/10) = (2+3+5X)/10 = (5+5X)/10 = 4 cycles/instruction

Solving for X yields

5+5X=40  5X=35  X = 7

e) lg(16 exbi) = lg(

64

) = 64 bits total. lg(12 10 x

10

) = lg(

14

) = 14 MSBs. lg(200,000,000) =

lg(

28

) = 28 LSBs. Therefore we have 64- 14 - 28=50-28=22 bits left, which can encode 4

mebithings.

f) How much could we store? Well, here is the standard equation:

Capacity(B) = Density(B/in

2

) * Area/Surface (in

2

/Surf) * SurfacesPerPlatter (Surf/Plat) *

#Platters (Plat)

And we’re given

Density =? B/in^2

#Platters = 4 Plat

SurfacesPerPlatter = 2 Surf/Plat (if we want to maximize capacity, we use BOTH sides!)

Area/Surface = area of the disk = π r

2

outer –^ Ļ€^ r

2

inner =^ Ļ€^ (30/Ļ€^ –^ 22/Ļ€) = 8 in

2

/Surf

Thus,? Gibi (B/in^2 ) * 8 (in^2 /Surf) * 2 (Surf/Plat) * 4 (Plat) =? 2^32122 B = 2^40 B = 1

TebiByte, so? = 2^24 B/in^2 = 16 GiB/in^2

g) 0: 32 TebiB, 1: 16 TebiB, 3: 31 TebiB, 5: 31 TebiB