Pipelining

Instruction-level pipelining

Some CPUs perform instruction-level pipelining where they divide the [[FDE Cycle]] into smaller steps, and then execute these steps in parallel.\

Link to original

Consider an FDE cycle broken down into 6 stages:

  1. Fetch instruction
  2. Decode opcode
  3. Calculate effective address of operands
  4. Fetch operands
  5. Execute instruction
  6. Store result

These can be used in order in a six-stage pipeline. For every clock cycle, one small step is carried out and the stages are overlapped.

Theoretical Speed-up

The theoretical speed-up offered by a pipeline can be found as follows:

  • Each instruction represents a task, , in the pipeline.
  • Let be the number of tasks (instructions) in the program.
  • Let be the time per stage.
  • Let be the number of stages in the pipeline.
  • The first task requires time to complete.
  • The remaining tasks emerge from the pipeline one per cycle.
  • So the total time to complete the remaining tasks is .

The time to complete tasks using a -stage pipeline is:

To compute the speed gain, we compare with the time taken to run the same program without pipelining, the time taken to run one task without pipelining is , hence we can find the time to do tasks to be .

The fractional speed up is then given by:

If we take the limit as then . This results in a theoretical speedup of:

These equations assume that:

  • the architecture supports fetching instructions and data in parallel
  • the pipeline can be kept filled at all times

Pipeline hazards are thongs that can cause a pipeline to stall, or be flushed for any reason such as: Resource conflicts, data dependencies, or conditional branching.