
A speculative producer writes into a FIFO before it knows whether the work is real. A branch predictor fills an instruction queue down the predicted path, a prefetcher queues requests it may cancel, a decoder pushes micro-ops past an instruction that might fault. When the guess turns out wrong, everything written after the guess has to go, and everything written before it has to stay, in order, ready for the reader.
Part 25 handled one speculative region with a commit point and a single rollback. Real producers keep several guesses in flight at once, and any one of them can be wrong. This part builds a checkpointed FIFO: the write pointer is saved at every guess, and a misprediction restores the FIFO to exactly the state it had at that guess, even while the reader keeps popping.
Key takeaways
- A checkpoint is just a saved copy of the write pointer, taken when the producer makes a guess. Restoring it throws away every entry written after that guess in one cycle.
- Checkpoints are themselves kept in a small FIFO: allocated in order, released in order when guesses are confirmed, and truncated on a restore.
- The hard case is a reader that has already popped past the checkpoint. A sticky "passed" bit per checkpoint turns that restore into an empty FIFO instead of a corrupted one.
- The passed bit must also include a pop in the restore cycle itself. Leaving that term out breaks the pointers, and a random model finds it within a hundred cycles.
- Area is small: one pointer and one bit per checkpoint. The cost is in the restore mux on the write pointer and the compare per checkpoint on every pop.
In this part
- What problem it solves
- The interface
- Micro-architecture
- RTL sketch
- Corner cases
- Timing, area and power
- Verification checklist
- Interview questions
- Where it is used in real chips
- The rest of the series
What problem it solves
Picture a fetch stage writing instructions into a queue that feeds decode. It predicts each branch and keeps going. Three branches later, the first one resolves as mispredicted. Everything fetched after that branch is on the wrong path; everything before it, including the branch, is correct and may still be in the queue.
Flushing the whole queue on any misprediction works, but it throws away correct older entries that must be fetched again. A speculative FIFO with one commit pointer remembers only one point to roll back to. With several unresolved guesses in flight, you need one saved point per guess and a way to jump back to any of them.
The interface

The data side is the FIFO from Part 1: push, wdata and full for the writer, pop, rdata and empty for the reader. The checkpoint side adds four controls:
take: save a checkpoint now. It returnstake_id, a small tag the producer keeps with the guess. The checkpoint includes any push in the same cycle, so the entry that carries the guess, such as the branch itself, is older than the checkpoint and survives a restore.release_ck: the oldest checkpoint is confirmed and can be freed. Release is in order, matching the in-order commit of the guesses.restorewithrestore_id: the guess with this tag was wrong. Cut the FIFO back to that checkpoint and drop every younger checkpoint.ck_full: no free checkpoint slots. The producer must stall before making another guess.
Guesses may resolve out of order, but checkpoints are released in order, which keeps the checkpoint table a simple ring.
Micro-architecture
There are two rings. The data ring holds the entries, with a write pointer and a read pointer that carry the extra wrap bit from Part 1. The checkpoint ring holds, for each live checkpoint, the saved write pointer and a single passed bit. It has its own head and tail pointers, also with a wrap bit, so ck_full comes out the same way full does.

A restore has two outcomes, shown above:
- Reader still behind the checkpoint. The saved pointer is loaded into the write pointer. Older entries stay, younger ones are gone, and the storage array is not touched.
- Reader already past the checkpoint. Some wrong-path entries were already popped, and the consumer must discard them through its own flush. Loading the saved pointer would now give a negative count, so the write pointer is set to the next read pointer instead, leaving the FIFO empty.
A plain compare of the saved pointer with the read pointer is ambiguous once the pointers wrap. A sticky bit removes the doubt. When a pop happens with the read pointer equal to a checkpoint's saved pointer, the reader is popping the first entry younger than that checkpoint, and the passed bit is set. Before that point, the read pointer can only be between the saved pointer minus the depth and the saved pointer itself, so the equality cannot fire early.
On a restore, the checkpoint ring tail is pulled back to just after the restored checkpoint. The restored checkpoint itself stays live: its guess is now resolved, and it is released in order like any other when it commits.
RTL sketch
Power-of-two depth and checkpoint count, a flip-flop array with a registered read, and the full-boundary push from Part 1:
module ckpt_fifo #(
parameter int W = 32,
parameter int DEPTH = 16, // power of two
parameter int NCK = 4, // checkpoints, power of two
localparam int AW = $clog2(DEPTH),
localparam int CW = $clog2(NCK)
) (
input logic clk, rst_n,
input logic push,
input logic [W-1:0] wdata,
output logic full,
input logic take, // checkpoint after this cycle's push
output logic [CW-1:0] take_id,
output logic ck_full,
input logic release_ck, // oldest checkpoint confirmed
input logic restore, // misprediction
input logic [CW-1:0] restore_id,
input logic pop,
output logic [W-1:0] rdata,
output logic empty
);
logic [W-1:0] mem [DEPTH];
logic [AW:0] wptr, rptr;
logic [AW:0] ck_wptr [NCK];
logic ck_passed [NCK];
logic [CW:0] ck_head, ck_tail;
assign empty = (wptr == rptr);
assign full = (wptr[AW-1:0] == rptr[AW-1:0]) && (wptr[AW] != rptr[AW]);
wire ck_empty = (ck_head == ck_tail);
assign ck_full = (ck_head[CW-1:0] == ck_tail[CW-1:0]) && (ck_head[CW] != ck_tail[CW]);
assign take_id = ck_tail[CW-1:0];
wire do_pop = pop && !empty;
wire do_push = push && !restore && (!full || do_pop);
wire do_rel = release_ck && !ck_empty;
wire do_take = take && !restore && (!ck_full || do_rel);
wire [AW:0] rptr_n = rptr + do_pop;
wire [AW:0] wptr_n = wptr + do_push;
// restore target: passed now, or passed by this cycle's pop
wire r_passed = ck_passed[restore_id] ||
(do_pop && rptr == ck_wptr[restore_id]);
wire [AW:0] r_wptr = r_passed ? rptr_n : ck_wptr[restore_id];
wire [CW-1:0] r_off = restore_id - ck_head[CW-1:0];
wire [CW:0] r_tail = ck_head + r_off + 1'b1;
always_ff @(posedge clk or negedge rst_n)
if (!rst_n) begin
wptr <= '0; rptr <= '0;
ck_head <= '0; ck_tail <= '0;
end else begin
rptr <= rptr_n;
wptr <= restore ? r_wptr : wptr_n;
if (do_rel) ck_head <= ck_head + 1'b1;
if (restore) ck_tail <= r_tail;
else if (do_take) ck_tail <= ck_tail + 1'b1;
end
always_ff @(posedge clk) begin
if (do_push) mem[wptr[AW-1:0]] <= wdata;
if (do_pop) rdata <= mem[rptr[AW-1:0]];
for (int i = 0; i < NCK; i++)
if (do_pop && rptr == ck_wptr[i]) ck_passed[i] <= 1'b1;
if (do_take) begin // later assignment wins
ck_wptr[take_id] <= wptr_n;
ck_passed[take_id] <= 1'b0;
end
end
endmodule
Checkpoint slots have no reset: a slot is only read while live, and taking it writes both fields. Push and take are ignored in a restore cycle, because anything the producer presents then is from the wrong path.
A cycle-accurate Python model of this sketch ran 600,000 random cycles at depths 4 to 16 with 2 to 8 checkpoints, against a reference queue with no wrap bits and no passed bits. Every pop and every restore matched. Removing the same-cycle term from r_passed fails within a hundred cycles.
Corner cases

- Pop in the restore cycle at the checkpoint boundary. The read pointer equals the saved pointer and a pop is accepted, so the reader is taking the first wrong-path entry right now. The stored passed bit is still zero. Without the extra term, the write pointer would be set one behind the new read pointer. With it, the FIFO ends empty, as it should.
- Take and release at a full checkpoint table. The release frees the head slot in the same cycle, so the take is accepted, matching the push at full in Part 1. The new checkpoint lands in the slot just freed.
- Release and restore together. Allowed when they name different checkpoints. The restore offset is computed from the old head, so the new tail is right either way. Releasing and restoring the head in the same cycle is a contradiction in the producer and should be an assertion.
- Second restore to a passed checkpoint. The saved pointer is stale, but the passed bit is set, so the stale value is never used.
Timing, area and power
- Restore path. The write pointer now has a three-way source: hold, increment, or a value chosen from the checkpoint table by
restore_id. The NCK-to-1 mux plus the passed select sits in front of the pointer flops and, throughfull, in front of the next cycle's push enable. If the restore arrives late in the cycle, register it and apply it one cycle later, with push blocked for that cycle. - Passed compare. Each checkpoint needs an equality compare against the read pointer on every pop. With 4 to 8 checkpoints and a 5-bit pointer this is small. With dozens of checkpoints, consider computing passed lazily: only the oldest few checkpoints can be passed, because the reader moves in order.
- Area. Each checkpoint is one pointer plus one bit. That is far cheaper than snapshotting data. The storage array is untouched by a restore.
- Power and sizing. Checkpoint flops can be clock gated on take. Size the table from how many guesses are unresolved at once; too few stalls the producer.
Verification checklist
- A reference model that keeps absolute positions for entries and checkpoints with no wrap. Restore sets the tail to the larger of the checkpoint position and the head. Compare every popped value and the count every cycle.
- Assertions on the producer contract:
wherea_restore_live: assert property (@(posedge clk) disable iff (!rst_n) restore |-> ck_live(restore_id)); a_no_rel_head: assert property (@(posedge clk) disable iff (!rst_n) !(restore && release_ck && restore_id == ck_head[CW-1:0])); a_take_room: assert property (@(posedge clk) disable iff (!rst_n) !(take && ck_full && !release_ck));ck_livechecks that the slot lies between head and tail. - Coverage: restore of a passed checkpoint, restore with a same-cycle pass, restore of the oldest and the youngest live checkpoint, restore at full, take with release at a full table, and pointer wrap many times with checkpoints live.
- Traffic phases: a fast reader to hit the passed cases, and a fast writer to keep the FIFO full while restores land.
Interview questions
1. What do you save at a checkpoint, and why not the data?
A strong answer says only the write pointer is needed, because entries older than the checkpoint are untouched and younger ones are simply overwritten later. It notes that a restore therefore costs one cycle regardless of how many entries are dropped.
2. The reader has already popped wrong-path entries when the misprediction arrives. What happens?
A strong answer explains that the FIFO cannot take back popped data, so it empties itself and the downstream stage flushes what it already took. It then explains how the FIFO knows: a sticky passed bit, because a plain pointer compare is ambiguous after wrap.
3. Why release checkpoints in order when branches resolve out of order?
A strong answer says in-order release keeps the table a ring, so allocation and truncation are pointer moves, and weighs a slot held a little longer against a free list and a harder restore.
4. Where is the critical path, and how do you fix it?
A strong answer names the restore mux into the write pointer and the passed logic that feeds it, and suggests registering the restore with a one-cycle push bubble, or precomputing the restore target for the oldest few checkpoints.
5. How would you find the same-cycle passed bug in verification?
A strong answer builds a reference without wrap bits or passed bits, drives a fast reader so the read pointer often sits on a checkpoint, and adds a cover point for a pop at the checkpoint boundary in the restore cycle.
Where it is used in real chips
The most familiar home is the front end of a processor: fetch and instruction queues and branch history structures, all written past unresolved predictions. The same pattern appears in accelerators that run ahead of a condition, in DMA engines that queue descriptors before a chain decision is known, and in protocol engines that stage responses before a check completes.
The rest of the series
Part 25 covered the speculative FIFO, with one commit point, rollback and flush.
Part 27 protects the stored data itself: an ECC-protected FIFO with single-error correction and double-error detection at full throughput.


Your comments will be moderated before it appears here.