Skip to question
ASIC.FYI
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
ASIC.FYI/Interview questions/Return every page at the kth density rank

Q256·Free·SystemVerilog

Return every page at the kth density rank

Difficulty
Medium
Topic
Memory Systems
Language
SV
Interview prompt

Question

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

Starting point

Question code

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
);
Reviewed example

Trace one case

Input
page densities={0x1000:3,0x2000:1,0x3000:3,0x4000:2}; k=2
Expected output
[0x4000]

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

What to cover

Requirements

  1. Treat equal densities as one rank.
  2. Use one-based k and return empty for k equal to zero or out of range.
  3. Return all pages at the selected rank.
  4. Sort equal-density outputs by page base.
Exact question handoffPractice Q256

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
  • Dense ranking
  • Sorting
  • Associative array
Interview preparation guide →
Continue practicing

Related questions

Q283 · Memory SystemsFind the densest 4 KiB page→Q284 · Memory SystemsReturn the top K densest pages→Q242 · Memory SystemsEstimate the densest page in a bounded stream→
ASIC.FYI · Learn silicon end to end.info@asic.fyi