Chapter 4 - COMPSCI 2GA3

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/139

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

140 Terms

1
New cards

What does a 2-input multiplexer do?

It selects one of two inputs based on a control signal: if s=0, output is x1

2
New cards

What is the main difference between combinational and sequential logic?

Combinational logic has no memory and output depends only on current inputs, while sequential logic includes memory and output depends on input history.

3
New cards

What is the function of a tri-state buffer when e=0?

The output is electrically disconnected from the input.

4
New cards

What basic element stores data in registers?

A D flip-flop stores a single bit of data and is the basic building block of a register.

5
New cards

What happens in a positive edge-triggered D flip-flop on a rising clock edge?

The value at the D input is stored and appears at the Q output after a delay.

6
New cards

How many D flip-flops are needed for an 8-bit register?

Eight D flip-flops are needed, one for each bit.

7
New cards

Why are tri-state buffers used with registers?

They allow multiple registers to share a data bus without conflict, as only one can enable output at a time.

8
New cards

What does the program counter (PC) do in instruction execution?

It points to the next instruction and is updated after each instruction is fetched.

9
New cards

What are the three types of RISC-V instructions discussed?

Arithmetic/logical (add, sub, and, or), memory reference (lw, sw), and control transfer (beq).

10
New cards

What is the purpose of multiplexers in a CPU datapath?

To select between multiple data sources for different instruction types.

11
New cards

What are the five stages of the RISC-V pipeline?

IF (Instruction Fetch), ID (Instruction Decode), EX (Execute), MEM (Memory Access), WB (Write Back).

12
New cards

What are structural, data, and control hazards in pipelining?

Structural: resource conflict, Data: dependency on previous instruction data, Control: uncertainty in control flow like branches.

13
New cards

What does forwarding (bypassing) in pipelining achieve?

It reduces stalls by using computed values directly instead of waiting for register write-back.

14
New cards

When can a load-use hazard not be avoided with forwarding?

When the required data from a load instruction is not yet available for the next instruction.

15
New cards

What is a pipeline "bubble"?

A cycle in which no useful work is done, usually due to a stall.

16
New cards

What is branch prediction and why is it important?

It predicts the outcome of branches to avoid pipeline stalls

17
New cards

What is dynamic branch prediction?

Hardware records actual branch history and predicts future behavior based on that history.

18
New cards

What is the purpose of the ALU control unit?

It determines the function the ALU performs based on instruction type and opcode.

19
New cards

What causes a control hazard?

A change in instruction flow, such as a branch, whose outcome is not yet known.

20
New cards

What is the function of the Main Control Unit in a CPU?

It generates control signals based on instruction opcodes to direct datapath behavior.

21
New cards

What is the critical path in a CPU?

The longest path that determines the minimum possible clock period, often through load instructions.

22
New cards

What is instruction-level parallelism (ILP)?

The ability to execute multiple instructions simultaneously to improve performance.

23
New cards

What is static multiple issue?

The compiler determines instruction groups to be issued together, minimizing hazards.

24
New cards

What is dynamic multiple issue (superscalar)?

The CPU dynamically selects and issues multiple instructions per cycle, resolving hazards at runtime.

25
New cards

What does register renaming help with?

It avoids data hazards by ensuring that different instructions using the same register name do not conflict.

26
New cards
27
New cards
What is speculative execution?
It executes instructions before it's certain they are needed, rolling back if the speculation is wrong.
28
New cards
How do you handle exceptions in a pipelined processor?
Flush the pipeline, save the PC and cause in SEPC and SCAUSE, and transfer control to an exception handler.
29
New cards
What does SEPC register store?
The program counter of the instruction that caused the exception.
30
New cards
What is SCAUSE in RISC-V?
A register that stores the reason or code for the exception or interrupt.
31
New cards
What happens during a BEQ instruction?
Registers are compared, and the PC is conditionally updated based on the result and offset.
32
New cards
What causes a stall on a branch?
Waiting for the branch decision before fetching the next instruction.
33
New cards
What is the role of pipeline registers?
They hold information passed between pipeline stages during each clock cycle.
34
New cards
What does a 2-bit branch predictor improve over 1-bit?
It avoids misprediction in nested loops by requiring two consecutive incorrect predictions to change direction.
35
New cards
What is a branch target buffer (BTB)?
A cache of branch target addresses used to fetch branch targets quickly.
36
New cards
What is the use of vectored interrupts?
They use different addresses for handlers based on the exception cause, reducing handler overhead.
37
New cards
What is a precise exception?
An exception that can be handled such that the program can be restarted correctly from the point it occurred.
38
New cards
What happens if multiple exceptions occur in a pipeline?
The earliest instruction’s exception is handled, and subsequent instructions are flushed.
39
New cards
What is the purpose of a reservation station in register renaming?
To temporarily hold operands and tags until an instruction is ready to execute.
40
New cards
What is the function of the reorder buffer (ROB)?
It ensures instructions commit in the correct order and handles register renaming results.
41
New cards
What is load speculation?
It predicts memory load values or addresses to execute loads early, rolling back if incorrect.
42
New cards
What is the key idea behind dynamic pipeline scheduling?
Instructions can execute out-of-order to avoid stalls but must commit results in order.
43
New cards
What is loop unrolling?
A compiler technique that replicates loop bodies to expose more instruction-level parallelism.
44
New cards
What are the advantages of dual-issue static scheduling?
Allows two instructions to be issued per cycle, improving throughput with careful hazard management.
45
New cards
Why do superscalar processors improve performance?
They issue and execute multiple instructions per cycle using dynamic scheduling and speculation.
46
New cards
What causes power inefficiency in advanced CPUs?
Complex techniques like speculation and dynamic scheduling increase power usage.
47
New cards
What is a power-efficient alternative to deep pipelines?
Using multiple simpler cores instead of complex single-core designs.
48
New cards
What is the role of the instruction decoder?
It interprets the fetched instruction and sets control signals for execution.
49
New cards
Why is it important to balance pipeline stages?
To maximize throughput and prevent slow stages from becoming bottlenecks.
50
New cards
How is speedup from pipelining calculated?
Speedup = Time between instructions (unpipelined) / Time between instructions (pipelined).
51
New cards
Why do all RISC-V instructions have the same length?
To simplify instruction fetching and decoding, aiding pipelining.
52
New cards
What is the main idea of forwarding in a pipelined processor?
To use computed values immediately from intermediate pipeline stages instead of waiting for write-back.
53
New cards
What are ForwardA and ForwardB signals used for?
To control multiplexers that select ALU input sources to resolve data hazards via forwarding.
54
New cards
What does a forwarding condition of ForwardA=10 mean?
The first ALU operand should come from the EX/MEM pipeline stage.
55
New cards
How do you detect a load-use data hazard?
By checking if the ID/EX.MemRead is set and if its destination register matches the source registers in the next instruction.
56
New cards
What happens when a load-use hazard is detected?
The pipeline is stalled, a bubble is inserted, and instruction fetch is repeated.
57
New cards
What is the purpose of stalling the pipeline?
To delay execution until data hazards or control decisions are resolved, ensuring correct operation.
58
New cards
What are the inputs of the ALU control function?
Opcode fields such as ALUOp, function7, and function3 determine the ALU operation.
59
New cards
Why can't wires in the datapath be joined freely?
It causes data conflicts
60
New cards
What is the main use of the MEM/WB pipeline register?
To store results from memory or ALU before they are written back to the register file.
61
New cards
What does an edge-triggered state element do?
It updates stored data only on a rising or falling edge of the clock.
62
New cards
How does a register with write control work?
It only updates its stored value on a clock edge if the write enable signal is active.
63
New cards
What is the significance of cycle time in pipeline performance?
Shorter cycle time allows faster instruction execution
64
New cards
What is the function of the datapath in the CPU?
To process and move data through units like ALU, registers, and memory.
65
New cards
How is ALU control derived for R-type instructions?
By decoding both function3 and function7 fields in conjunction with ALUOp.
66
New cards
Why is memory separated in pipelined processors?
To avoid structural hazards by allowing simultaneous instruction fetch and data access.
67
New cards
What does an instruction fetch stage do?
Retrieves the instruction pointed to by the program counter (PC).
68
New cards
What happens in the decode stage (ID)?
Registers are read and the instruction type is determined by the control unit.
69
New cards
What is the function of the execute stage (EX)?
Performs arithmetic or address calculations using the ALU.
70
New cards
What is the role of the memory stage (MEM)?
Performs memory access operations like load and store.
71
New cards
What is the purpose of the write-back stage (WB)?
Writes the result of an instruction back into the register file.
72
New cards
What is the hazard if a needed register value is not yet written?
A data hazard, which may require forwarding or stalling.
73
New cards
What is the function of the control unit in pipelining?
Generates appropriate control signals for each pipeline stage based on instruction type.
74
New cards
How are pipeline stages isolated from one another?
By inserting pipeline registers between them to store intermediate data.
75
New cards
Why is it important for the D input to remain stable around the clock edge in a flip-flop?
To ensure correct data is stored and avoid metastability.
76
New cards
Why are enable signals used in flip-flops and registers?
To control when the register should accept and store new data.
77
New cards
What is the purpose of a multiplexer (MUX) in the datapath?
It selects one of multiple inputs to pass through to the output based on control signals.
78
New cards
How is the branch target address calculated in BEQ instructions?
By sign-extending the displacement, shifting left by one, and adding to the current PC.
79
New cards
What does Zero output from ALU indicate in a BEQ?
That the two compared registers are equal, which may trigger a branch.
80
New cards
Why can't a value be forwarded backward in time?
Because the needed value hasn’t been computed yet, such as in a load-use hazard.
81
New cards
What is early restart in cache miss handling?
The CPU restarts execution before the entire block is loaded, using the first available word.
82
New cards
Why do we need separate instruction and data memories in pipelining?
To allow concurrent access and avoid structural hazards.
83
New cards
What happens in a pipelined R-type instruction execution?
Registers are read, ALU performs computation, and result is written back in 5 stages.
84
New cards
What are pipeline bubbles used for?
To handle hazards by inserting idle cycles into the pipeline.
85
New cards
What does critical-word-first mean?
Load the word needed by the CPU first during a memory block fetch.
86
New cards
What is the goal of Instruction-Level Parallelism (ILP)?
To increase CPU throughput by executing multiple instructions simultaneously.
87
New cards
What does the MEM/WB.RegWrite signal control?
Whether the register file will be updated with the result in the write-back stage.
88
New cards
How are exceptions handled in the pipeline?
Flush instructions, save PC and cause, then jump to exception handler.
89
New cards
Why are imprecise exceptions hard to handle?
They don’t preserve the exact point of failure, making it harder to recover or restart.
90
New cards
What is dynamic scheduling in CPU?
Out-of-order execution of instructions to improve throughput while maintaining correct final state.
91
New cards
Why is latency not reduced by pipelining?
Each instruction still takes the same total time to complete
92
New cards
How is a data hazard from a register write handled in a pipeline?
By forwarding the result or stalling until the write is completed.
93
New cards
What is the speedup of a pipeline with balanced stages?
The speedup approaches the number of pipeline stages.
94
New cards
What is a superscalar processor?
A CPU that can issue and execute multiple instructions per clock cycle.
95
New cards
What makes multiple-issue CPUs more complex?
Hazard detection, instruction scheduling, and power requirements increase significantly.
96
New cards
What is the impact of pipeline hazards on performance?
They introduce stalls and reduce effective instruction throughput.
97
New cards
How does a compiler reduce pipeline stalls?
By reordering instructions to avoid hazards (code scheduling).
98
New cards
What are the benefits of register renaming?
Eliminates false dependencies and increases parallel execution opportunities.
99
New cards
What does a stall do to the PC and IF/ID registers?
It prevents them from updating, effectively pausing the pipeline.
100
New cards
What is the goal of the pipelined datapath design?
To improve instruction throughput by overlapping stages of multiple instructions.