Pipelining Updated
Pipelining Updated
Amudhan AN
Opcode (short for operation code) is a unique code that specifies the operation to be performed by
a computer's processor. It's essentially the instruction part of a machine language instruction.
For example, in the instruction "ADD A, B", "ADD" is the opcode, specifying the addition operation.
The registers "A" and "B" are the operands, the data on which the operation is performed.
Key points about opcodes:
•Unique Identifier: Each opcode corresponds to a specific operation.
•Binary Representation: Opcodes are typically represented in binary format.
•Part of Machine Language: They are the fundamental building blocks of machine language.
•Instruction Set Architecture: The set of opcodes supported by a processor is defined by its
instruction set architecture (ISA).
Example:
•Instruction: ADD R1, R2, R3
•Rs: Register R2
•Rt: Register R3
•Operation: Result = R2 + R3 (Value from R2 plus value from R3).
Example:
•Instruction: BEQ R1, R2, offset
•PC: 0x1000
•Immediate (offset): 0x0004
•Sign-Extended Immediate: 0x0004
•Shifted Immediate: 0x0004 << 2 = 0x0010
•Branch Address: PC + 0x0010 = 0x1010
Course Instructor : Amudhan AN 12
Memory
• Definition:
• The Memory Access (MEM) stage is used for load and store instructions
to access memory.
• Key Points:
• Load/Store Unit: Handles memory read or write operations.
• Data Memory: Reads or writes data from/to memory.
• Memory Address: The effective address is calculated and used.
• Operations:
1.Memory Read: Load the data from the calculated address.
2.Memory Write: Store the data to the calculated address
Course Instructor : Amudhan AN 13
Example:
• If Load instruction: Data = Memory[Address]
• If Store instruction: Memory[Address] = RtValue
• Instruction 2 (I2):
• Cycle 2: Fetch
• Cycle 3: Decode
• Cycle 4: Execute
In a program where the value calculated by I2 is needed before the execution of I1,
this order can lead to incorrect results.
Course Instructor : Amudhan AN 23
Handling Data Hazards:
• Forwarding (Bypassing):
• Uses hardware to pass the result of an instruction directly to a
subsequent instruction needing it, bypassing the normal write-back
stage.
• Control hazards, also known as branch hazards, occur when the pipeline
makes incorrect predictions about the flow of control instructions such a
s branches, jumps, and calls. These hazards can disrupt the flow of instru
ctions through the pipeline, leading to delays and inefficiencies.
2000 I1
2004 I2 BEQ Label
2008 I3
Jump case
1 2 3 4 5 6 7
I1 IF ID EX Mem Wb Ok
ID
I2 IF (PC:250) EX Mem Wb Ok
Prob based
Me on Previous
I3 IF ID Ex m WB decode stage
I4
BI1 IF ID
Course Instructor : Amudhan AN Ex Mem WB 29
Solution: Stall
1 2 3 4 5 6 7
I1 IF ID EX Mem Wb Ok
ID
I2 IF (PC:250) EX Mem Wb Ok
Till Decode
Introduc of previous
e delay - - - - - stage
I4
BI1 IF ID Ex Mem WB
1 2 3 4 5 6 7
I1 IF ID EX Mem Wb Ok
EX
I2 IF ID (PC:250) Mem Wb Ok
Prob based
Branch on on Previous
condition I3 IF ID Ex Mem WB decode stage
I4 IF ID Ex Mem WB
1 2 3 4 5 6
I1 IF(Mem) ID EX Mem Wb
I2 IF(Mem) ID EX Mem Wb
Wb
I3 IF(Mem) ID Ex Mem
During the full 100 instruction execution, each stage of the pipeline is actively used after
the pipeline is filled.
Utilization Calculation: After the pipeline is filled, all 5 stages are utilized for 96 cycles (5
cycles to fill + 95 more cycles).