Part 7 · Environment & Tests · Intermediate

Dual-Stream Checking: Expected vs Observed Correlation

Correlating expected and observed streams with IDs, timing windows, and deterministic mismatch diagnostics.

Correlation model

Dual-stream checking compares predicted intent with monitor-observed truth. Correlate via transaction IDs and bounded timing windows.

diagram
[ENV][UVM][CHECK] dual-stream pipeline

expected stream:
  predictor/model -> exp_q[id]

observed stream:
  monitor -> obs_q[id]

correlator:
  if id in both queues -> compare
  if timeout on one side -> missing counterpart error
systemverilog
task correlate_loop();
  forever begin
    if (exp_q.exists(id) && obs_q.exists(id)) begin
      compare_pair(exp_q[id], obs_q[id]);
      exp_q.delete(id);
      obs_q.delete(id);
    end
    check_timeouts();
    @(posedge vif.clk);
  end
endtask
  • IDs should be protocol-meaningful and stable across transformations.

  • Timeout policy must be explicit and reviewed.

  • Diagnostics should show both expected and observed snapshots.

Key takeaways

  • Reliable correlation is the heart of scoreboard trust.

  • Timeouts are correctness logic, not optional debug aids.

Common pitfalls

  • Comparing in arrival order when protocol allows reordering.

  • Using weak IDs that collide under stress traffic.


Applied Patterns

Keep dual-stream state machine explicit so out-of-order and retry flows remain debuggable.

diagram
[CHECK] correlation states

IDLE
  -> WAIT_EXP / WAIT_OBS
  -> BOTH_READY
  -> COMPARE
  -> DONE or MISMATCH

retry path:
  mark provisional
  re-correlate on final response
systemverilog
function void compare_pair(txn exp, txn obs);
  compare_hits++;
  if (!exp.compare(obs)) begin
    mismatch_hits++;
    `uvm_error("CMP",
      $sformatf("id=%0d exp=%s obs=%s", exp.id, exp.sprint(), obs.sprint()))
  end
endfunction
  • State labels make triage simpler than ad-hoc queue logic.

  • Print ID and key fields on every mismatch.

  • Retry handling should be visible, not implicit.


Integration Drilldown

Inject reordered responses and confirm correlation remains stable without false mismatches.

diagram
[CHECK] reorder validation

sequence:
  issue IDs 10,11,12
  observe responses 11,10,12

expect:
  compare_hits == 3
  mismatch_hits == 0
  timeout_hits == 0

Key takeaways

  • Reorder validation proves correlation correctness under realistic behavior.

Common pitfalls

  • Assuming in-order behavior in protocols that permit reordering.