Skip to content
Snippets Groups Projects
  • Geo Ster's avatar
    2f7596b8
    Handle branch delay slots · 2f7596b8
    Geo Ster authored
    * MIPS has an architectural feature, where instead of flushing the
    pipeline when executing a branch instruction, it goes ahead and executes
    the instruction following the branch as well. Flushing the pipeline
    is costly and is the cause of those complex branch predictors on
    modern CPUs that try to guess when a branch will be taken.
    
    * To properly emulate this behaviour we must act how the pipeline acts. We
    will always have 2 instructions loaded the current one and the next one. This way
    we can load the instruction after the branch even though the pc changes.
    2f7596b8
    History
    Handle branch delay slots
    Geo Ster authored
    * MIPS has an architectural feature, where instead of flushing the
    pipeline when executing a branch instruction, it goes ahead and executes
    the instruction following the branch as well. Flushing the pipeline
    is costly and is the cause of those complex branch predictors on
    modern CPUs that try to guess when a branch will be taken.
    
    * To properly emulate this behaviour we must act how the pipeline acts. We
    will always have 2 instructions loaded the current one and the next one. This way
    we can load the instruction after the branch even though the pc changes.