Skip to question
SystemVerilogDesignVerificationFirmwareArchitectureASIC Interview Questions→
/Interview questions/Detect missing type-priority coverage

Q178·Free·Design Verification

Detect missing type-priority coverage

Difficulty
Medium
Topic
Functional Coverage
Language
SV
Interview prompt

Question

Given packets containing type, size, and priority fields, track the type-by-priority cross without built-in covergroups. Report whether every expected pair has been observed and return the first missing pair.

Candidate starting point

Implementation scaffold

class CoverageGapDetector;
  typedef struct packed {
    int type_id;
    int size;
    int prio;
  } packet_t;

  local bit hit[];
  local int num_types;
  local int num_prios;
  local int domain_size;

  function new(int num_types, int num_prios);
    longint signed total = longint'(num_types) * longint'(num_prios);
    if (num_types <= 0 || num_prios <= 0 || total > 32'sh7fff_ffff)
      $fatal(1, "positive coverage dimensions must fit the dense array index range");
    this.num_types = num_types;
    this.num_prios = num_prios;
    domain_size = int'(total);
    hit = new[domain_size];
  endfunction

  function void sample(packet_t p);
    int index;
    // Implement here: sample.
  endfunction

  function bit all_combinations_hit();
    int hit_count = hit.sum() with (int'(item));
    // Implement here: all_combinations_hit.
  endfunction

  function void first_missing(output int miss_type,
                              output int miss_prio);
    // Implement here: first_missing.
  endfunction
endclass
Reviewed example

Trace one case

Input
type_count=2, priority_count=2; sample (0,0),(0,1),(1,0)
Expected output
all_combinations_hit=0; first_missing=(1,1)

Three unique pairs set three cells in the dense 2x2 domain, leaving the row-major final pair unobserved.

What to cover

Requirements

  1. Validate both lower and upper bounds of the sampled type and priority values.
  2. Count repeated observations of the same pair only once.
  3. Implement all_combinations_hit and first_missing queries.
  4. Use dense storage proportional to the declared domain. Constructor dimensions must be positive and their product must fit the signed 32-bit dynamic-array size/index range; reject other dimensions before allocation.
  5. Do not use a SystemVerilog covergroup.
Exact question handoffPractice Q178

Solve it in the question bank, keep your progress, and reveal the reviewed solution when your access allows.

Open in question bank →
Solution accessEach time you open this Solution, one Practice Credit is used; it is not permanently unlocked. Premium Solution content also uses one credit per opening.
Continue learning

Coverage Bins and Crosses

Review covergroups, bins, transitions, crosses, exclusions, and model size.

  • Functional Coverage
  • Cross coverage
  • Bitmap
  • Missing bin
Coverage Bins and Crosses →
Continue practicing

Related questions

Q198 · Functional CoverageCover arbitrary type and priority valuesMedium→Q370 · Functional CoverageReport current cross-coverage percentageEasyP→Q371 · Functional CoverageTrack a sparse three-way packet crossMediumP→Q211 · Functional CoverageExclude illegal coverage combinationsMediumP→Q292 · Functional CoverageCross coverageEasyP→
ASIC.FYI · Learn silicon end to end.info@asic.fyi