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
DescriptionQ297
Page ↗
Q297ArchFollow-up to Q212ASIC interview problem

Measure external fragmentation

TechniquesAllocatorFragmentationMetrics
DifficultyEasy
TopicMemory Systems
LanguageSystemVerilog
Requirements4 checkpoints
01

Problem

Report total free capacity, the largest contiguous free block, and a defined external-fragmentation ratio.

Function headerSystemVerilog
function void fragmentation_metrics(
  output longint unsigned total_free,
  output int unsigned largest_block,
  output real external_ratio
);

Example input and output

Use this case to check your interpretation
Input
free=[[0,9],[20,24]]
Output
total_free=15; largest_block=10; external_ratio=1-10/15=0.3333
Explanation

Inclusive sizes are 10 and 5, and the largest-to-total fraction is subtracted from one.

02

Requirements (4)

  • Measure inclusive range sizes correctly.
  • Return zeros for an empty free list.
  • Define external_ratio as 1 minus largest_block divided by total_free.
  • Avoid division by zero.