RTL Design #38 · 2026-10-31 · Free lists · Medium · about 15 min

An allocator that says full one cycle too long

slot_alloc hands out four slots (0 to 3), for example entries of a small table:

  • alloc_idx is the lowest-numbered free slot, and alloc_ok says there is one. Both are combinational.
  • When alloc is 1 and alloc_ok is 1, that slot becomes busy at the rising edge.
  • When free_en is 1, slot free_idx (always a busy one) becomes free at the rising edge.
  • A slot that is being released in this cycle can be handed out in this cycle, even when every other slot is busy. If it is the lowest free slot, it is the one in alloc_idx.
  • rst_n (synchronous, active low) frees every slot.

Under load the allocator reports "full" in cycles where it shouldn't. Fix slot_alloc.sv.

Write and run your answer in the browser. The hidden tests check it, and it’s free.