5.3.5 · D1Advanced Microarchitecture

Foundations — Reorder buffer (ROB)

1,918 words9 min readBack to topic

This page assumes nothing. Before you read Reorder buffer (ROB) you must own a handful of words and pictures. We build each one from the ground up, in an order where every symbol is earned before it is used.


0. What is an "instruction"?

We will write instructions like this:

Read it as: "take the value in box , add the value in box , put the sum in box ." The boxes are called registers — we define those next.


1. Registers and the register file

Figure — Reorder buffer (ROB)

Look at the figure: the register file is just a row of labelled cups. points at the value inside cup . When a program "finishes" an instruction for real, the answer gets poured into one of these cups — and once it's poured, it's permanent and visible to the program.

We call the contents of the register file the architectural state: the state the program is supposed to have. Related reading: Register-file-management.


2. Program order vs. execution order

Figure — Reorder buffer (ROB)

In the figure, the left column is program order (I1, I2, I3, I4 top-down). The right column is when each instruction finishes: notice I3 finishes first because it is fast, even though it was written third. This mismatch is the entire reason the ROB exists — see Speculative-execution and Superscalar-processors for why processors bother finishing out of order at all.


3. In-flight instructions


4. The three life stages of an instruction

Every instruction passes through three named moments. You must know all three verbatim.

This trio appears throughout Instruction-retirement and is the backbone of the parent note.


5. A queue, FIFO, and "circular"

The ROB is a FIFO because retirement must be in program order — first issued, first retired.

Figure — Reorder buffer (ROB)

The figure shows slots drawn as a ring. Two arrows live on this ring:

As instructions retire, Head walks forward. As new ones issue, Tail walks forward. Both loop around the ring.


6. The one piece of math: modulo

The only symbol from mathematics the parent note uses is mod. We define it from zero.


7. Full vs. empty

Two conditions decide whether the ring can accept or release work.


8. Status of a slot

A completed instruction that is not at the head must wait — its answer sits in the ROB slot, not in the register file. This waiting is the essence of in-order retirement.


9. Tag / physical register name


10. Prerequisite map

Instruction = one recipe line

Register and register file

Architectural state = official values

Program order vs execution order

In-flight instructions

Issue Execute Retire stages

FIFO queue

Circular buffer with Head and Tail

Modulo wrap-around counter

Full and empty conditions

Slot status pending completed exception

Tag = slot number as temporary name

Reorder Buffer

Every arrow means "you must understand the source before the target makes sense." The whole graph funnels into the Reorder buffer (ROB) node. Downstream topics that reuse these foundations include Precise-exceptions, Branch-prediction, Memory-ordering, and Instruction-retirement.


Equipment checklist

Self-test: can you answer each before revealing?

What one line of a program does an instruction represent?
One tiny command, like "add R2 and R3, store in R1".
What is the register file ?
The shelf of permanent named boxes holding the program's official (architectural) values.
What does denote?
The number currently stored in box .
Program order vs execution order?
Program order = the written top-to-bottom order; execution order = the order instructions actually finish computing.
Name the three life stages of an instruction, and which are in-order.
Issue (in order), Execute (out of order), Retire/commit (in order).
What does FIFO stand for and why does the ROB use it?
First In First Out; retirement must follow program order, so oldest leaves first.
What does the Head pointer point to?
The oldest in-flight instruction, next in line to retire.
What does the Tail pointer point to?
The next free slot where a newly issued instruction is placed.
What is in plain words?
The remainder after dividing by — a wrap-around clock counter.
Compute .
— the pointer wraps back to slot 0.
Empty condition of the ROB?
.
Full condition of the ROB?
(one spacer slot kept empty).
Why keep one slot always empty?
So full and empty don't both read ; the spacer removes the ambiguity.
What are the three slot statuses?
pending, completed, exception.
Why can a completed instruction still not write the register file?
If it isn't at the head, older instructions haven't retired yet; in-order commit forbids it.
What is a tag?
The ROB slot number used as a unique temporary name for an in-progress result.