Exceptions; Introduction to Pipelining
Tom Kelliher, CS 220
Nov. 14, 2007
Homework due, exam Friday.
Read 6.2.
Controlling the multi-cycle implementation.
- Exceptions, syscalls, and interrupts.
- Introduction to pipelining; comparison with single-cycle
implementation.
Pipelined datapath.
- Exception examples:
- Divide-by-zero.
- Privileged instruction.
- Memory protection.
- Hardware faults.
What action should be taken? Can the hardware carry it out?
- Software interrupts (syscalls):
- Used to make transition from user mode to kernel mode.
- Interrupts are a mechanism allowing a CPU to ``disconnect'' from
active I/O devices to continue doing useful work.
- CPU much faster than most I/O devices.
- Polling wastes CPU cycles if there's other work to be done --
multiprogrammed system.
Conceptually, how do interrupts work?
``Unplanned'' function calls setup by planned function calls (syscalls,
etc.).
Why does the kernel initiate the I/O operation?
Components of an interrupt system:
- Interrupt request line(s). Priorities, arbitration within level,
masking.
- Interrupt acknowledge line(s).
- Interrupt handlers (service routines).
- A mechanism for indicating what device interrupted and why.
The laundry analogy:
The five stage MIPS pipeline:
- Instruction fetch.
- Decode and read registers.
The consistent placement of the source registers permits this.
- Execute ALU operation or calculate an address.
- Access memory.
- Result write-back.
Assume:
- Memory access is 2 ns.
- ALU use is 2 ns.
- Register file access is 1 ns.
Instruction class times:
|
|
Instruction |
Register |
ALU |
Data |
Register |
Total |
|
Instruction Class |
fetch |
read |
operation |
access |
write |
time |
|
lw |
2 ns |
1 ns |
2 ns |
2 ns |
1 ns |
8 ns |
|
sw |
2 ns |
1 ns |
2 ns |
2 ns |
|
7 ns |
|
R-format |
2 ns |
1 ns |
2 ns |
|
1 ns |
6 ns |
|
beq |
2 ns |
1 ns |
2 ns |
|
|
5 ns |
Clock periods for the two implementations?
Execution example:
Note that pipelined register file reads are done during the second half of
the clock cycle and writes are done during the first half. Why?
Consider the speedup:
- Assumption: Stages are of equal length. What if they aren't?
- Speedup is at most the number of pipeline stages.
Do we achieve that?
Consider the execution of 1,000 instructions and compute the actual
speedup.
What happened? The cost of the pipeline registers.
Consider:
- How does the speedup occur?
- Shortened instruction execution time?
- Higher instruction bandwidth?
Thomas P. Kelliher
2007-11-12
Tom Kelliher