Single-cycle Datapath and pipelining Flashcards

1
Q

What are the 5 steps in the datapath when executing an instruction?

A

1.
Use PC to fetch instruction from instruction memory.
Next PC is also computed as either (PC + 4) or target address

2.
Grab registers from instruction and accesses the register file to read registers that needs to be read

  1. Instruction is executed.
    ALI (arithmetic result, calculate address for load/store, calculate target of branch address)

4.
Access memory (if necessary)

5.
Write result to register file (if there is a result)

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

What are multiplexers used for?

A

Can’t join wires together, so combine multiplexers with control signals to determine which input is used

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

What logical value does Low voltage/ground have?

A

0

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

How many bits are there per wire?

A

One bit per wire

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

How are multi-bit data encoded?

A

On multi-wire buses

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

What are to types of circuit elements used in creating a data path

A

Combinational element
State (sequential) element

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

What is an combinational element?

A

Operate on data
The output is a function of input.

AND, Adder, Multiplexer, ALU

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

What is an state (sequential) element?

A

Stores data
Basic unit is a flip flop.
Stores values on its input, and does it on the rising edge of the clock.

It is common to assemble flip flops into registers to be able to store multibit values that has something to do with each other

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

What does an adder do?

A

Binary addition of two binary numbers

Y = A + B

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

How does a multiplexer compute its outout?

A

Y = S ? I1 : I0

I1: Input 1
I0: Input 0
S: Selector signal

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

What is a critical path?

A

The worst case latency between two state elements.
The latency the signal must traverse within a clock cycle.

Avoids for example storing values before the input is comletely ready.

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

What is the data path?

A

Elements that process data and addresses in the CPU (Registers, ALUs, mux’s, memories)

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

How are instructions fetched using a PC?

A

PC is a 32-bit register (addresses are 32 bit)

Output of PC is addresses in instruction memory

PC output are used to fetch instruction from instruction memory

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

What happens in parallell during instruction fetch

A

While the PC is used to fetch the instruction from instruction memory,

The current PC is incremented by 4 to get the address of the next instruction.

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

How are ALU instructions executed?

A
  1. Need to read 2 register operands
  2. Perform the operation
  3. Write result

Components: Register file, ALU

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

What are the components of a register file?

A

2 read ports:
- both 5 bit wide (instruction format have 5 bits for specifying registers)

2 output (ports?) that go into the input of ALU

write input port: write registers

write data input port: to write data

RegWrite signal: Makes sure we don’t write register unless we need to.

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

What are the components of the ALU?

A

Two inputs

Input signal: Tells which operation to perform (4 bit gives 16 possible ops, dependent on architecture)

Results

Zero bit: Not used for arithmetic, but for branching

19
Q

What is needed to be able to execute load/store instructions?

A
  1. Read register operands

2.
Calculate address (ALU): Need to sign extend the offset because it is not the full 32 bit (is an immediate supplied in the instruction)

3.
Finish instruction by providing address and the write data (on stores), or grab data (on loads).

2 signals:
MEMRead signal: Tell that we need to read.

MemWrite: tell we need to write

20
Q

What is needed to support branch instructions?

A

1.
Read register operands (register file)

  1. Compare operands (ALU)

3.
Calculate target address
- sign-extend displacement
- Shift left 2 places (because we know we are branching to a 32 bit value)
- Add to PC + 4

21
Q

How to decide if we should branch

A

Take values from register and send them to ALU.
Provide ALU with operation signal for subtract.
If result of subtraction is zero, they are equal and we should branch.

22
Q

What is a single-cycle architecture

A

An architecture where all of the stages in the datapath is executed within one clock cycle

23
Q

In a MIPS datapath, what are the ALU used for

A

Load/store: function signal ‘add’

Branch: function signal ‘sub’

R-type: function depends of funct field in instruction

24
Q

What is the ALUOp control signal?

A

Come from main control unit, derived it from opcode.

00: load or store
01: Branch equal
10: R-types

ALU control is set based on ALUOp and funct.
For 00 and 01, it doesn’t matter what the funct field is.

For R-types (add, sub, and, or), the funct field are as defined in instruction

25
Q

What is the main control unit?

A

Based on the principle that all control signals are derived from instruction.

Need to select appropriate part of instruction and add them to correct place.

26
Q

What are examples of control signals

A

Multiplexer selection, ALUOp, etc.

27
Q

What are the three instruction types

A

Branch, load/store, R-type

28
Q
A
29
Q

Explain what happens when an R-type instruction is passed executed (ex.ADD).

A

PC -> Instruction memory -> Instruction

PC is incremented by 4

Opcode sent to control unit

2 registers being read

1 destination register, based on opcode know this is and R-type instruction, use multiplexer to set write to 1

immediate bits are not used in this case

funct bits are sent to ALU control

ALUOp is set in the main control unit

combine ALUOp with funct to get correct operation in ALU

In control unit, set ALUSrc so that registers are used as input to ALU.

Control unit disable MemRead and MemWrite

ALU output uses multiplexer to bypass memory - no load/store

Provide output to writeData in register file

RegWrite is set in control unit

30
Q
A
31
Q

What are some issues with a single cycle processor?

A

Longest delay determines clock period (critical path = load)

No way to vary period of different instructions as all take the same amount of time. Violates the design principle of “Making the common case fast”

32
Q

What is pipelining?

A

Overlap execution of multiple instructions.

Partition instruction into n stages. Needs pipeline registers to be able to do this. Uses these registers as input to next stage, so that a new instruction can start execution completely independently.

33
Q

Describe the RISC-V datapath including pipeline registers

A

PC goes to instruction memory.

Put instruction into pipeline register

Decode instruction and go to registers. Output of registers is stored in pipline registers.

Execute ALU and branching and store all of the results in pipeline registers.

At memory stage, write to normal registers happen.

34
Q

Name some pipeline stages

A

IP: Instruction fetch

ID: Instruction decode

EX: Execute, treats ALU, load and branch instructions differently. Branch is completed after EX stage

MEM: Memory

WB: Write back

35
Q

What are the three types of dependencies?

A

Data dependences through memory
data dependences through registers
control dependences

36
Q

What is a hazard?

A

Not respecting a program dependence.
This result in wrongful program execution.

37
Q

Name the three data dependences

A

Real dependence: read-after-write (RAW)

Anti dependence: write-after-read (WAR), use data as input in one instruction and then it gets overwritten in the next.

Output dependence: write-after-write (WAW), write to same register

38
Q

What does it mean to stall a pipeline?

A

Instruction stalls (does not progress to next stage) until required data is made available (dependency is satisfies).

39
Q

What is forwarding?

A

Mitigates data dependences without the need to stall.

Result-data is forwarded to previous stages the next cycles, making it available to instructions before the results are written back to registers.

The instructions in the different stages will check where the most updated data comes from, and chooses this as source for the operation

40
Q

What type of hazard can happen due to a control dependence?

A

When branching, might not know what the next instruction will be before the branch-criteria is fulfilled.

41
Q

What is one sollution to control hazards?

A

Branch predition and speculative execution. If prediction was wrong - flush out instructions along the wrong execution path.

42
Q

What happens when a branch is mispredicted.

A

Pipeline starts executing instruction on predicted path.

When first instruction reaches MEM stage - finds out path is incorrect.

needs to flush pipeline and make sure there are no architectural consequences. reset pipeline registers and then fetch instruction of the correct path.

43
Q

What happens when you have deeper pipelines

A

Higher clock frequency

But higher cost due to mispredictions -> higher CPI

Power consumption increases with frequency - also a cost with deeper pipelines.