
An out-of-order processor runs instructions as soon as their operands are ready, not in the order the program lists them. Yet the program must behave as if every instruction ran in order: registers and memory change in program order, and an exception stops the machine at exactly the faulting instruction, with everything before it done and nothing after it visible. The structure that makes this work is the reorder buffer, and at its heart it is a FIFO.
This is Part 38 of the FIFO Series. Part 37 built a completion FIFO that retires entries in order once they finish. A reorder buffer adds what a processor needs on top: several commits per cycle, an exception status per entry, and a flush that throws away every younger entry in one cycle. We build a small one, two commits wide, and check it against a program-order reference.
Key takeaways
- A reorder buffer is a FIFO in program order. Dispatch pushes at the tail, execution writes results by tag in any order, and commit pops from the head.
- Commit is the only point where architectural state changes. Everything before commit is speculative and can be discarded.
- Commit width is a chain: the second slot commits only if the first does, and both stop at the first entry that is not done or carries an exception.
- An exception is recorded at writeback but acted on only when the entry reaches the head. That is what makes exceptions precise.
- A flush resets the tail to the head and clears every done bit in one cycle. Stale writebacks for flushed entries must be killed in the same cycle, or they corrupt reused tags.
In this part
- What problem a reorder buffer solves
- The interface
- Micro-architecture: dispatch, writeback, commit, flush
- RTL sketch
- Corner cases
- Timing, area and power
- Verification checklist
- Interview questions
- Where it is used in real chips
- The rest of the series
What problem a reorder buffer solves
Out-of-order execution hides latency: while a load waits for memory, independent instructions behind it can run. Without a way to restore order, though, a later instruction could overwrite a register before an earlier one that faults, and the program state at the fault would match no point in the program. Software could not resume it, and a debugger could not explain it.
The reorder buffer separates finishing from committing. An instruction finishes when its result is computed and written into its ROB entry. It commits when it reaches the head of the ROB and every older instruction has committed. Only then does its result reach the architectural register file, and only then can a store be released to memory. If an instruction at the head has an exception, the processor discards it and everything younger, and redirects to the handler.
The interface

- Dispatch:
disp_validwith the destination register,disp_readywhen there is space, anddisp_tag, the ROB slot, which follows the instruction through execution. - Writeback:
wb_valid,wb_tag, the result value and an exception flag, in any order. - Commit: two slots,
cmt0andcmt1, each with a destination and a value for the register file. - Flush: a pulse with the tag of the excepting instruction, so the front end can redirect and the execution units can drop in-flight work.
Real cores dispatch and write back several instructions per cycle. One of each keeps the sketch readable; the commit side is two wide because that is where the interesting FIFO logic lives.
Micro-architecture: dispatch, writeback, commit, flush
The pointers are the read and write pointers of Part 1 with an extra wrap bit. Each entry holds a destination, a value, a done bit and an exception bit.
Dispatch pushes at the tail, records the destination and clears done. Writeback indexes the entry by tag, as in Part 37, stores the value and the exception flag, and sets done.
Commit looks at the two oldest entries. Slot 0 commits if the head is done without an exception. Slot 1 commits only if slot 0 commits and the second entry is also done without an exception. The read pointer advances by the number of commits. The chain matters: committing the second entry while the first is still waiting would break program order, which is exactly what the ROB exists to prevent.
An exception is just a flag in the entry until the entry becomes the head. If an older instruction is still waiting, the exception might never matter, because an older branch could turn out mispredicted or an older instruction could fault first. When the excepting entry reaches the head, the ROB raises flush: the write pointer jumps back to the read pointer, every done bit clears, and the excepting instruction and everything younger disappear in one cycle.

Notice that I4 in the picture is done and correct, yet it is flushed. A precise exception throws away finished work that is younger than the fault. That waste is the cost of a clean architectural state.
RTL sketch
module rob #(
parameter int DEPTH = 32, // power of two, at least 2
parameter int VW = 64, // result width
parameter int RW = 5, // destination register index
localparam int AW = $clog2(DEPTH)
) (
input logic clk,
input logic rst_n,
input logic disp_valid,
input logic [RW-1:0] disp_dest,
output logic disp_ready,
output logic [AW-1:0] disp_tag,
input logic wb_valid,
input logic [AW-1:0] wb_tag,
input logic [VW-1:0] wb_value,
input logic wb_exc,
output logic cmt0, cmt1,
output logic [RW-1:0] cmt_dest [2],
output logic [VW-1:0] cmt_value [2],
output logic flush,
output logic [AW-1:0] flush_tag
);
logic [RW-1:0] dest [DEPTH];
logic [VW-1:0] value [DEPTH];
logic [DEPTH-1:0] done, exc;
logic [AW:0] wptr, rptr;
wire [AW:0] count = wptr - rptr;
wire [AW-1:0] h0 = rptr[AW-1:0];
wire [AW-1:0] h1 = h0 + 1'b1;
wire [AW-1:0] widx = wptr[AW-1:0];
wire v0 = (count >= 1) && done[h0];
wire v1 = (count >= 2) && done[h1];
assign cmt0 = v0 && !exc[h0];
assign cmt1 = cmt0 && v1 && !exc[h1];
assign flush = v0 && exc[h0]; // precise: only at the head
assign flush_tag = h0;
assign cmt_dest = '{dest[h0], dest[h1]};
assign cmt_value = '{value[h0], value[h1]};
assign disp_ready = (count != DEPTH);
assign disp_tag = widx;
wire do_disp = disp_valid && disp_ready && !flush;
always_ff @(posedge clk or negedge rst_n)
if (!rst_n) begin
wptr <= '0;
rptr <= '0;
done <= '0;
end else if (flush) begin
wptr <= rptr; // drop the head and everything younger
done <= '0;
end else begin
rptr <= rptr + cmt0 + cmt1;
if (do_disp) wptr <= wptr + 1'b1;
if (cmt0) done[h0] <= 1'b0;
if (cmt1) done[h1] <= 1'b0;
if (do_disp) done[widx] <= 1'b0;
if (wb_valid) done[wb_tag] <= 1'b1;
end
always_ff @(posedge clk) begin
if (do_disp) dest[widx] <= disp_dest;
if (wb_valid && !flush) begin
value[wb_tag] <= wb_value;
exc[wb_tag] <= wb_exc;
end
end
endmodule
The sketch was checked with a cycle-accurate Python model against a program-order reference for 750,000 cycles at depths 2 to 32, with random writeback order and exception rates from none to one writeback in ten. Every commit matched the next instruction in program order with its value, and every flush happened exactly when an excepting instruction reached the head.
Corner cases
- Exception in the second commit slot. Slot 0 commits, slot 1 does not, and the flush happens next cycle when the excepting entry is the head. Flushing from slot 1 directly saves a cycle but adds a second flush source.
- Writeback in the flush cycle. It belongs to a flushed instruction, so it is ignored. Its done bit would otherwise survive the clear and make a future instruction in that slot look finished.
- Stale writebacks after the flush. The sketch assumes the execution units drop all in-flight work on
flush. If a long-latency unit cannot, tag each instruction with an epoch bit that flips on every flush, and ignore writebacks with the old epoch. - Full ROB with commits in the same cycle.
disp_readyuses the current count, so dispatch waits one cycle even when a commit frees a slot. Counting this cycle's commits recovers it at the cost of a longer path. - Interrupts. An external interrupt is usually taken at a commit boundary, by marking the head entry, which reuses the exception path.
Timing, area and power
- Commit chain. Each extra commit slot adds a done and exception check to the chain, and the read pointer increment becomes a small adder. Wider commit is usually built by reading a group of entries and computing a prefix of "can commit" bits.
- Read ports. Two commits need two reads per cycle from the value array, plus ports for writebacks. Many designs keep values in a physical register file and store only register mappings in the ROB, which shrinks it a lot.
- Flush. Resetting the tail is one register, but clearing every done bit is a wide reset that must meet timing in one cycle. Flip-flop done bits make that easy; an SRAM ROB needs a valid vector in flops.
- Size. ROB depth bounds how far ahead the core can look. It is sized together with the physical register file and the load and store queues, because whichever is smallest limits the window.
Verification checklist
- A program-order reference: every commit must match the next instruction in order, with its value, and nothing may commit after an exception until the flush.
- A random writeback model with exceptions on random instructions, and dispatch stalls.
- Assertions:
a_no_skip: assert property (@(posedge clk) disable iff (!rst_n) cmt1 |-> cmt0); a_precise: assert property (@(posedge clk) disable iff (!rst_n) flush |-> !cmt0 && !cmt1 && !do_disp); a_wb_live: assert property (@(posedge clk) disable iff (!rst_n) (wb_valid && !flush) |-> !done[wb_tag]); a_empty_after: assert property (@(posedge clk) disable iff (!rst_n) flush |=> (wptr == rptr) && (done == '0)); - Coverage: two commits in one cycle, an exception in each commit slot, back-to-back flushes, a flush with a full ROB, and a writeback in the flush cycle.
Interview questions
1. Why does an out-of-order core need a reorder buffer?
A strong answer separates finishing from committing, explains precise exceptions and in-order architectural state, and says stores and register updates are released only at commit.
2. How do you commit two instructions per cycle?
A strong answer reads the two oldest entries, commits the second only if the first commits, stops at the first not-done or excepting entry, and advances the head by the count.
3. Why wait until the head to take an exception?
A strong answer says an older instruction might fault first or an older branch might be mispredicted, so only the head knows the exception is real.
4. What can go wrong with a flush?
A strong answer mentions writebacks in the flush cycle, stale writebacks to reused tags, and clearing state in one cycle, and proposes killing in-flight work or using epoch bits.
5. How is a ROB different from the completion FIFO of Part 37?
A strong answer says both allocate in order, complete by tag and retire in order, and that the ROB adds wide commit, exception status, a one-cycle flush, and coordination with renaming and memory ordering.
Where it is used in real chips
Reorder buffers are central to out-of-order CPU cores in application processors and servers. The same in-order-commit pattern also appears in some accelerators and GPU front ends that issue work speculatively, and in DMA and PCIe engines that must make completions visible to software in order.
The rest of the series
Part 37 built a completion FIFO that accepts results in any order and releases them in allocation order.
Part 39 carries error status through a FIFO: poison bits, marking a packet bad to its end, and selectively discarding poisoned entries.


Your comments will be moderated before it appears here.