Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Count unique detected faults

Hardware interview practice

Count unique detected faults

MediumPhysical Design and DFTC++

Each test reports a bit mask of detected stuck-at faults. Several tests may detect the same fault. Write a C++ function that computes unique coverage in parts per million.

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 →
Starting point

Question code

int fault_coverage(const uint64_t *masks, size_t tests,
unsigned total_faults,
unsigned *detected, unsigned *ppm);
Reviewed example

Work through one case

Input
masks = {0b0011, 0b0110}, tests = 2, total_faults = 4.
Expected output
detected = 3 and ppm = 750000.

The union mask is 0b0111 with three unique faults, and floor(3 * 1,000,000 / 4) is 750000.

What to cover

Requirements

  1. Require detected and ppm, total_faults in 1..64, and masks nonnull when tests>0; return -1 and preserve outputs otherwise.
  2. OR all test masks, then ignore bits at indices total_faults and above.
  3. Set detected to the population count of the remaining union and ppm=floor(detected*1000000/total_faults).
  4. Use a wide enough intermediate for the multiplication; on success return 0.
asic.fyi · Learn silicon end to end.info@asic.fyi