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
DescriptionQ276
Page ↗
Q276ArchFollow-up to Q212ASIC interview problem

Randomize free-range allocation

TechniquesAllocatorRandomizationInterval splitting
DifficultyMedium
TopicMemory Systems
LanguageSystemVerilog
Requirements4 checkpoints
01

Problem

Allocate from a randomly selected sufficient free range, then choose a valid random start within that range.

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

Example input and output

Use this case to check your interpretation
Input
free=[[0x1000,0x10FF],[0x2000,0x20FF]]; request size=0x40
Output
One valid randomized result: base=0x2040; remaining selected-range fragments=[[0x2000,0x203F],[0x2080,0x20FF]]
Explanation

Either free range and several starts are legal. This result demonstrates preservation of both prefix and suffix, so it is not the only valid random outcome.

02

Requirements (4)

  • Choose uniformly among eligible ranges.
  • Choose a valid start in the selected range.
  • Preserve both unused prefix and suffix fragments.
  • Return 0 without mutating state when no range is sufficient.