
A plain FIFO knows nothing about what it holds. It moves words in order and forgets them once they leave. Real queues on a chip rarely stay that simple. A request queue in a DMA engine needs to know which transaction each entry belongs to. A load queue needs to mark an entry as done when its data comes back. A packet queue carries a destination, a class and an error bit next to every payload. The moment an entry carries a name and a few status bits, you have a tagged FIFO.
This is Part 18 of the FIFO series. It covers tags and metadata: where the tag comes from, how to store sideband bits next to the data, how to update an entry in place while it waits in the queue, and how to catch an update that arrives for an entry that has already left.
Key takeaways
- A tagged FIFO stores a tag and a small metadata field with every entry, and returns the tag at the push so other logic can refer to the entry later.
- The cheapest tag is the write pointer itself, including its wrap bit. It is unique among live entries and needs no allocator.
- One subtraction tells whether a tag is still live: the tag is live when its distance from the read pointer is less than the count.
- An update to the head in the same cycle it pops must not be lost. A small bypass into the head metadata fixes it.
- Keep wide data in SRAM and narrow metadata in flip-flops, so in-place updates never need a read-modify-write on the memory.
In this part
- What problem a tagged FIFO solves
- The interface
- Where tags come from
- Live tags and stale updates
- 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 a tagged FIFO solves
Two needs push a FIFO toward tags. The first is identity. When a request leaves a queue and its response comes back many cycles later, the response has to find its way back to the right place. A tag handed out at the push is the handle for that. The second is state. An entry often waits in the queue for something to happen: data to arrive, a permission check to finish, an error to be reported. The queue is the natural place to record that, so the consumer at the head can see in one look whether the entry is ready to go.
A separate table could hold that state, but then two structures must agree about which entries exist. Keeping the metadata in the FIFO, keyed by its own tag, gives one source of truth. The order stays strict first in, first out. Only the sideband bits change while an entry waits.
The interface

The write side has the usual push, wdata and full, plus wmeta for the initial metadata and push_tag, the tag of the entry being written in this cycle. The read side has pop and empty, and shows the head entry as rdata, rmeta and rtag before the pop, so the consumer can decide from the metadata whether to take it.
The new piece is an update port: upd, upd_tag and upd_set, which sets metadata bits in the entry named by the tag. It returns upd_stale when the tag does not name a live entry. Setting bits with an OR is deliberate: status bits such as done or error only move from 0 to 1 while an entry waits, and two ORs can never undo each other.
Where tags come from
There are three common sources, in order of cost.
- The write pointer. The slot index plus the wrap bit, exactly the pointer from Part 1. It is free, unique among live entries, and lets an update index the metadata directly. But a tag is reused as soon as its slot is.
- A wider sequence number. A counter a few bits wider than the pointer, stored per entry. The extra bits act as a generation count, so a stale tag is less likely to alias a live one.
- A tag supplied by the producer. Such as a bus transaction ID. Now the FIFO must search for it, and IDs can repeat. That is Part 19 and Part 21.
This part uses the first option and stores no tag bits at all: the tag of an entry is its pointer value, recovered from the read pointer at the head.
Live tags and stale updates

Updates often arrive many cycles after the push. By then the entry may have popped and its slot may hold a newer entry, which a blind write would corrupt. So every update is checked first.
With pointers that carry one wrap bit, the check is one subtraction and one compare. Take the distance from the read pointer to the tag, modulo twice the depth. If that distance is less than the current count, the tag sits between the read and write pointers and names a live entry. If not, it is either a tag that has already left or a tag that has not been issued yet, and the update is dropped and flagged.
The check has a limit. With only one generation bit, the tag space is twice the depth. A stale tag that comes back late enough will fall inside the live window again and alias a newer entry. Working through the modular arithmetic, a stale tag is always caught if it returns within DEPTH pops of its entry leaving. If the update path can be slower than that, widen the tag with more generation bits, or guarantee by design that an entry cannot pop until its updates are in, which is often the cleaner answer.
RTL sketch
A flip-flop FIFO with a show-ahead head, an OR-update port keyed by tag, and a bypass so an update to the head is visible in the same cycle:
module tagged_fifo #(
parameter int W = 64,
parameter int MW = 4, // metadata bits
parameter int DEPTH = 16, // power of two
localparam int AW = $clog2(DEPTH)
) (
input logic clk,
input logic rst_n,
input logic push,
input logic [W-1:0] wdata,
input logic [MW-1:0] wmeta,
output logic [AW:0] push_tag,
output logic full,
input logic upd,
input logic [AW:0] upd_tag,
input logic [MW-1:0] upd_set,
output logic upd_stale,
input logic pop,
output logic [W-1:0] rdata,
output logic [MW-1:0] rmeta,
output logic [AW:0] rtag,
output logic empty
);
logic [W-1:0] data [DEPTH];
logic [MW-1:0] meta [DEPTH];
logic [AW:0] wptr, rptr;
wire [AW:0] count = wptr - rptr;
wire [AW:0] offset = upd_tag - rptr; // distance from the head
wire upd_ok = upd && (offset < count); // tag is live
wire do_pop = pop && !empty;
wire do_push = push && (!full || do_pop);
assign empty = (wptr == rptr);
assign full = (count == DEPTH);
assign push_tag = wptr;
assign upd_stale = upd && !upd_ok;
assign rtag = rptr;
assign rdata = data[rptr[AW-1:0]];
assign rmeta = meta[rptr[AW-1:0]]
| ((upd_ok && upd_tag == rptr) ? upd_set : '0); // head bypass
always_ff @(posedge clk or negedge rst_n)
if (!rst_n) begin
wptr <= '0;
rptr <= '0;
end else begin
if (do_push) wptr <= wptr + 1'b1;
if (do_pop) rptr <= rptr + 1'b1;
end
always_ff @(posedge clk) begin
if (upd_ok) meta[upd_tag[AW-1:0]] <= meta[upd_tag[AW-1:0]] | upd_set;
if (do_push) begin // later assignment wins on a slot clash
data[wptr[AW-1:0]] <= wdata;
meta[wptr[AW-1:0]] <= wmeta;
end
end
endmodule
The order of the two writes in the last block matters. When the FIFO is full and a push and pop happen together, the push writes the slot the head is leaving. If an update targets that departing head in the same cycle, both writes hit the same metadata slot. The push must win, because the slot now belongs to the new entry, and the update has already reached the consumer through the bypass on rmeta.
Corner cases

- Update to the head in the cycle it pops. Cycle 5 in the diagram. Without the bypass, the consumer takes the entry with the old metadata and the update lands in a freed slot. It is the bug most likely to escape, because two independent events must line up.
- Update after the entry left. Cycle 7. The tag is outside the live window, so
upd_stalefires and the metadata array is untouched. Decide in the spec whether a stale update is legal and ignored, or a protocol error that should raise an alarm. - Update with a tag that was never issued. The same check catches it, because its distance from the read pointer is at least the count.
- Push and update to the same slot. Only possible when full with a push and pop together, as described above. The push wins.
- Two updates, or set and clear. A second update port can OR into the same entry safely. If bits can also be cleared, define which wins in the same cycle and what the bypass shows.
Timing, area and power
- Split the storage. Payload is wide and written once. Metadata is narrow and written many times. Put the payload in SRAM and the metadata in flip-flops. An in-place update to an SRAM would need a read, a merge and a write, which costs a port or a cycle. In flops it is a single enable.
- The live check. The subtraction and compare are only AW+1 bits wide. The longer path is
upd_okfanning out to every metadata write enable. For deep FIFOs, register the update and apply it a cycle later, and widen the head bypass to cover it. - The head bypass. One equality compare and an OR on MW bits in front of
rmeta. If the consumer's pop decision already sits on a tight path, this adds a few gate levels to it. The alternative is a rule that an entry with an update in flight cannot pop, which moves the cost into the consumer. - Power. Clock gate each metadata row on its own write enable.
Verification checklist
- A scoreboard that keeps a reference queue of tag, data and metadata, applies each accepted update to the matching reference entry, and checks the full head tuple at every pop.
- A check that every issued tag is unique among live entries, and that the tag seen at the pop equals the tag returned at the push.
- Assertions:
The second one says metadata bits on the head never clear while the head waits.a_stale_exact: assert property (@(posedge clk) disable iff (!rst_n) upd |-> (upd_stale == (((upd_tag - rptr) & MASK) >= count))); a_meta_mono: assert property (@(posedge clk) disable iff (!rst_n) !empty && !pop |=> ((rmeta & $past(rmeta)) == $past(rmeta))); - Coverage: update to the head with a pop in the same cycle, update to the head with a push and pop at full, stale update one cycle after the pop, stale update DEPTH pops later, and update with a never-issued tag.
A cycle-accurate Python model of this RTL ran 600,000 random cycles at depths 2, 4, 8 and 16 against a reference queue, with all of the corner cases above hit thousands of times, and matched on every pop.
Interview questions
1. Why use the write pointer as the tag?
A strong answer says it is unique among live entries, costs no storage and no allocator, and lets an update index the metadata array directly. It then names the limit: the tag is reused when the slot is, so stale tags need a guard.
2. How do you know whether an incoming tag is still in the queue?
A strong answer gives the modular distance from the read pointer compared against the count, explains why it also rejects tags not yet issued, and works out how late a stale tag can return before it aliases.
3. An update hits the head in the cycle it pops. What happens in your design?
A strong answer spots that the update would otherwise be lost, adds a bypass into the head metadata, and resolves the write clash with a same-cycle push at full in favor of the push.
4. The payload is 512 bits and the FIFO is 64 deep. Where do you put the metadata?
A strong answer keeps the payload in SRAM and the metadata in flops, explains that in-place updates on SRAM need a read-modify-write, and mentions per-row clock gating on the metadata.
5. How would you make stale detection safe for very late updates?
A strong answer widens the tag with generation bits stored per entry, or changes the protocol so an entry cannot pop while an update for it is outstanding, and compares the area of each.
Where it is used in real chips
Tagged queues are everywhere requests and responses are separated in time. DMA engines tag descriptors so completions can mark them done. Load and store queues in processors carry status bits that are set as addresses resolve and data returns. NoC routers and bridges carry routing and quality-of-service fields next to each flit. PCIe and AXI interface blocks keep per-request metadata such as length, attributes and error status beside the buffered request, and accelerators use the same structure to track work items through a pipeline.
The rest of the series
Part 17 covered the priority FIFO: serving urgent entries first without starving the rest.
Part 19 lets the producer choose the ID: the ID-aware FIFO, where IDs can repeat and the queue must answer whether an ID is present and how many times.


Your comments will be moderated before it appears here.