Winter 2025 • Department of Computer Science • Kalamazoo College
(If you want to write up your answers using Markdown, here is a Markdown template you can use.)
Consider the following program fragment. Assume that each instruction fetch takes 50 ns. How long would it take for this program fragment to run? You will need to read the code to know how many times the loop will be executed. (Assume there is no cache.)
112: addi $t0, $zero, 0 116: addi $t1, $zero, 100 120: loop: add $s0, $s0, $s1 124: addi $t0, $t0, 1 128: bne $t0, $t1, loop
v
column indicates whether the line
contains valid (meaningful) data for this program, or just left-over
garbage.)
v | Tag | Instruction in Cache (4 bytes) | |
---|---|---|---|
00 | 1 (Yes) | 0000 ... 0111 | addi $t0, $zero, 0 (but in binary) |
01 | 0 (No) | ||
10 | 0 | ||
11 | 0 |
112: addi $t0, $zero, 0 116: addi $t1, $zero, 100 120: loop: add $s0, $s0, $s1 124: addi $t0, $t0, 1 128: bne $t0, $t1, loop
v
is 0 for every line.)
What would be the final contents of the cache?
v | Tag | Data in Cache (2 bytes) | |
---|---|---|---|
000 | |||
001 | |||
010 | |||
011 | |||
100 | |||
101 | |||
110 | |||
111 |
Requested Address | Data at Address (in hex) | Hit/Miss? |
---|---|---|
00000000 00000000 | 00 00 | |
00000000 00101110 | 00 0F | |
00000000 00101010 | C0 03 | |
00000000 01011010 | F0 00 | |
00000000 01011110 | FF FF |
v | Tag | Data in Cache | ||||
---|---|---|---|---|---|---|
00 | ||||||
01 | ||||||
10 | ||||||
11 |
Requested Address | Data at Address | Hit/Miss? |
---|---|---|
00000000 00000000 | 0000 | |
00000000 00101110 | 000F | |
00000000 00101010 | C003 | |
00000000 01011010 | F000 | |
00000000 01011110 | FFFF |
v | Tag | Data in Cache | |
---|---|---|---|
00 | |||
01 | |||
10 | |||
11 | |||
v | Tag | Data in Cache | |
---|---|---|---|
v | Tag | Data in Cache | |
---|---|---|---|
0 | |||
1 | |||