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_idxis the lowest-numbered free slot, andalloc_oksays there is one. Both are combinational.- When
allocis 1 andalloc_okis 1, that slot becomes busy at the rising edge. - When
free_enis 1, slotfree_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.