Explaining Tomasulo's algorithm
Tomasulo's algorithm enables out-of-order execution via dynamic scheduling using reservation stations that buffer instructions and manage operand readiness. Instructions issue to reservation stations linked to functional units, fetch operands from registers or wait if pending, then execute once ready. The Common Data Bus (CDB) broadcasts results with tags to update registers and all waiting stations, ensuring correct data flow. Register renaming replaces architectural register names with reservation station tags, eliminating WAW and WAR hazards by tracking which instruction will write each register, thus avoiding false dependencies. This scheme handles RAW hazards by waiting for needed values, enables out-of-order completion, and maintains precise execution by using tags to coordinate writes and operand usage precisely.
One of the classic mechanisms for getting more parallelism out of a scalar instruction stream is to decouple the order in which operations are issued from the fixed program order dictated by the compiler. Robert Tomasulo's algorithm, first used in the IBM 360/91 floating–point unit, is an early and influential example of such a dynamic scheduler.
The algorithm adds three key structures to a simple in–order pipeline:
- An issue logic that scans the program order stream and allocates entries in function–specific queues called reservation stations.
- A set of reservation stations sitting in front of each functional unit. Each entry holds an opcode, the destination tag, and either the value of each source operand or a tag indicating where that operand will come from.
- A common data bus (CDB) that broadcasts the tag/value of each completed operation to everyone who might be waiting for it.
At a high level, instructions pass through three stages:
-
Issue/rename: If there is a free reservation station for the required functional unit and no structural hazard, the next instruction issues. For each source register, the hardware checks a small “register status” table. If no outstanding instruction is going to write that register, the current architectural value is read into the reservation station. If a pending producer exists, its reservation station number is recorded as a tag. The destination register’s status is updated with the tag of this reservation station. This tag serves as a renamed version of the destination — from now on consumers of that architectural register will refer to this tag rather than to the architectural name.
-
Execute: Each cycle the scheduler examines the reservation stations. An entry whose operands are both available (either it latched values at issue, or it has since received them on the CDB) and whose functional unit is free can begin execution. Different operations can execute out of program order as soon as their true data dependencies are resolved.
-
Write/broadcast: When a functional unit finishes, it puts its reservation station tag and result value on the common data bus. The register file updates the architectural register status only if the tag on the bus still matches the one recorded for that register – this prevents an older instruction from overwriting a newer value. All reservation stations snoop the bus; if an operand tag matches the one they were waiting for, they latch the value. The reservation station that produced the result can then be freed.
This distributed tag/value broadcast is what allows the hardware to wake up dependents without centralized scoreboards, and it is the essence of the CDB.
The “register renaming” inherent in this process solves the so‑called name–dependent hazards:
-
A write–after–write (WAW) hazard occurs in an in–order machine because two instructions target the same architectural register; the older write must complete before the newer to preserve the programmer’s view. In Tomasulo’s scheme, each write is associated with a unique reservation station tag. Updating the register status with the latest tag means only the youngest producer will be allowed to commit its value to the architectural register. The older write can execute and broadcast its value, but because its tag no longer matches the register’s status, it will not overwrite the later result.
-
A write–after–read (WAR) hazard arises when a younger instruction overwrites a register that an older instruction still needs to read. Tomasulo’s algorithm captures a source operand’s value or tag at issue time; subsequent redefinitions of the architectural name don’t affect the reservation station entry. Even if a younger writer updates the register file, the older consumer either already has the value or will pick it up from the producing tag on the CDB. Thus renaming breaks the false dependence between the reader and the later writer.
By translating architectural register names into transient tags, the algorithm removes these name hazards, leaving only true read‑after‑write dependencies to be enforced by the reservation stations’ operand readiness checks.