
Many blocks send out requests in order and get answers back out of order. A memory controller reorders reads to hit open rows. An interconnect returns responses from different targets with different latencies. A cache returns a hit before an older miss. Yet the block that issued the requests often needs the answers in the original order. The structure that sits in between is an out-of-order completion FIFO: entries are allocated in order, filled in any order, and leave in order.
This is Part 37 of the FIFO Series. We build one with a done bit per slot and the slot index as the request tag, look at head-of-line blocking and tag reuse, and check the design against a reference model with random completion orders.
Key takeaways
- Allocation is an ordinary FIFO push that returns the slot index as a tag. The tag travels with the request and comes back with the completion.
- A completion writes its data straight into the slot named by its tag and sets the slot's done bit. No search is needed.
- The head retires only when its own done bit is set. Completed entries behind an unfinished head wait: that is head-of-line blocking, and it is the price of in-order delivery.
- A tag is reused only after its slot retires, so a completion can never land in the wrong request, provided every request completes exactly once.
- Verify with a completer that picks random outstanding tags, a scoreboard in allocation order, and assertions that every completion targets a live, not-yet-done slot.
In this part
- What problem it solves
- The interface
- Micro-architecture: tags, done bits and the head
- 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
Suppose a DMA engine issues reads for consecutive chunks of a buffer and must write them to a stream in address order. The fabric returns chunk 5 before chunk 2. Without a reorder structure, the engine would have to issue one read at a time and wait, which wastes the whole point of having many reads in flight. With a completion FIFO, it can keep as many reads outstanding as there are slots, and the output still comes out in order.
The same pattern appears whenever a protocol allows out-of-order responses but a consumer needs order: AXI read data with different IDs, split transactions on a NoC, or a lookup engine whose hits and misses take different times. The tagged and ID-aware FIFOs of Parts 18 and 19 carried IDs alongside data. Here the ID is the slot itself, which is what makes the completion path so cheap.
The interface
There are three ports. The allocate port takes alloc and any request metadata to keep, such as a destination or a byte count, and returns alloc_tag in the same cycle. The completion port takes cpl_valid, cpl_tag and cpl_data, in any order. The retire port offers ret_valid, ret_data and the stored metadata, and takes ret_ready.

Allocation stalls when the FIFO is full, which is how the number of outstanding requests is capped. Retirement uses a valid and ready handshake, so the consumer can stall without affecting completions, which keep landing in their slots.
Micro-architecture: tags, done bits and the head
The pointers are those of Part 1: a write pointer for the next slot to allocate, a read pointer for the head, and an extra wrap bit for full and empty. Each slot holds the request metadata, the completion data and a done bit.
- Allocate writes the metadata into the slot at the write pointer and hands out that slot index as the tag. The slot's done bit is already zero, because it was cleared when the slot last retired.
- Complete writes the data into the slot named by the tag and sets its done bit. This is a direct indexed write, not a search, so it costs the same as an ordinary FIFO write.
- Retire looks only at the head. If its done bit is set, the head is valid on the output. When the consumer takes it, the read pointer advances and the done bit is cleared.

The picture above is the normal state of a busy completion FIFO. Several entries behind the head are done and waiting. As soon as the head completes, they drain one per cycle. The timing diagram shows the simplest version: three requests complete in the order 2, 0, 1 and retire as 0, 1, 2.

RTL sketch
module ooo_cpl_fifo #(
parameter int W = 64, // completion data
parameter int MW = 8, // request metadata
parameter int DEPTH = 16, // power of two, at least 2
localparam int AW = $clog2(DEPTH)
) (
input logic clk,
input logic rst_n,
input logic alloc,
input logic [MW-1:0] alloc_meta,
output logic alloc_ok, // not full
output logic [AW-1:0] alloc_tag,
input logic cpl_valid,
input logic [AW-1:0] cpl_tag,
input logic [W-1:0] cpl_data,
output logic ret_valid,
output logic [W-1:0] ret_data,
output logic [MW-1:0] ret_meta,
input logic ret_ready
);
logic [W-1:0] data [DEPTH];
logic [MW-1:0] meta [DEPTH];
logic [DEPTH-1:0] done;
logic [AW:0] wptr, rptr;
wire [AW-1:0] widx = wptr[AW-1:0];
wire [AW-1:0] ridx = rptr[AW-1:0];
wire empty = (wptr == rptr);
wire full = (widx == ridx) && (wptr[AW] != rptr[AW]);
assign alloc_tag = widx;
assign alloc_ok = !full;
assign ret_valid = !empty && done[ridx];
assign ret_data = data[ridx];
assign ret_meta = meta[ridx];
wire do_ret = ret_valid && ret_ready;
wire do_alloc = alloc && (!full || do_ret);
always_ff @(posedge clk or negedge rst_n)
if (!rst_n) begin
wptr <= '0;
rptr <= '0;
done <= '0;
end else begin
if (do_alloc) wptr <= wptr + 1'b1;
if (do_ret) rptr <= rptr + 1'b1;
if (do_ret) done[ridx] <= 1'b0;
if (cpl_valid) done[cpl_tag] <= 1'b1; // never the retiring slot
end
always_ff @(posedge clk) begin
if (do_alloc) meta[widx] <= alloc_meta;
if (cpl_valid) data[cpl_tag] <= cpl_data;
end
endmodule
The output is combinational from the head slot, like the first-word fall-through FIFO of Part 3. The sketch was checked with a cycle-accurate Python model against a reference model for 720,000 cycles at depths 1 to 32 (the RTL needs 2 or more), with completions in random order, forced completion of any request older than a latency bound, and random retire stalls.
Corner cases
- Completion for the head in the same cycle the consumer is ready. In the sketch the done bit is registered, so the head retires one cycle later. A bypass from the completion port to the output saves that cycle at the cost of a longer path from
cpl_validtoret_valid. - Allocate at full while the head retires. The new request takes the slot being freed and gets the same tag. That is safe because the old request has fully left; the done bit is cleared by the retire and nothing sets it in the same cycle.
- Duplicate or stray completions. A completion for a free slot, or a second completion for a done slot, silently corrupts data. The design cannot detect it cheaply; assertions must.
- A request that never completes. The head waits forever and everything behind it waits too. Production designs add a timeout per head entry that retires it with an error status, which the poison-aware FIFO of Part 39 can carry downstream.
- Multi-beat completions. A response of several beats needs a beat counter per slot, or one slot per beat with tags allocated in groups. Done is set on the last beat only.
Timing, area and power
- Completion path. Decoding
cpl_taginto a one-hot write enable is the same cost as an ordinary FIFO write. Two completion ports need two write ports on the data array, or banking as in Part 34. - Retire path.
ret_validis a DEPTH-to-1 mux on the done bits plus the empty check. For a deep FIFO, registerdone[ridx]anddone[ridx+1]as a small lookahead. - Area. One done bit per slot on top of the data. Metadata stored at allocation often turns out larger than expected; keep only what the consumer needs.
- Depth. The depth bounds the number of requests in flight, so it sets throughput. Size it from the longest completion latency times the issue rate.
- Power. Data is written once per completion and read once at retire. There is no data movement during reordering, which is the main advantage over sorting structures.
Verification checklist
- A completer model that keeps the set of outstanding tags and picks one at random each cycle, with a latency bound so no request starves the test.
- A scoreboard in allocation order that checks tag, metadata and completion data at every retire, and that
ret_validis high exactly when the head has completed. - Assertions:
Herea_cpl_live: assert property (@(posedge clk) disable iff (!rst_n) cpl_valid |-> !done[cpl_tag] && tag_is_live(cpl_tag)); a_fresh_slot: assert property (@(posedge clk) disable iff (!rst_n) (do_alloc && !full) |-> !done[widx]); a_ret_stable: assert property (@(posedge clk) disable iff (!rst_n) (ret_valid && !ret_ready) |=> ret_valid && $stable(ret_data));tag_is_liveis a small function that checks the tag lies between the read and write pointers. - Coverage: completions in exact reverse order, head completing last, allocation at full with a retire, the same tag reused many times, and long retire stalls while completions continue.
Interview questions
1. Requests go out in order and come back in any order. How do you deliver them in order?
A strong answer allocates a slot per request in FIFO order, uses the slot index as the tag, writes completions by tag, and retires from the head only when its done bit is set.
2. Why use the slot index as the tag rather than a free-list?
A strong answer says the slot index needs no search on completion and no separate free-list, because slots free in order. It adds that a free-list fits when retirement is not in order.
3. One request takes far longer than the rest. What happens and what can you do?
A strong answer describes head-of-line blocking, the effect on throughput when the FIFO fills, and options such as more depth, timeouts with error status, or splitting traffic into independent ordering domains.
4. When can a tag be reused safely?
A strong answer says only after the slot retires, and relies on exactly one completion per request. It mentions what breaks with duplicate completions.
5. How would you test it?
A strong answer builds a completer with random order and a latency bound, a scoreboard in allocation order, assertions on stray completions, and coverage of reverse order and full-boundary reuse.
Where it is used in real chips
Completion FIFOs sit in DMA engines that issue many reads at once, in AXI and PCIe bridges that restore ordering for one side of the link, in NoC endpoints that receive split responses from many targets, and in accelerator load units that fetch tiles from several memory channels and must present them in order.
The rest of the series
Part 36 built an almost-full rule that covers the full round-trip latency of the producer's pipeline.
Part 38 takes the same idea into a processor: the reorder buffer, which commits instructions in program order, several per cycle, and handles exceptions at the head.


Your comments will be moderated before it appears here.