Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Optimize nonadjacent bank activation

Hardware interview practice

Optimize nonadjacent bank activation

MediumHardware AlgorithmsSystemVerilog

Choose a maximum-benefit subset of static random-access memory (SRAM) banks when adjacent banks may not be active in the same maintenance interval. Return the total score and exact selection mask.

Try it in the question bankReason first. Then compare.

Keep this exact question selected while you check your answer and review the full solution.

Practice this question →
Reviewed example

Work through one case

Input
benefit by bank = [5, 1, 4, 9, 2]
Expected output
score=14; selected_mask=5'b01001; selected_count=2

Banks 0 and 3 are nonadjacent and total 14, which exceeds every other legal subset.

What to cover

Requirements

  1. Accept a frame of 1 to 16 unsigned eight-bit benefits; the first and last banks are not adjacent.
  2. Select no adjacent pair and maximize the total benefit.
  3. On a score tie, prefer fewer selected banks; if still tied, prefer the mask that selects the first differing lower-index bank.
  4. Clear mask bits above the frame length and return the selected-bank popcount.
  5. Hold the final score, mask, and count stable while stalled.
Continue practicing

Related questions

Hardware AlgorithmsMinimize descriptor count for a payload→
asic.fyi · Learn silicon end to end.info@asic.fyi