← Design Verification Interviews

Interview Question · Code Writing

A Scoreboard for Out-of-Order Responses

L2 Mid-Leveluvmscoreboardordering

The Question

The interviewer asks

Reads carry an ID, and the DUT may return different IDs in any order. Write the scoreboard.

Reveal the Model Answer

Store the expected responses in an associative array of queues, keyed by ID. On a request, push its expected data onto the queue for its ID. On a response, pop the front of that ID's queue and compare. Use a queue per ID, because responses with the same ID must still return in order on buses such as AXI. At the end, every queue must be empty.

Two Reads with Tag 3, Two Banks, One QueueArrows from a read go to its bank and push a prediction onto pending[3]. Arrows from a bank carry the response, and the arrow from pending[3] is the pop.
Two reads with tag 3, two banks, one queueArrows from a read go to its bank and push a prediction onto `pending[3]`. Arrows from a bank carry the response, and the arrow from `pending[3]` is the pop. request READ tag 3, bank1 taken at 55 ns; modelsays 22 request READ tag 3, bank0 taken at 65 ns; modelsays 11 queue pending[3] [22] at 55 ns, [22,11] at 65 ns bank Bank 1 ready and driven at85 ns bank Bank 0 ready at 75 ns, helduntil the older tag 3has gone; driven at95 ns response Response tag 3 =22 seen at 95 ns:pop_front gives 22,match response Response tag 3 =11 seen at 105 ns:pop_front gives 11,match push 22seen 95seen 105pop_front
  1. 55 ns

    The first tag 3 read is taken. The scoreboard pushes its prediction, 22; the read goes to bank 1.

    Follow the calls, values and waits
    1. data prediction 22: READ tag 3, bank 1 → pending[3]
    2. data READ tag 3 (bank 1): READ tag 3, bank 1 → Bank 1
  2. 65 ns

    The second tag 3 read is taken. Its prediction, 11, goes behind 22; the read goes to bank 0.

    Follow the calls, values and waits
    1. data prediction 11: READ tag 3, bank 0 → pending[3]
    2. data READ tag 3 (bank 0): READ tag 3, bank 0 → Bank 0
  3. 75 ns

    Bank 0 is ready first, but an older tag 3 read is still in bank 1, so the same-tag rule holds it back.

    Follow the calls, values and waits
    1. Waiting: Bank 0 — held behind the older tag 3
  4. 85 ns

    Bank 1 drives 22 at 85 ns. The monitor samples it at the next edge.

  5. 95 ns

    The monitor sees 22, and pop_front returns 22: match. Bank 0 may now drive 11, at 95 ns.

    Follow the calls, values and waits
    1. data response tag 3 = 22: Bank 1 → Response tag 3 = 22
    2. data prediction 22: pending[3] → Response tag 3 = 22
    3. Released: Bank 0
  6. 105 ns

    The monitor sees 11. pop_front returns 11, the only entry left: match, and pending[3] is empty.

    Follow the calls, values and waits
    1. data response tag 3 = 11: Bank 0 → Response tag 3 = 11
Read the diagram as text
  • READ tag 3, bank 1: taken at 55 ns; model says 22
  • READ tag 3, bank 0: taken at 65 ns; model says 11
  • pending[3]: [22] at 55 ns, [22, 11] at 65 ns
  • Bank 1: ready and driven at 85 ns
  • Bank 0: ready at 75 ns, held until the older tag 3 has gone; driven at 95 ns
  • Response tag 3 = 22: seen at 95 ns: pop_front gives 22, match
  • Response tag 3 = 11: seen at 105 ns: pop_front gives 11, match
  • READ tag 3, bank 1 → pending[3]: push 22
  • READ tag 3, bank 0 → pending[3]
  • READ tag 3, bank 1 → Bank 1
  • READ tag 3, bank 0 → Bank 0
  • Bank 1 → Response tag 3 = 22: seen 95
  • Bank 0 → Response tag 3 = 11: seen 105
  • pending[3] → Response tag 3 = 22: pop_front

One queue per tag is the same-tag ordering rule, written as storage. Its front entry always belongs to the next response with that tag.

Search by data

idx = pending.find_first_index(d) with (d == data);

Accepts data that went to the wrong ID

Queue per ID

want = pending[id].pop_front();

Checks the ID and the order within it

Self-Check

Tick each key point you covered in your answer.

What Interviewers Listen For (Mid-Level)

A good mid-level answer first asks which ordering rule the bus keeps. Then it stores expected items by ID, with a queue for each ID.

Cross-Questions

Where the interviewer goes next. Open a node to practise that follow-up.

What IfProve ItBreak ItCompareScale It

  1. A Scoreboard for Out-of-Order Responses
  2. What IfChoosing the Key for Out-of-Order CheckingL2 Mid-Level

    Asked if they key by address

    What if the response carries no ID, only an address?

    Reveal the Model Answer

    Key by whatever the response carries that names its request. If two open requests share a key, the protocol must define their order, or the scoreboard cannot tell them apart. Then ask the designers how the DUT orders them, and check that rule.

    Self-Check

    Tick each key point you covered in your answer.

    Misconception

    "Use the arrival time as the key."

    The response does not carry the request's time, so the scoreboard cannot look it up. Time is a check on latency, not a key.

    Source Verification Academy, UVM Cookbook, Scoreboards: out-of-order comparator keyed by index_id() (PDF p172)

  3. CompareThe Cost of Out-of-Order CheckingL2 Mid-Level

    Compare the cost of an out-of-order scoreboard with an in-order one.

    Reveal the Model Answer

    The in-order version pops one queue, so each check costs constant time. The keyed version adds a lookup and must track what is still open for each key. Its errors are also harder to read, because a lost response shows only at the end or at a timeout. Use it only where the protocol really allows reordering.

    Bank 0 overtakes bank 1
    01234edge (ns)3545556575read taken (tag, bank)1, b12, b0-response tag-21in-order scoreboard expects-12mismatchmismatch

    Both responses are correct. A scoreboard with one in-order queue pairs each with the wrong prediction and reports two mismatches.

    Self-Check

    Tick each key point you covered in your answer.

  4. Break ItCatching a Response That Never ComesL2 Mid-LevelL3 Senior

    How would a response that never comes show up, and how do you catch it early?

    Reveal the Model Answer

    With only an end-of-test check, it appears as one leftover entry after a long run. Stamp each expected entry with its request time. A watchdog then reports any entry older than the allowed latency, with its ID and address. That points straight at the stuck request.

    Self-Check

    Tick each key point you covered in your answer.

    What Interviewers Listen For (Senior)

    A good senior answer gives each expected entry a latency limit. It treats that limit as part of sign-off, not only as a debug aid.

  5. Scale ItChecking an InterconnectL3 SeniorL4 Staff

    Scale it: an interconnect with four masters and three slaves. How does the checking change?

    Reveal the Model Answer

    Keep one keyed scoreboard per master port for its own responses. A routing model maps each address to its slave and checks that each request appears on the right slave port. The interconnect may widen or remap IDs, so the model must apply the same mapping. Finally, a global check makes sure every request ends exactly once.

    Self-Check

    Tick each key point you covered in your answer.

    What Interviewers Listen For (Staff)

    A good staff answer splits the checking into separate models for routing, ordering and data. It names ID remapping by the interconnect as the risky part.

    Missed Corner

    "Compare each master's requests with each slave's requests by ID."

    Interconnects often add bits to the ID to route the response back. The slave sees a different ID from the one the master sent.

    Source Arm IHI 0022L §A5.4 (interconnect use of transaction identifiers)

  6. Prove ItSolve U8.2.1: Interleaved Read BurstsSimulator-graded

    Show it, don't just say it: this Silicon Lab problem is graded by the simulator.

    Open Problem U8.2.1

What People Get Wrong

Common wrong answers and why they fail. Run It shows the wrong belief failing on a real simulator.

Half-Truth

"Search the pending list for a response with matching data."

It finds a match even when the data went to the wrong ID. The twin swaps the data of two IDs, and the search reports no error.

Run It

A design that swaps the read data of IDs 1 and 2, checked by searching for matching data.

RUNVerilator · simulator service
Edit the code, then run it
Expected: errors=0 FAIL: matching by data alone accepted responses that went to the wrong ID
See the Fix
// Reads tagged with an ID may return out of order. This design swaps the data of IDs 1 and 2.
class sb;
  typedef bit [7:0] byte_q[$];
  byte_q pending[int];                // the fix: one in-order queue per ID
  int errors;
  function void expect_read(int id, bit [7:0] data);
    pending[id].push_back(data);
  endfunction
  function void got_read(int id, bit [7:0] data);
    bit [7:0] want;
    if (!pending.exists(id) || pending[id].size() == 0) begin errors++; $display("unexpected id %0d", id); return; end
    want = pending[id].pop_front();
    if (data != want) begin errors++; $display("id %0d: got %0h, expected %0h", id, data, want); end
  endfunction
endclass
module tb;
  sb s = new();
  initial begin
    s.expect_read(1, 8'haa);  s.expect_read(2, 8'hbb);
    s.got_read(2, 8'haa);     s.got_read(1, 8'hbb);
    $display("errors=%0d", s.errors);
    if (s.errors == 2)
      $display("PASS: keyed by ID, both swapped responses were caught");
  end
endmodule

Prints: id 2: got aa, expected bb id 1: got bb, expected aa errors=2 PASS: keyed by ID, both swapped responses were caught

Misconception

"An in-order queue is fine; reordering is rare."

Every legal reordering then shows up as a mismatch, and the team starts waiving errors. Out-of-order checking needs storage keyed by something the response carries.

Source Verification Academy, UVM Cookbook, Scoreboards: comparing transactions out of order (PDF p172)

Missed Corner

"One stored entry per ID is enough."

A master may have several reads open on one ID. A single entry is overwritten by the second request. A queue per ID keeps them in their legal order.

Source Arm IHI 0022L §A5.3 (request ordering: same-ID responses return in request order)

Learn It, Then Prove It