Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Count connected fault regions in a tile map

Hardware interview practice

Count connected fault regions in a tile map

MediumRTL DesignSystemVerilog

Accept a row-major fault bitmap up to 8 by 8 pixels and report how many 4-connected components contain a one. Diagonal contact alone does not connect regions.

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
width=3,height=3; row-major fault bitmap rows=[110,010,001]
Expected output
component_count=2

The upper three set cells are four-connected; the bottom-right bit touches only diagonally and therefore forms a second component.

What to cover

Requirements

  1. Capture a width and height from 1 through 8, followed by exactly width x height pixels.
  2. Use fixed-size frame storage, a visited bitmap, and a bounded stack or queue; do not use recursion or dynamic allocation.
  3. Check row and column boundaries before enqueuing each of the four neighbors.
  4. Mark a cell visited when it enters the work list so it cannot be inserted more than once.
  5. Hold component_count and result_valid stable under backpressure and complete internal work within 2048 cycles.
asic.fyi · Learn silicon end to end.info@asic.fyi