Write your answers on this question paper. Your answers must be clear and legible. You may not use your book, your notes, or any other such material during this exam. You may use a calculator. Use the space provided to show how you arrived at your answer for partial credit. Only the answers you write in the spaces provided will be graded; you may use the back of the pages for your own private calculations. If a question seems ambiguous, state any assumptions you need to make to work the problem.
Which machine is faster, machine A or B?
Let's compute the CPI for the first machine: CPI_A = 1 + 0.33 * 5 = 2.65 Now let's compute the nsPI (nanoseconds per instruction) for the first machine: nsPI_A = 1ns/cycle * 2.65 = 2.65ns Let's compute the CPI for the second machine: CPI_B = 1 + 0.33 * 20 = 7.60 Now let's compute the nsPI for the second machine: nsPI_B = 1ns/2cycles * 7.60 = 3.8ns So machine A is faster, even though it has a lower clock rate.What is the speedup?
3.8 / 2.65 = 1.44 So the speedup is 1.44, or 44%
L R9, 0(R5) DADD R1, R9, R8 DSUB R2, R1, R9 DADD R3, R1, R2
f = fetch d = instruction decode / read registers x = execute / compute effective address m = memory w = write back registers 1 1 1 1 1 1 2 3 4 5 6 7 8 9 0 1 2 3 4 L R9, 0(R5) f d x m w DADD R1, R9, R8 f d s s x m w DSUB R2, R1, R9 f s s d s s x m w DADD R3, R1, R2 f s s s s d s s x m w 14 cycles
1 2 3 4 5 6 7 8 9 L R9, 0(R5) f d x m w DADD R1, R9, R8 f d x s m w DSUB R2, R1, R9 f d s x m w DADD R3, R1, R2 f s d x m w 9 cycles
Let's first figure out how many set index bits there are: log2 256 = 8 set index bits Now we can figure out how many offset bits there are: 32 bits total - (19 tag bits + 8 index bits) = 5 offset bits Now we know how many bytes per block there are: 25 = 32 bytes per block
Let's first figure out how many blocks there are: 64KB = 65536 bytes / 32 bytes per block = 2048 blocks Now we can figure out how many blocks per set there are: 2048 blocks / 256 sets = 8 blocks per set
In binary, this number is: 00010010001101000101011001111000 Let's separate this number into the 5-bit offset, 8-bit set index, and 19-bit tag: tag=[0001001000110100010], index=[10110011], offset=[11000] So the tag is 1001000110100010 in binary, or 91a2 in hex, or 37282 in decimal. Can we do this without converting to binary? Yes: divide the address by the number of sets times the number of bytes per block, i.e. 0x12345678 / (32 * 256) = 37282.