pipelining in computer architecture code example

Example 1: pipelining in computer architecture

Pipelining is a technique where multiple instructions are overlapped during execution. 
Pipeline is divided into stages and these stages are connected with one another to form a pipe like structure.

Example 2: pipelining in computer architecture

Stage 1 (Instruction Fetch)
In this stage the CPU reads instructions from the address in the memory whose value is present in the program counter.
Stage 2 (Instruction Decode)
In this stage, instruction is decoded and the register file is accessed to get the values from the registers used in the instruction.
Stage 3 (Instruction Execute)
In this stage, ALU operations are performed.
Stage 4 (Memory Access)
In this stage, memory operands are read and written from/to the memory that is present in the instruction.
Stage 5 (Write Back)
In this stage, computed/fetched value is written back to the register present in the instructions.