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
DescriptionQ256
Page ↗
Q256ArchFollow-up to Q283ASIC interview problem

Return every page at the kth density rank

TechniquesDense rankingSortingAssociative array
DifficultyMedium
TopicMemory Systems
LanguageSystemVerilog
Requirements4 checkpoints
01

Problem

Rank distinct page-density values from highest to lowest and return every 4 KiB page whose density equals the kth distinct level.

Function headerSystemVerilog
function automatic void kth_dense_pages_4kb(
  input bit [31:0] mem[longint unsigned],
  input int unsigned k,
  output longint unsigned pages_at_rank[$],
  output int unsigned density
);

Example input and output

Use this case to check your interpretation
Input
page densities={0x1000:3,0x2000:1,0x3000:3,0x4000:2}; k=2
Output
[0x4000]
Explanation

Distinct density ranks are 3, 2, and 1, so the second rank contains only page 0x4000.

02

Requirements (4)

  • Treat equal densities as one rank.
  • Use one-based k and return empty for k equal to zero or out of range.
  • Return all pages at the selected rank.
  • Sort equal-density outputs by page base.