Skip to question
ASIC.FYI
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
ASIC.FYI/Interview questions/Reject invalid deallocation

Q291·Free·SystemVerilog

Reject invalid deallocation

Difficulty
Medium
Topic
Memory Systems
Language
SV
Interview prompt

Question

Detect zero-sized, double, partial, and otherwise invalid deallocation requests before they can corrupt the free list.

Starting point

Question code

function bit alloc_checked(
  int unsigned size,
  output int unsigned addr
);

function bit dealloc_checked(
  int unsigned addr,
  int unsigned size
);
Reviewed example

Trace one case

Input
recorded allocation: base=0x1000,size=0x20; dealloc_checked(0x1000,0x10)
Expected output
reject partial deallocation; allocation map and free list unchanged

The base matches but the size does not, so exact allocation metadata prevents silent range corruption.

What to cover

Requirements

  1. Route successful allocations through a wrapper that records size by returned base address.
  2. Require an exact base and size match on deallocation.
  3. Leave allocator state unchanged on failure.
  4. Coalesce the returned interval after successful validation.
Exact question handoffPractice Q291

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
  • Validation
  • Ownership
Interview preparation guide →
Continue practicing

Related questions

Q212 · Memory SystemsBuild a first-fit range allocator→Q276 · Memory SystemsRandomize free-range allocation→Q297 · Memory SystemsMeasure external fragmentation→
ASIC.FYI · Learn silicon end to end.info@asic.fyi