Loading…
Out-of-Order Cores: Tomasulo-Style Design Notes (Scalar and Dual-Issue)

Out-of-Order Cores: Tomasulo-Style Design Notes (Scalar and Dual-Issue)

Two out-of-order cores are built on this family: rv32i-ooo-FE on the single-issue pipeline, and rv32i-super-ooo-FE on the optimised dual-issue superscalar core. Both use the same hybrid scheme, Tomasulo-style tag-based dynamic scheduling for wakeup and selection, combined with reorder-buffer commit for precise architectural state.

This page is the design reference: what each structure holds, how an instruction moves through it, where the speculative edges are, and what the two cores measure. The tutorial walkthrough, RTL excerpts and the debugging narrative live in the out-of-order post.

Big Picture

The execution policy is:

  1. Fetch and decode in program order, with branch prediction on the fetched stream.
  2. Rename destination registers to reorder buffer tags.
  3. Dispatch renamed instructions into per-class issue queues.
  4. Issue when operands are ready, oldest ready first within a class.
  5. Write results back with tag broadcasts on the common data bus.
  6. Commit from the reorder buffer head in program order.

Execution order follows data readiness. Architectural visibility stays in program order, which is what keeps precise state, memory side effects and exception boundaries correct.

Core Parameters

The two cores differ in width and window size, and share the rest of the scheme.

Structurerv32i-ooo-FE (scalar)rv32i-super-ooo-FE (dual issue)
Fetch and predict1 wide, hybrid predictor, BTB, RAS2 wide, both slots predicted
Dispatch and issue1 per cycleup to 2 per cycle
RenameRAT, ROB tag as the physical tagsame, 2 write ports
Reorder buffer16 entries32 entries
Issue queues8 entries, split by classfour 16-entry queues: ALU, MD, load/store, branch
Execution units1 ALU path, MD for divide, branch unit2 ALU paths, MD for divide, branch unit on pipe 0
Result busestag broadcast, one pending load responsedual CDB, two memory ports
Commit1 per cycleup to 2 per cycle
Memoryloads issue early with a ROB tag, stores at retiresame, up to two new loads per cycle
Control windowup to 4 unresolved branches or JALRsup to 4 unresolved branches or JALRs

Architectural Register File

  • 32 integer registers (x0 to x31), 32 bits each.
  • x0 stays hardwired to zero.
  • Register writes happen only at commit, so the register file always holds a clean architectural state.

RAT (Register Alias Table)

For each architectural register:

  • alias_valid[reg]: whether the register currently maps to an in-flight producer.
  • alias_tag[reg]: reorder buffer tag of the latest producer.

Behaviour:

  • At dispatch of a writing instruction, the RAT entry for rd is updated to the new tag.
  • At commit, the RAT entry is cleared only if the committing tag still matches the current mapping.
  • The second rule is what stops a retiring instruction from clearing a mapping that a younger writer already owns.

ROB (Reorder Buffer)

Circular buffer with head, tail and count. The ROB index itself is the tag, so the ROB slot is the physical register and no separate physical register file or free list is needed.

Each entry tracks:

  • valid, ready
  • rd, reg_write, value
  • memory intent (mem_read, mem_write, mem_to_reg, mem_funct3)
  • memory payload (mem_addr, mem_wdata, load_data)
  • effective address, written directly into ROB metadata so it does not consume a result bus
  • ecall, halt

Commit policy:

  • Only the head entry can commit, and it commits only when ready.
  • Commit moves the head forward, one entry in the scalar core, up to two in the dual-issue core.
  • Stores write memory at commit, never before.
  • A full ROB stalls dispatch. That stall is the only in-order stall left in the machine, and it is the backpressure that keeps speculation bounded.

In practice the dual-issue ROB peaks at 29 of its 32 entries on CoreMark, and a separate full-window test reaches all 32.

Issue Queues

One queue per functional class, each entry holding:

  • source operand state: rs1_ready/val/tag, rs2_ready/val/tag
  • decoded control fields
  • the assigned ROB tag
  • an age stamp used for oldest-ready selection

Selection policy:

  • ready means both operands are present now, either latched earlier or woken this cycle by a broadcast.
  • among ready entries, the oldest wins, so an old waiter cannot be starved by younger ones.
  • splitting by class keeps a slow unit from holding fast ones hostage: a divide occupies the MD queue while ALU and branch work keep draining.

CDB (Tag Broadcast)

Results go out as tag plus value on a shared bus, and every queue entry and ROB entry holding that tag captures it in the same cycle.

  • The scalar core has one result path plus the pending load response.
  • The dual-issue core has two buses, one per issue slot, with arbitration for the case where both a load return and an ALU completion land together.

Fetch, Decode and Dispatch

An instruction dispatches only when all of these hold:

  • the fetch slot holds a valid instruction
  • the ROB can allocate an entry for it
  • the target issue queue has space
  • the control window has room for it (see below)
  • no flush or redirect is active

Control Flow and the Control Window

The early version of these cores allowed one control instruction in flight and stopped dispatch behind it. That single gate was the largest measured cost in the dual-issue core, at 23.1% of all cycles, so it was widened.

  • Up to four unresolved conditional branches or JALRs may be in flight.
  • The next control is selected behind the one currently resolving.
  • A correctly predicted branch no longer adds a dispatch-cycle wait before the following control can enter.
  • A redirect cancels younger queue entries and pending load responses. An entry selected before the edge is re-checked against its live ROB tag and sequence before it issues, and allocation resumes after the surviving branch.
  • Flush uses positional tags, and a RAT restore accompanies every redirect, so a wrong-path write cannot leave a live tag pointing at a value that never arrives.
  • In the dual-issue core, prediction covers both slots of a fetched pair, with prediction metadata carried forward when a pair advances one slot at a time.
  • A JALR’s link value is PC+4 even while its target still depends on an operand, so the link can wake younger consumers early. The control itself still cannot retire early.

Operand Resolution at Dispatch

When a source register is read:

  • if the RAT holds no pending producer, the operand comes from the architectural register file
  • if the RAT holds a tag, the same-cycle broadcasts are checked first, and a match latches the value immediately
  • otherwise the tag travels into the issue queue and the entry waits for the wakeup

This is the part that decouples operand timing from pipeline stage alignment, and it is why renamed sources never need a stall for a false dependency.

Execute and Writeback

Issued instructions execute with resolved operands:

  • ALU, branch and CSR results are computed directly.
  • Multiply-class M-extension ops run on the ALU paths, single cycle and dual issue capable. Only divide and remainder use the MD pipe, which is 12 cycles and not pipelined.
  • Loads are covered in the next section.
  • Writeback sends tag plus value to the ROB and the broadcast path in the same cycle.

Memory Ordering

The memory path went through the largest revision, because a load with a ready address was still waiting for the ROB head before it could ask for data.

  • Address generation happens out of order, and an eligible load is selected early. Its ROB tag and sequence travel with the request.
  • Returned data updates the ROB and wakes dependents while an older instruction is still waiting.
  • An older store with an unknown address blocks the load, as does a known older store to the same physical word.
  • A known-disjoint older store may be bypassed, including while that store waits for its data.
  • Register writes and stores still commit in program order, and reads from MMIO never move ahead.
  • The scalar core carries one pending load response. The dual-issue core uses both ports and can start up to two new loads per cycle, with a retiring store owning its port.
  • Store-to-load forwarding is not implemented, and the load path keeps a one-cycle completion bubble that earlier address generation shrinks but does not remove.

Correctness Before Timing

The out-of-order cores run the same checks as the rest of the family, and no change is kept unless it passes all of them:

  • 7 directed M-extension programs (multiply, divide, remainder, divide by zero, overflow, CSR)
  • the 31-instruction regression suite
  • C programs compared bit for bit against a reference state dump
  • all 9 CoreMark configurations reaching halt with identical retired instruction counts and identical final architectural state

Three M-extension faults were found by those directed tests after CoreMark had already run clean, which says as much about CoreMark’s coverage of the M extension as about the ALU: the MULH family returned zero because products were computed in 32 bits, INT_MIN / -1 took an unsigned literal in the divide mux, and division by zero returned 1 instead of all ones. A fourth fault was in retire, where a CSR read used the flopped address and returned the previous cycle’s value.

Worked Examples

RAW chain, the true dependency.

I0: add x5, x1, x2
I1: sub x6, x5, x3
I2: xor x7, x6, x4

I0 gets tag T0 and RAT[x5] = T0. I1 gets T1, and its source x5 carries tag T0. I2 gets T2 and carries T1. I0 issues and broadcasts, I1 wakes and captures the value, I1 issues and broadcasts, I2 wakes. Commit still walks T0, T1, T2.

WAW elimination by rename.

I0: addi x10, x0, 1
I1: addi x10, x0, 2
I2: add  x11, x10, x12

I0 gets T0 and I1 gets T1, with RAT[x10] now pointing at T1. I2 reads the tag T1, so it binds to the younger writer without either write waiting on the other.

Store then load to the same address.

I0: sw x8, 0(x2)
I1: lw x9, 0(x2)
I2: add x10, x9, x3

I1 queries older stores before its speculative read. A matching older store with an unknown address blocks issue; a known-disjoint store is bypassed. If blocked, the load is serviced later, and I2 wakes when the loaded value is broadcast.

Taken branch with younger work in flight.

I0: beq x1, x2, target
I1: add x5, x6, x7
I2: sub x8, x9, x10

I0 resolves taken, the redirect kills I1 and I2 by positional tag, the RAT is restored to its state at the branch, fetch restarts on the target path, and any pending load responses for the wrong path are cancelled.

Measured Results

All rows are RV32IM, Verilator, O3 with 100 iterations, same binaries before and after each change, fixed-latency memory model.

CoreVersionCyclesCPIIPCCoreMark/MHz
Scalarchecked-in baseline40,233,6291.3617140.7343682.485483
Scalarrevised32,589,8661.1030100.9066103.068439
Dual issuechecked-in baseline34,399,5521.1642590.8589152.907015
Dual issuerevised19,746,4290.6683211.4962865.064207

The revised scalar core uses 19.00% fewer cycles than its baseline, and the revised dual-issue core 42.60% fewer. Across the nine O2, O3 and Ofast runs at 1, 10 and 100 iterations, input hashes, retirement counts and final architectural state match their baselines, with reductions between 18.78% and 19.91% for the scalar core and between 41.76% and 44.20% for the dual-issue core.

For reference, the in-order cores on the same workload sit at 1.0675 CPI and 3.1705 CoreMark/MHz for the optimised single-issue pipeline, and 0.7271 CPI and 4.6545 CoreMark/MHz for the optimised in-order superscalar. The revised scalar out-of-order core beats the plain pipeline by 19.29% and trails the optimised pipeline by 3.22%. The revised dual-issue out-of-order core is 8.80% above the in-order superscalar, using 74.8% of the two-wide issue ceiling against the in-order core’s 68.8%.

What each change was worth

Separate ablations on the dual-issue core, all at O3 with 100 iterations, holding fast multiply constant where it is not the variable:

ConfigurationCycles
Checked-in baseline34,399,552
Consistent execution and retirement timing, legacy limits retained30,856,205
Fast multiply, head-only loads, old control gates, slot 1 not taken29,021,118
Fast multiply and early loads, old control gates, slot 1 not taken28,708,153
Fast multiply and four-deep control window, head-only loads, slot 1 not taken24,008,325
Fast multiply and both-slot prediction, head-only loads, old control gates26,887,659
Combined changes, one new load per cycle19,856,055
Combined changes, up to two new loads per cycle19,746,429

The control window is the single largest recoverable item, at 17.3% of cycles with fast multiply held constant. Early loads alone recover 1.1% while the old gates remain, and a second load per cycle adds 0.55% once the rest is in place. The changes interact, so the rows are not additive.

Validation

  • 124 programs on the dual-issue core and 121 on the scalar core, in both Verilator and Icarus.
  • The two simulators agree on cycles, retirement counts, committed PCs, all 32 registers, all 2,048 data words and the 16 CSR storage slots.
  • 31 register checks pass on both, and 1,024 M-extension results agree with mathematical expectations, QEMU and Spike.
  • Test coverage includes store aliases, overlapping stores, wrong-path memory operations, repeated predicted calls and full ROB flushes.
  • The O3 100-iteration dual-issue run matches the functional reference, and compiling out the performance counters leaves the cycle counts unchanged.

Practical Limits in This Revision

  • Commit stays in order, which caps throughput on any workload whose oldest instruction is also its slowest.
  • The scalar core carries one pending load response, and the dual-issue core at most two new loads per cycle, so more parallelism needs a wider load path rather than more window.
  • There is no store-to-load forwarding, and a one-cycle load completion bubble remains in the retire path.
  • The memory model is fixed latency. Caches, variable memory latency and multi-miss overlap are where latency tolerance would show more, and they are the next structural step.
  • The CSR model covers the machine-mode registers used by the software here. MRET, interrupts and coherent self-modifying code are outside it.
  • No synthesis is involved, so area, Fmax and power for these cores are not measured on this page.

Compact Pseudocode

every cycle:
  if flush:
    cancel younger queue entries and pending load responses
    restore RAT to the state at the redirecting branch
    clear front-end valid state

  if dispatch_ok:
    tag <- ROB.allocate()
    RAT[rd] <- tag (if rd writes)
    src operands <- RF value, or RAT tag, or same-cycle broadcast value
    IQ[class].enqueue(instruction, src descriptors, tag)

  IQ.wakeup_from_broadcast()
  issued <- IQ.select_oldest_ready()

  if issued:
    result <- execute(issued)
    ROB.writeback(tag, result, memory metadata, effective address)
    broadcast(tag, result) if the result is broadcastable

  if ROB.head.ready:
    commit ROB.head in order
    write RF, and write memory for stores
    clear RAT mapping only if the tag still matches