Skip to question
ASIC.FYI
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
ASIC.FYI/Interview questions/Compact live allocations

Q277·Free·SystemVerilog

Compact live allocations

Difficulty
Hard
Topic
Memory Systems
Language
SV
Interview prompt

Question

Compact live allocations toward the allocator base, return an old-to-new relocation map, and rebuild one consolidated free interval.

Starting point

Question code

function void compact(
  ref int unsigned relocated_addr[int unsigned]
);
Reviewed example

Trace one case

Input
allocator=[0,99]; live blocks=(base=10,size=20),(base=50,size=10)
Expected output
relocations={10->0,50->20}; consolidated free range=[30,99]

Packing in allocation order keeps blocks nonoverlapping and advances the final free cursor to 30.

What to cover

Requirements

  1. Track live allocation bases and sizes.
  2. Preserve allocation order and prevent overlap during conceptual movement.
  3. Return a relocation entry for every moved allocation.
  4. Rebuild the free list from the final packed cursor to the allocator limit.
Exact question handoffPractice Q277

Solve it in the question bank, keep your progress, and reveal the reviewed solution when your access allows.

Open in question bank →
Solution accessA Free account unlocks the complete reviewed solution.
Continue learning

SystemVerilog

  • Memory Systems
  • Allocator
  • Compaction
  • Relocation
Interview preparation guide →
Continue practicing

Related questions

Q212 · Memory SystemsBuild a first-fit range allocator→Q276 · Memory SystemsRandomize free-range allocation→Q263 · Memory SystemsMake the allocator thread-safe→
ASIC.FYI · Learn silicon end to end.info@asic.fyi