Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Minimize descriptor count for a payload

Hardware interview practice

Minimize descriptor count for a payload

MediumHardware AlgorithmsSystemVerilog

Express a target payload length as an exact sum of supported transfer-block sizes while using the fewest descriptors. Return one count per original size slot, or report that no decomposition exists.

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
target=18; block sizes in original slot order = [6, 4, 9]
Expected output
reachable=1; descriptor_count=2; slot_counts=[0, 0, 2]

Two 9-byte blocks are an exact decomposition and no one-descriptor block equals 18.

What to cover

Requirements

  1. Support target lengths from 0 to 64 and one to four unique positive block sizes supplied in any order.
  2. Treat target zero as a valid zero-descriptor result and represent unreachable totals explicitly.
  3. On equal descriptor counts, prefer more uses of the largest block size, then the next largest.
  4. Keep enough fixed-size metadata to return counts in the original input-slot order.
  5. Hold the response stable under backpressure.
Continue practicing

Related questions

Hardware AlgorithmsOptimize nonadjacent bank activation→
asic.fyi · Learn silicon end to end.info@asic.fyi