changhengliou / ECE-6913

2 stars 1 forks source link

MIPS Pipeline #2

Open changhengliou opened 3 years ago

changhengliou commented 3 years ago

R type pipeline

Hazard: 1:25:30

Structure hazard

Data hazard

Solution:

Add-Add dependency

Add-Load dependency

Not working, because lw at execution stage is register address instead of register value. The only way to handle this is stall it.

changhengliou commented 3 years ago

Required control signal

Stall is a must when there is a dependency for lw and its next instruction

if (ID/EX.MemRead && // if at execution stage, the instruction is memory read; the only instruction is memRead is lw 
  ((ID/EX.RegisterRt == IF/ID.RegisterRs) || 
  (ID/EX.RegisterRt == IF/ID.RegisterRt))
)
  stall frontend and insert `NOP` in execution stage

Control hazard

We know branch is happened or not at the execution stage, which means intuitively, we have to stall 3 cycles.

Solution:

changhengliou commented 3 years ago

image

changhengliou commented 3 years ago

Branch Prediction