The pipeline controls its own stall and flush status, through specific stall and flush-related request signals. These requests are sent to the Stall and Flush Unit (SFU). The output of the SFU is a set of signals that directly control pipeline stages (a stall and flush control signals pair for each stage):
Requests to SFU
The SFU stalls all younger stages. However, by stalling-only, the current instruction is spawned into 2 instances. One of them must be killed (flushed). The the younger instance is killed (the previous stage is flushed).
Thus, a nop is introduced in the pipeline before the instruction wavefront.
If more than one stage request a stall at the same time, the older one has priority (the younger one will be stalled along with the others). Only after that, the younger one will be ackowledged its stall by means of appropriate stall and flush control signals.
The SFU simply flushes that stage.
More than one flush could be acknolewdged at the same time, without competition. However, all flush requests happen to request to flush the same pipeline stage, s2.
The SFU flushes stages s2...s5, because the corresponding instructions were already uselessly fetched, and requests the PC to be loaded with the branch relative jump address.
The SFU treats skips as branches that have the relative jump address equal to 0, 1 or 2, depending on the skip condition and on next instruction's length (16/32 bits).
The SFU stalls all younger instructions. The current instruction is spawned into 2 instances. The older instance is killed (the very same stage that requested the nop stage is flushed).
Thus, a nop is introduced in the pipeline after the instruction wavefront.
In order to do that, a micro-state machine is needed outside the pipeline, because otherwise that stage would undefinitely stall itself.
SFU control signals
Each main pipeline stage (s1-s6) has 2 kinds of control signals, that are generated by the SFU:
All registers in this stage are instructed to remain unchanged All possible requests to hardware resources (such as RF, IOF, BPU, DACU, SREG, etc) are reseted (to 0).
All registers in this stage are reseted (to 0), to a most "benign" state (a nop). Also, all requests to hardware resources are reseted.
Each main pipeline stage has an associated flag that determines whether or not that stage has the right to access hardware resources. These flags are also managed by the SFU.
Hardware resources enabling flags:
Generated on Tue Dec 31 20:26:31 2002 for Pipelined AVR microcontroller by
@Importing into repository the new directory structure.