Home › Practice › RTL Design › Pipeline register: stall and flush
Pipeline register: stall and flush
EasyRTLsequentialarchitecture
In a pipelined processor, an instruction moves from stage to stage through registers. Sometimes a stage must wait, and sometimes the instruction in it turns out to be wrong and must be thrown away.
Concept first. A pipeline splits the work on an instruction into stages with a register between each pair. A stall means the stage must wait: its register holds its value instead of loading the new one. A flush means the instruction in the register is wrong (for example it came after a mispredicted branch) and must become a bubble, a do-nothing slot, by clearing its valid bit. Each register carries a valid bit next to the data so later stages know whether the slot holds a real instruction. If a stall and a flush arrive in the same cycle, think about which one should win: is it useful to keep a wrong instruction?
What to build.
- Ports:
clk, rst, d[7:0], vin, stall, flush; outputsq[7:0]andvout. rst(synchronous, active-high) orflush: on a rising edge,qbecomes 0 andvoutbecomes 0.- Otherwise, with
stall = 1: both hold. - Otherwise:
qloadsdandvoutloadsvin.
No install and no sign-up needed. You write your answer in the editor and Nishkam checks it.