Processor Pipelines Flashcards

1
Q

Draw the CPU overview focusing on the data path

A

.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

? between stages keep the processes in different stages

A

Registers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How is the address for the memory access generated?

A

From rs1 and immediate

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Which register holds data for the store?

A

rs2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Why is it quicker to do things later and then decide if we need the result?

A

Because hardware is parallel

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Add control logic to the data path diagram

A

.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does the branch unit do?

A

Generates next PC value. If there is no branching just adds 4 to PC

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does the mux after register file access do?

A

Selects either immediate or rf[rs2] as the second operator

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Why do we need a jump and link instruction?

A

Because we can’t specify a 32 bit immediate and instruction in 32 bits

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How does a store instruction work?

A

Starts out like an I-type instruction and does the address calculations: read register operands, calculate address rf[rs1] + sign_extended_immediate
Write register rf[rs2] value to this location in memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How does a load instruction work?

A

Starts out like an I-type instruction and does the address calculations: read register operands, calculate address rf[rs1] + sign_extended_immediate
Read memory and update destination register rf[rd]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Draw the part of the data path corresponding to load/store instructions

A

.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Draw the part of the data path corresponding to R-type instructions

A

.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Draw the part of the data path corresponding to I-type instructions

A

.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What happens with branch instructions?

A
  1. Read register operands
  2. Compare operands
    Use ALU, subtract and check outputs
  3. Calculate target address
    Sign-extend displacement, shift left 1 place, add to PC value
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the data path?

A

Made up of elements that process data and addresses. Data flows through this path, with some of the data coming from the instruction. Fixed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the control path?

A

Control path signals are determined by the instruction and other microarchitectural state (eg. result of ALU operation is zero or negative). Determines how each part of ther data path is used to perform each instruction

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Highlight the influence of control for R-type instructions on the data and control path diagram

A

.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Highlight the influence of control for I-type arithmetic instructions on the data and control path diagram

A

.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Highlight the influence of control for I-type load instructions on the data and control path diagram

A

.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Highlight the influence of control for S-type store instructions on the data and control path diagram

A

.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Highlight the influence of control for B-type instructions on the data and control path diagram

A

.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

List 3 performance issues with with the processor pipeline

A
  1. Longest delay determines clock period
    Critical path = load instruction
    Instruction memory -> register file -> ALU -> data memory -> register file
  2. Not feasible to very period for different instructions
  3. Violates the design principle of making the common case fast
23
Q

What is the critical path through the processor pipeline?

A

Load instruction
Instruction memory -> register file -> ALU -> data memory -> register file

24
Why do we need pipelining?
To overcome the 3 performance issues with the processor pipeline
25
If we execute 1 instruction every x seconds, what improvement do we get if we use pipelining?
1 instruction every x/s seconds s = number of seconds
26
List the 5 stages of the RISC-V processor pipeline
1. IF: instruction fetch 2. ID: instruction decode 3. EX: execute operation 4. MEM: memory access 5. WB: write back result to register
27
What type of pipeline is the RISC-V pipeline?
Scalar pipeline Simple linear pipeline that fetches one instruction at a time and sends it down the pipeline to be executed
28
How can we know we will always read updated data?
Can write registers in the first half of the clock cycle and read registers in the second half
29
Draw a diagram of program execution order against time to show how pipelining improves performance for these instructions: ld x1, 100(x4) ld x2, 200(x4) ld x3, 300(x4)
.
30
Assuming stages are balanced, give the equation for pipeline speedup
Time between instructions pipelined = time between instructions non-pipelined/number of stages So the speedup is near linear if the pipeline doesn't stall
31
If stages are not balanced, is speedup more or less?
Less
32
Does pipelining affect latency?
No, it does not decrease latency. Speedup is due to increased throughput
33
What is latency?
Time for each instruction
34
In which 3 ways is RISC-V ISA designed for pipelining?
1. All instructions are 32 bits Easier to fetch and decode in one cycle 2. Few and regular instruction formats Can decode and read registers in one step 3. Load/store addressing Can calculate address in 3rd stage, access memory in 4th stage
35
List the 3 types of hazard
1. Structural hazard 2. Data hazard 3. Control hazard
36
What is a hazard?
Situations that prevent starting the next instruction in the next cycle
37
What is a structural hazard?
A required resource is busy This is a problem in a pipeline with a single memory. Load/store requires memory access, so does instruction fetch so it would have to stall for that cycle causing a pipeline bubble
38
Give an example of a structural hazard
Can't do fetch and memory access at the same time in 1 memory
39
How can we overcome structural hazards?
Pipelined paths need separate instructions/data memories so use separate instruction and data caches
40
What is a data hazard?
An instruction depends on completion of data read/write by a previous instruction, so has to wait until this instruction has written back
41
What is forwarding/bypassing?
Don't wait for result to be written back to the register file, use result when it is computed. Forwarded from write back directly to execute (back to the ALU)
42
What is a load-use data hazard?
Stalls cannot always be avoided by forwarding, if the value hasn't been computed when needed Eg. load instruction need to load from memory, so even with data forwarding the next instruction will need to stall for one clock cycle
43
Draw a diagram of program instruction order against time to show a load-use data hazard
.
44
How can load-use data hazards be overcome?
Using code scheduling. Reorder code to avoid use of load result in the next instruction
45
What is a control hazard?
Branch determines the flow of control. Fetching the next instruction depends on branch outcome so pipeline cannot always fetch the correct instruction because it is still working on ID stage of branch
46
When can unconditional jumps happen in a RISC-V pipeline?
ID stage
47
When can conditional branches happen in a RISC-V pipeline?
They are dependant on register comparisons typically done in the EX stage
48
What is an indirect jump and when can it be handled?
Jumps to an address in a register, handled in EX stage
49
What is a stall on branch?
Wait until branch outcome determined before fetching next instruction
50
Draw a diagram of program instruction order against time to show a stall on branch
.
51
What is branch prediction?
Predict the outcome of the branch. Only stall if prediction is wrong. If wrong, state must be cleaned up to preserve sequential execution model
52
State the 2 types of branch prediction
1. Static 2. Dynamic
53
Why do we need branch prediction?
To stall on branch in longer pipelines causes an unacceptable stall penalty
54
What is static branch prediction? Give an example
Based on typical branch prediction Eg. Loop and if statement branches which predict backwards branches taken and forward branches not taken
55
What is dynamic branch prediction?
Hardware measures actual branch behaviour and assume future behaviour will continue the trend