(1) (5pt) Please indicate all the potential hazards in the following instruction sequence ?
(2) (5pt)What is the total execution cycles of the above instruction sequence running on processor 1 ?
(3) (5pt)Assume there is a 5-stage pipline processor 2 with two forwarding:
What is the total execution cycles of the above instruction sequence running on processor 2 ?
(1) (3pt) What is the bit width for byte offset?
(2) (3pt) What is the bit width of index?
(3) (3pt) What is the bit width for tag?
(4) (3pt) What is the cache entry size (bits)?
(5) (18pt) Starting from power on, the following byte-addressed cache references are recorded.
0, 128, 4, 32, 2180, 140, 180, 232, 2020, 132
5.1 (6pt) How many blocks are replaced?
address | index | Hit | Replace |
---|---|---|---|
0 | 000 | Miss | |
128 | 100 | Miss | |
4 | 000 | Hit | |
32 | 001 | Miss | |
2180 | 100 | Miss | R |
140 | 100 | Miss | R |
180 | 101 | Miss | |
232 | 111 | Miss | |
2020 | 111 | Miss | R |
132 | 100 | Hit |
5.2 (6pt) What is the cache miss rate?
5.3 (6pt) Assume there is a CPU with 1ns clock cycle, cache hit time = 1 cycle, cache miss penalty = 20 cycles, and its cache miss rate is equal to the answer of question 5.2. What is the Average Memory Access Time(AMAT) of this CPU?
(1) lw
(2) beq
(1) (5pt) Which type of forwarding line is missing?
(a) EX/MEM to EX
(b) MEM/WB to EX
(2) (10pt) Which code sequence(s) will still run correctly?
(a) add $s1, $t0, $t1
add $s3, $s2, $s1
add $s2, $s3, $s1
(b) add $s3, $t0, $t1
add $s1, $s2, $s1
add $s2, $s3, $s1
(c) add $s1, $t0, $t1
add $s1, $s2, $s1
add $s2, $s3, $s1
(d) add $s1, $t0, $t1
add $s2, $s2, $s1
add $s2, $s3, $s1
Branch: T-T-N-T-N-N-T-N
(1) If the one-bit predictor is used, what is the predictions will be?
(2) If the two-bit predictor is used, what is the predictions will be?
(1) (5pt) The memory space available to a program is __ bytes.
(2) (5pt) The number of virtual pages is __.
(3) (5pt) The page size is __.
The function strdouble receives a null-terminated string as input, and writes a string where every letter is repeated two times. For example, if we called strdouble on the input string "Hello World!", we would get the output string "HHeelllloo WWoorrlldd!!!".
More specifically: strdouble has the following inputs: a0 stores a null-terminated string. It is guaranteed that the string is well-formatted. Let the string have strlen of n. a1 contains a pointer to a buffer of length at least 2 * n + 1 characters, potentially containing garbage data. You may assume that the buffer does not overlap with the string stored in a0.
strdouble outputs the following: a0 should return the pointer to the buffer we initially received in a1. The buffer should contain the string originally provided in a0, with every character doubled. Please complete the unfinished assembly to make the above work as expected. For full credit, you must follow proper calling convention.
(a) sll
(b) jr
© addi
(d) bne
(e) sub
(f) lw
(g) beq
Assume the following operation times for each major functional unit of a RISC-V processor that supports Load word (lw), Store word (sw), R-format (add,sub,and,or), and Branch (beq):
Assume that the multiplexors, control unit, PC accesses, and sign extension unit have no delay
(a) In the single-cycle model, how much time does each instruction take? briefly explain why.
(b) In the 5-stage pipeline model (i.e. IF/ID/EXE/MEM/WB), what is the execution time of the following code sequence?
Code sequence |
---|
lw x1, 100(x4) |
lw x2, 200(x4) |
lw x3, 400(x4) |
(a) 1150 ps, because the slowest instruction is Load word (lw), and Load word (lw) needs 300 + 150 + 250 +300 150 = 1150 ps
Instruction class | IF | ID | EXE | MEM | WB | Total time |
---|---|---|---|---|---|---|
Lw | 300 ps | 150 ps | 250 ps | 300 ps | 150 ps | 1150 ps |
Sw | 300 ps | 150 ps | 250 ps | 300 ps | 1000 ps | |
R-format | 300 ps | 150 ps | 250 ps | 150 ps | 850 ps | |
Branch | 300 ps | 150 ps | 250 ps | 700 ps |
(b) 300 ps * 7 = 2100 ps
Select the corresponding statement for the three hazards:
(a) Arising from the need to make a decision based on the results of one instruction while others are executing
(b) The pipeline must be stalled because one step must wait for another to complete
© The hardware cannot support the combination of instructions that we want to execute in the same clock cycle
Structural Hazard: ____
Data Hazard: ______
Control Hazard: ______
Structural Hazard: C
Data Hazard: B
Control Hazard: A