Q198FreeDesign Verification
Cover arbitrary type and priority values
Interview prompt
Question
Types and priorities are arbitrary integer values rather than contiguous ranges starting at zero. Track their cross and determine when every pair from the declared expected sets has been observed. If either expected set is empty, all_combinations_hit returns false and first_missing returns false with both output values zero. Once both sets are nonempty, first_missing returns the first missing pair in ascending type then priority order, or false with zeroed outputs after complete coverage.
Candidate starting point
Implementation scaffold
class SparseCoverageGapDetector;
local bit expected_type[int];
local bit expected_prio[int];
local bit seen[int][int];
function void add_expected_type(int value);
// Implement here: add_expected_type.
endfunction
function void add_expected_priority(int value);
// Implement here: add_expected_priority.
endfunction
function void sample(int type_value, int priority_value);
// Implement here: sample.
endfunction
function bit all_combinations_hit();
int type_key, priority_key;
// Implement here: all_combinations_hit.
endfunction
function bit first_missing(output int miss_type,
output int miss_prio);
// Implement here: first_missing.
endfunction
endclassReviewed example
Trace one case
Input
expected types={2,7}, priorities={1,9}; sample (2,1),(7,9), then invalid (3,1)Expected output
first_missing=(2,9); invalid sample rejected; all_hit=0The sparse universe is the declared Cartesian product, not values inferred from traffic; type 3 lies outside that universe.
What to cover
Requirements
- Receive finite expected type and priority sets and de-duplicate their values.
- Store observed pairs sparsely in associative arrays.
- Reject samples containing a value outside either expected set.
- Support all-hit and first-missing queries.
- Do not infer the expected universe from observed traffic.
