Skip to the selected question
ASIC.FYI

ASIC Question Bank

1,000+ hardware interview questions
DescriptionQ295
Page ↗
Q295ArchASIC interview problem

Report the top-K opcode frequencies

TechniquesHistogramTop KRankingDeterministic tie
DifficultyMedium
TopicStreaming Algorithms
LanguageSystemVerilog
Requirements5 checkpoints
01

Problem

Count the opcode IDs in a completed packet frame and emit up to K distinct opcodes in descending frequency order, breaking equal counts by lower opcode ID.

Example input and output

Use this case to check your interpretation
Input
accepted opcodes = [3, 1, 3, 2, 1, 3]; K=2
Output
ranked outputs = [(opcode=3,count=3), (opcode=1,count=2)]
Explanation

Opcode 3 has the highest frequency and opcode 1 is the next distinct frequency winner.

02

Requirements (5)

  • Support opcode IDs 0 to 15, frame lengths from 1 to 64, and K from 1 to 4 captured with the first item.
  • Clear or invalidate all 16 histogram bins between frames.
  • Do not select an opcode twice and never emit an absent opcode.
  • If fewer than K distinct opcodes appear, emit only those present.
  • Begin ranking only after the frame is complete and hold each output token stable while stalled.