Skip to the selected question
ASIC.FYI

ASIC Question Bank

1,000+ hardware interview questions
DescriptionQ897
Q897FWASIC interview problem

Intersect redundant-core fault lists

TechniquesFWArraysMultisetCapacityMemory safety
DifficultyEasy
TopicFirmware Algorithms
LanguageSystemVerilog
Requirements4 checkpoints
01

Problem

Return the multiset intersection of two bounded fault-ID lists, preserving the first list's encounter order and consuming each match only once.

Type declarationSystemVerilog
typedef enum { IX_OK, IX_EINVAL, IX_ENOSPC } ix_rc_t;
ix_rc_t fault_intersection(const uint16_t *a, size_t na,
                           const uint16_t *b, size_t nb,
                           uint16_t *out, size_t cap,
                           size_t *nout);
// na and nb are at most 32.

Example input and output

Use this case to check your interpretation
Input
A=[5,2,5,7]; B=[5,5,8]
Output
intersection=[5,5]
Explanation

Both copies of 5 are consumed once in A encounter order; 2 and 7 have no available match.

02

Requirements (4)

  • Emit each identifier min(count_a, count_b) times in A's encounter order.
  • Use fixed state for at most 32 entries and do not modify either input.
  • Count the complete result before writing and return no-space without exposing a partial output.
  • Validate pointers, lengths, arithmetic, and output/input overlap while preserving all outputs on error.