Master the fundamental concepts of pipelining & out-of-order execution through this focused micro-challenge.
You have read the whole brief, and the concepts above stay free on every task. Writing and running the code needs a plan.
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
Every task includes starter code, theory, and hidden tests so you can implement and verify locally in the browser.
How it worksTomasulo's algorithm (1967) schedules instructions dynamically using reservation stations and a Common Data Bus (CDB). It renamed physical registers decades before modern Intel cores branded it differently.
cLoading…
For example, an ADD waiting on a LOAD clears its qj tag when the load broadcasts its value on the CDB, allowing the adder to fire without writing the architectural register yet.
For this exercise, you will simulate two ALU stations and a CDB broadcast loop. This task asks you to compare Tomasulo scheduling against your in-order five-stage pipeline on the same instruction trace.
Keep the relevant datasheet, ISA manual, or architecture textbook chapter open while you implement. When your output disagrees with the reference trace on the same program, the bug is usually a mis-decoded opcode, a stale register read, or a flag bit left unchanged after arithmetic.
For this exercise, you will use those habits while implementing the requirement in the starter code. Microarchitectural product names change across CPU generations, but the control ideas (fetch, bypass, cache lines, vector lanes) stay stable enough to debug from first principles.
Simulate Tomasulo's algorithm, the scheme behind out-of-order execution with register renaming. Instructions issue in order into reservation stations and capture their operands as either values or tags of the stations that will produce them. They execute when both operands are available, and broadcast their results on a common data bus (CDB) to every waiting station. A register alias table (RAT) maps each register to the station that will write it last, which removes WAR and WAW hazards.
cLoading…
Values are integers; DIV truncates, and division by 0 gives 0.
c with latency L, it finishes at the end of cycle c + L − 1.RAT[Fd] is set to this station (renaming).The simulation ends when every instruction has issued and every station is free (or after 300 cycles).
One line per cycle: the parts that happened, joined by |, then the RAT.
cLoading…
write lists the registers updated, or -> (no register: renamed away) when a later instruction has already renamed the destination (a WAW hazard, resolved).exec lists the stations that started this cycle, e.g. exec I0 (Mul1), I3 (Add2).issue shows each operand as j=VALUE or j=TAG; a stall prints issue stalled (no free ADD station) (or MUL).wait when nothing happened, and | RAT ... only when some register is renamed (in register order).Instructions are named I0, I1, … Finally: finished in C cycles: F0=.. F1=.. ... F7=...
Input:
cLoading…
Output:
cLoading…
I2 overwrote F1 while I1 was still waiting for the old F1. Renaming let both proceed, and the final registers match sequential execution.
busy, op, Vj, Vk, Qj, Qk, and a RAT of station tags; implement issue, execute and write_result as separate steps.Hidden tests cover two results finishing in the same cycle (CDB contention), a WAR hazard, DIV including division by zero, and a long independent sequence limited by station count.