Pipelined Implementation

References

Outline

Computational Example

3-Way Pipelined Version

Limitations: Nonuniform Delays

Limitations: Register Overhead

Data Dependencies

Data Hazards

Data Dependencies in Processors

irmovq $50, %rax
addq %rax, %rbx
mrmovq 100(%rbx), %rdx

Sequential Hardware

Sequential Hardware
Sequential Hardware

Modified Sequential Hardware

Modified Sequential Hardware
Modified Sequential Hardware

Modified Sequential Hardware

Pipeline Stages

Pipelined Hardware

Pipelined Hardware
Pipelined Hardware

Pipelined Hardware

Feedback Paths

Predicting the PC

Pipeline Demonstration

Data Dependencies: 3 nop Instructions

Data Dependencies: 2 nop Instructions

Data Dependencies: 1 nop Instruction

Data Dependencies: No nop Instruction

Stalling for Data Dependencies

Stall Condition

Stall Example

What Happens When Stalling

Implementing Stalling

Data Forwarding

Data Forwarding Example

Data Forwarding Example

Forwarding Priority

Implementing Forwarding

Implementing Forwarding

Limitation of Forwarding

Avoiding Load/Use Hazard

Load/Use Hazard Implementation

Branch Misprediction Example

0x000:    xorq %rax, %rax
0x002:    jne t             # not taken
0x00b:    irmovq $1, %rax   # fall through
0x015:    nop
0x016:    nop
0x017:    nop
0x018:    halt
0x019: t: irmovq $3, %rdx   # target
0x023:    irmovq $4, %rcx   # should not execute
0x02d:    irmovq $5, %rdx   # should not execute

Handling Branch Misprediction

Branch Misprediction Implementation

Return Example

0x000:    irmovq Stack, %rsp   # intialize stack pointer
0x00a:    call p               # procedure call
0x013:    irmovq $5, %rsi      # return point
0x01d:    halt
0x020: .pos 0x20
0x020: p: irmovq $-1, %rdi     # procedure
0x02a:    ret
0x02b:    irmovq $1, %rax      # should not be executed
0x035:    irmovq $2, %rax      # should not be executed
0x03f:    irmovq $3, %rax      # should not be executed
0x049:    irmovq $4, %rax      # should not be executed
0x100: .pos 0x100
0x100: Stack:                  # Stack pointer

Correct Return Example

Return Implementation

Special Control Cases

Control Combinations

Handling Control Combinations

Pipeline Summary