0

The re-order buffer used in the Tomasulo's algorithm for out-of-order execution and branch speculation has 2 pointers.

  • Head pointer: Points to the oldest instruction. This will be the next instruction to be committed.
  • Tail pointer: Points where the newest instruction will be added.

Each ROB entry has 4 fields: instruction type, destination, value and ready field.

I've seen many sources teaching it this way. The ROB entry doesn't need a committed bit or busy bit.

For a ROB of size N.

  • If the ROB is empty or flushed, then TAIL=HEAD.
  • If the ROB has one free slot and HEAD=0, then TAIL=N-1.
  • If the ROB is full and HEAD=0, then TAIL=?

If TAIL=HEAD how do we know if the ROB is full or empty?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Cholax
  • 48
  • 1
  • 6

1 Answers1

1

Normally it's a circular buffer (indices wrap around); the almost-full state doesn't have to have HEAD=0, just an arbitrary position.

Yes, there's an ambiguity between full vs. empty if you use HEAD and TAIL read/write indices. As the wikipedia article explains, one way to solve that is by tracking used-capacity which can go from 0..n instead of only 0..n-1.

For thinking about CPUs, this is an implementation detail where it doesn't matter exactly how the hardware solves it; it's safe to assume that it correctly and efficiently implements a circular buffer that can use all its entries. (Or unlikely, the effective ROB size is 1 less than the physical ROB size.)


BTW, your model with HEAD=0 corresponds to adding instructions at the current tail, but retiring (committing) by shifting all entries down to 1 index lower instead of moving HEAD. In a circular buffer, the condition to watch for is HEAD = (TAIL-1)%n or something like that.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847