Wednesday, 6 December 2017

microprocessor - Stalling and Flushing in MIPS Piplining



I am learning MIPS data path with piplining and I am a little confused in the following two things?


How do we perform Stall in MIPS data path?


What is the difference between Stall and Flush?


Here is the data path:


enter image description here



Answer



A pipeline "stall" simply means that the values flowing through the pipeline are not valid, because the current operation needs a data value that is still propogating through the pipeline. This is normally implemented by a special bit that flows through the pipeline along with the rest of the control fields that inhibits updating any permanent state (register and memory write operations). The control logic at the head of the pipeline recognizes when these data dependencies occur, and sets/resets that bit accordingly, and repeats the same operation when/until the required data is available.


The forwarding logic can eliminate many potential stalls by "short circuiting" the normal pipeline delays and providing results from within the pipeline at the point where they're needed.


A pipeline "flush" is required whenever global state information needs to be changed that will affect the processing of all instructions. You can think of it as a stall that lasts for the full depth of the pipeline. All pending operations are completed before any new operations are launched into the pipeline. "Global state" would include things like the program counter or cache/MMU settings.


One significant cause of a pipeline flush is any conditional branch. Until the control logic knows which way the branch is going to go, no new instructions can be processed. Many methods have been invented to mitigate the effects of conditional branches, including "branch delay slots" that are filled with instructions that get executed regardless of the branch direction and "speculative execution" that executes instructions on one or both of the potential branch paths (sometimes combined with "branch prediction" logic), with the results later discarded for the path not taken.



Sometimes, no hardware support for data dependencies is implemented at all, and the burden is entirely on the compiler to schedule operations, inserting NOPs where necessary, to avoid them. Interestingly, this was the approach used by the first versions of the MIPS architecture, but later implementations have introduced hardware support.


No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...