Q087FreeDesign Verification
Verify a return-stack trace validator
Interview prompt
Question
Write the format and stack oracle for a validator fed by two independent Universal Verification Methodology (UVM) stream agents, one for push traces and one for pop traces. Equal transaction IDs identify the pair. Values are known unsigned bytes. Empty queues are format errors. On a format error, sequence_valid and fail_pop_index are zero; on a valid sequence, fail_pop_index is also zero. The oracle operates on the already paired complete queues, independently of the arrival order of their stream frames.

Candidate starting point
Implementation scaffold
class trace_oracle;
typedef struct {
bit format_error;
bit sequence_valid;
int unsigned fail_pop_index;
} prediction_t;
function automatic prediction_t predict(
byte unsigned push_q[$], byte unsigned pop_q[$]);
// TODO: implement.
endfunction
endclassReviewed example
Trace one case
Input
id7 push frame=[A,B,C]; id7 pop frame=[C,B,A], with either half allowed to arrive firstExpected output
format_error=0; sequence_valid=1; first_bad_index=0Both halves have equal unique value sets, and simulating the stack reproduces every pop in order.
What to cover
Requirements
- Accept two already assembled 1-to-16-value queues belonging to the same ID and predict format_error for overlength, unequal lengths, duplicate values, or unequal value sets.
- For a well-formed pair, simulate a stack and return sequence_valid or the first impossible pop index.
- Perform all format checks before stack simulation so malformed input is not mislabeled as a legal but impossible sequence.
- Treat frame assembly, four-ID pairing, missing-mate watchdogs, response matching, and reset epochs as follow-up scoreboard architecture.
