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
DescriptionQ283
Page ↗
Q283ArchASIC interview problem

Find the densest 4 KiB page

TechniquesAssociative arrayAddress alignmentHistogram
DifficultyEasy
TopicMemory Systems
LanguageSystemVerilog
Requirements4 checkpoints
01

Problem

Given an associative array keyed by written addresses, return the 4 KiB-aligned page base containing the most keys and its density.

Six addresses grouped into three aligned four-kibibyte page bins with counts
Clear the low twelve address bits to form each page base, then compare the resulting densities.
Function headerSystemVerilog
function automatic void densest_page_4kb(
  input bit [31:0] mem[longint unsigned],
  output longint unsigned densest_page,
  output int unsigned density
);

Example input and output

Use this case to check your interpretation
Input
written addresses=[0x1004,0x1010,0x1FFC,0x2000]
Output
page_base=0x1000; density=3
Explanation

The first three keys share page number 1 after shifting by 12; the fourth belongs to page 0x2000.

02

Requirements (4)

  • Count keys by shifting each address right by 12.
  • Return the page base, not the page number.
  • Return zero outputs for an empty input.
  • Break equal-density ties in favor of the lower page base.