Skip to the selected question
ASIC.FYI

ASIC Interview Question Bank

1,000+ hardware interview questions.Curated and reviewed by industry engineers.1,000+ hardware questions1,000+ questionsEngineer-reviewed
DescriptionQ291
Page ↗
Q291ArchFollow-up to Q212ASIC interview problem

Reject invalid deallocation

TechniquesAllocatorValidationOwnership
DifficultyMedium
TopicMemory Systems
LanguageSystemVerilog
Requirements4 checkpoints
01

Problem

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

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

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

Example input and output

Use this case to check your interpretation
Input
recorded allocation: base=0x1000,size=0x20; dealloc_checked(0x1000,0x10)
Output
reject partial deallocation; allocation map and free list unchanged
Explanation

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

02

Requirements (4)

  • Route successful allocations through a wrapper that records size by returned base address.
  • Require an exact base and size match on deallocation.
  • Leave allocator state unchanged on failure.
  • Coalesce the returned interval after successful validation.