Timeout Detection
Detect missing responses and stalled protocol activity using explicit timing rules, transaction deadlines, and useful failure diagnostics.
Learning objectives
- Explain why a scoreboard alone cannot reliably detect a missing response.
- Define a timeout from a precise protocol acceptance event to a precise response event.
- Distinguish simulation-time timeouts from cycle-based protocol timeouts.
- Track deadlines for multiple outstanding transactions, including out-of-order responses.
- Handle reset correctly so old timeout state does not create false failures.
- Produce diagnostics that identify the transaction, elapsed time, deadline, and checker state.
- Distinguish a genuine timeout from normal end-of-test draining.
Why timeout detection is different from scoreboard checking
A scoreboard can detect that an observed response does not match an expected response. It can also know that an expected transaction is still outstanding.
But an outstanding transaction does not automatically mean that the DUT has failed.
Consider this sequence:
t=100 ns Request ID=42 accepted
t=120 ns ID=42 still outstanding
t=150 ns ID=42 still outstanding
t=180 ns Response ID=42 arrives
If the protocol permits a response within 100 ns, this is legal. If the maximum allowed latency is 50 ns, it is a timeout.
Therefore, timeout detection requires three things:
- A defined start event — when the timeout clock begins.
- A defined completion event — what counts as the required response.
- A deadline — how long the response is allowed to take.
Step 1: Define the timeout boundary precisely
The most important design decision is deciding when the timer starts.
For a handshake-based protocol, a request may be accepted only when both sides agree:
accept_request = req_valid && req_ready;
The timeout should normally start at the transaction's acceptance, not merely when the driver begins presenting the request.
Driver begins request
|
v
valid = 1
|
| waiting for ready
v
valid && ready <-- transaction accepted
|
| timeout window begins
v
response accepted
|
v
success
If the timer starts when the driver starts driving the request, backpressure can incorrectly consume part of the response timeout.
Likewise, the response completion event must be protocol-defined. Depending on the interface, it might be:
- a response handshake,
- a valid response transaction reconstructed by the monitor,
- a completion indication, or
- another protocol-specific acceptance event.
Do not start or stop timers from arbitrary signal transitions simply because they are convenient.
Step 2: Choose the timeout unit
There are two common approaches.
Simulation-time timeout
A requirement might state:
Request accepted -> response must arrive within 500 ns
SystemVerilog can represent time directly:
time start_time;
time timeout_limit = 500ns;
start_time = $time;
// Later...
if (($time - start_time) > timeout_limit)
`uvm_error("TIMEOUT", "Response exceeded timeout")
The exact time-unit representation depends on the compilation environment and `timescale/timeunit settings, so reusable components should define their timing assumptions clearly.
Cycle-based timeout
For synchronous protocols, the requirement may instead be expressed as:
Response must be accepted within 20 clock cycles.
A cycle counter can then provide a protocol-oriented definition:
request_cycle = cycle_count;
deadline_cycle = request_cycle + MAX_LATENCY;
if (current_cycle > deadline_cycle)
`uvm_error("TIMEOUT", "Response exceeded cycle limit")
Cycle-based checking is often easier to interpret for synchronous interfaces because the requirement maps directly to protocol clocks.
Step 3: Track one outstanding transaction
Start with the simplest possible case: one request can be outstanding at a time.
class timeout_checker extends uvm_component;
`uvm_component_utils(timeout_checker)
bit waiting_for_response;
int unsigned request_id;
time start_time;
time timeout_limit = 500ns;
function new(string name = "timeout_checker",
uvm_component parent = null);
super.new(name, parent);
endfunction
function void request_accepted(packet req);
waiting_for_response = 1;
request_id = req.id;
start_time = $time;
endfunction
function void response_received(packet rsp);
if (!waiting_for_response) begin
`uvm_error("TIMEOUT_CHK",
$sformatf(
"Response ID=%0d arrived with no outstanding request",
rsp.id))
return;
end
if (rsp.id != request_id) begin
`uvm_error("TIMEOUT_CHK",
$sformatf(
"Expected response ID=%0d, got ID=%0d",
request_id,
rsp.id))
return;
end
waiting_for_response = 0;
endfunction
endclass
This establishes the state model:
IDLE
|
| request accepted
v
WAITING
|
| response accepted
v
IDLE
The missing piece is detecting that the checker has remained in WAITING too long.
Step 4: Add a timeout watchdog
A simple watchdog can monitor the outstanding state and periodically evaluate the deadline.
task run_phase(uvm_phase phase);
forever begin
#10ns;
if (waiting_for_response) begin
if (($time - start_time) > timeout_limit) begin
`uvm_error("TIMEOUT",
$sformatf(
"Response timeout: ID=%0d elapsed=%0t limit=%0t",
request_id,
$time - start_time,
timeout_limit))
waiting_for_response = 0;
end
end
end
endtask
This is useful for demonstrating the concept, but it has an important weakness: the watchdog polling interval affects when the timeout is detected.
If the deadline is 500 ns and the watchdog checks every 10 ns, the error may be reported after the deadline rather than exactly at it.
For a production checker, the timing mechanism should match the precision required by the protocol.
Step 5: Understand why arbitrary #delay timers can be fragile
A tempting implementation is:
task wait_for_response(packet req);
fork
begin
#(TIMEOUT);
`uvm_error("TIMEOUT", "No response")
end
begin
wait_for_response_event(req.id);
end
join_any
disable fork;
endtask
This pattern can be useful in carefully controlled situations, but it becomes difficult when several transactions can be outstanding simultaneously.
For example:
ID=10 accepted at 100 ns
ID=11 accepted at 120 ns
ID=12 accepted at 150 ns
Each transaction has a different deadline. A single global timer cannot represent all three deadlines correctly.
That leads to a more scalable architecture: store timing state per transaction.
Step 6: Track deadlines for out-of-order traffic
This builds directly on Lessons 25 and 26.
Suppose each response is correlated using an ID:
typedef int unsigned id_t;
typedef struct {
time start_time;
time deadline;
} timeout_info_t;
timeout_info_t timeout_by_id[id_t];
When a request is accepted:
timeout_info_t info;
info.start_time = $time;
info.deadline = $time + timeout_limit;
timeout_by_id[req.id] = info;
When the response arrives:
if (!timeout_by_id.exists(rsp.id)) begin
`uvm_error("TIMEOUT_CHK",
$sformatf(
"Response ID=%0d has no outstanding timeout entry",
rsp.id))
end
else begin
timeout_info_t info;
info = timeout_by_id[rsp.id];
if ($time > info.deadline) begin
`uvm_error("TIMEOUT",
$sformatf(
"ID=%0d response arrived late: elapsed=%0t limit=%0t",
rsp.id,
$time - info.start_time,
timeout_limit))
end
timeout_by_id.delete(rsp.id);
end
Now each transaction has an independent deadline.
ID=10 accepted 100 ns deadline 150 ns
ID=11 accepted 120 ns deadline 170 ns
ID=12 accepted 150 ns deadline 200 ns
Responses:
ID=11 160 ns OK
ID=12 190 ns OK
ID=10 175 ns TIMEOUT
The response order does not matter to the timeout calculation.
Step 7: Detect expired transactions independently of responses
Checking the deadline only when a response arrives detects a late response, but it does not immediately detect a response that never arrives.
For missing responses, some process must evaluate outstanding deadlines even when no response traffic is present.
foreach (timeout_by_id[id]) begin
timeout_info_t info = timeout_by_id[id];
if ($time > info.deadline) begin
`uvm_error("TIMEOUT",
$sformatf(
"ID=%0d timed out: deadline=%0t current=%0t",
id,
info.deadline,
$time))
timeout_by_id.delete(id);
end
end
This creates an important distinction:
| Condition | Meaning |
|---|---|
| Expected entry exists | Response is still allowed to arrive. |
| Expected entry exists and deadline has passed | Transaction has timed out. |
| Response arrives before deadline | Transaction completed on time. |
| Response arrives after deadline | Late response; whether it is also an unexpected response depends on checker policy. |
| End of test with outstanding entry | Unresolved transaction; not necessarily proof of a protocol timeout unless its deadline has expired. |
Step 8: Handle late responses deliberately
A subtle design question appears after a timeout:
What should happen if the response eventually arrives?
There are several possible policies:
- remove the timed-out entry and classify the later response as unexpected,
- retain a completed-timeout record so the later response can be identified specifically as late, or
- treat the late response as an additional error while preserving enough history for diagnosis.
The correct policy depends on the verification requirement.
For example, if the specification explicitly says that responses after the deadline are illegal, reporting both the timeout and the late response may be useful. If the timeout itself is the definitive failure and later traffic is expected to become unreliable, retaining limited diagnostic state may be sufficient.
Step 9: Reset must clear timing state
Reset is especially important for timeout logic because timeouts are stateful.
Consider:
100 ns Request ID=25 accepted
120 ns Reset asserted
...
200 ns Timeout checker reports ID=25 timed out
If reset cancels outstanding operations, the timeout at 200 ns is a false failure.
The checker therefore needs an explicit reset policy.
function void reset_checker();
timeout_by_id.delete();
endfunction
Depending on the protocol, reset may instead require preserving some state, marking a new transaction epoch, or waiting for the interface to become operational again.
The important point is that timeout state cannot be left to survive reset accidentally.
Step 10: Do not use one global timeout for unrelated transactions
A common shortcut is:
if (outstanding_count != 0)
start_global_timer();
This is often incorrect when transactions can have different acceptance times, IDs, channels, or timeout requirements.
For example:
Channel A:
ID=1 accepted at 100 ns
timeout = 50 ns
Channel B:
ID=9 accepted at 120 ns
timeout = 500 ns
One global deadline cannot correctly represent both requirements.
Prefer timing state that matches the actual verification rule:
correlation key
|
v
+-----------------------+
| start time |
| deadline |
| timeout requirement |
| optional stream info |
+-----------------------+
If different channels have different timeout policies, include the policy in the transaction-specific state or derive it from configuration.
Step 11: Make timeout failures actionable
A message such as:
UVM_ERROR: timeout
is rarely enough to debug a regression.
A useful timeout report should answer:
- Which transaction timed out?
- Which stream or channel was involved?
- When was it accepted?
- What was the deadline?
- How long had it been outstanding?
- How many other transactions were outstanding?
- What was the relevant protocol state?
For example:
`uvm_error("TIMEOUT",
$sformatf(
"Response timeout: ID=%0d channel=%0d start=%0t deadline=%0t now=%0t outstanding=%0d",
id,
channel,
info.start_time,
info.deadline,
$time,
timeout_by_id.size()))
This turns the timeout into a useful debugging event rather than merely a failure counter increment.
Debugging workflow
- Confirm the acceptance event. Did the monitor actually observe the request being accepted?
- Confirm the correlation key. Is the response supposed to use the same ID or a derived key?
- Check the recorded deadline. Was the correct timeout policy applied?
- Inspect response monitoring. Did the response occur but fail to reach the checker?
- Check reset activity. Was the transaction legitimately cancelled or flushed?
- Inspect protocol backpressure. Was the DUT prevented from completing because the receiver was not ready?
- Inspect the waveform. Look at the relevant request and response handshakes around the deadline.
- Check checker state. Determine whether the timeout entry was created, retained, or deleted correctly.
A timeout can therefore originate from several layers:
Request never accepted
|
+-- monitor/checker boundary
Request accepted
|
+-- DUT never responds
|
+-- DUT responds but response monitor misses it
|
+-- response correlation is wrong
|
+-- reset legitimately cancelled request
|
+-- timeout policy is wrong Exercise 1: Define the timeout correctly
For each scenario, identify the correct start and completion events:
- A request is presented for five cycles before the DUT accepts it.
- A response becomes valid but is not accepted until the receiver asserts
ready. - A transaction is cancelled by reset before the response deadline.
Explain why simply starting a timer when the driver begins driving the request would be incorrect in at least one of these cases.
Exercise 2: Implement per-ID deadlines
Extend an out-of-order scoreboard so that each expected transaction stores:
- ID,
- acceptance time,
- deadline, and
- optional channel or stream information.
Create the following traffic:
ID=10 accepted at 100 ns
ID=11 accepted at 120 ns
ID=12 accepted at 150 ns
Maximum latency = 50 ns
ID=11 response at 160 ns
ID=12 response at 180 ns
ID=10 response never arrives
The checker should identify ID=10 as timed out while accepting the other two responses as on-time.
Exercise 3: Reset during an outstanding transaction
Create a test where:
Request ID=7 accepted
Reset asserted before the deadline
No response for ID=7
Reset released
Verify that the checker does not report a timeout for the cancelled transaction.
Then create a new request after reset and confirm that the new transaction receives a fresh timeout deadline.
Advanced challenge: multiple timeout policies
Build a timeout checker for two streams:
Command stream:
maximum latency = 100 cycles
Data stream:
maximum latency = 20 cycles
Both streams can have multiple outstanding transactions and responses may arrive out of order.
Use a correlation key that distinguishes stream and transaction ID. Store a deadline for every outstanding transaction.
Then test all of these cases:
- on-time response,
- late response,
- missing response,
- duplicate response,
- reset while transactions are outstanding, and
- several transactions timing out at nearly the same time.
Success criterion: every timeout report identifies the correct stream, transaction, acceptance time, deadline, and current outstanding state without confusing one transaction's deadline with another's.
Knowledge check
- Why is an outstanding scoreboard entry not automatically a timeout?
- What should normally define the start of a response timeout?
- What is the difference between a late response and a missing response?
- Why does an out-of-order environment usually require per-transaction timeout state?
- Why can reset create false timeout failures?
- Why is a polling watchdog potentially less precise than a deadline-based mechanism?
- Why should end-of-test outstanding transactions not automatically be classified as timeouts?
Answers
- An outstanding entry means the response is still expected; it becomes a timeout only after its allowed deadline has passed.
- The protocol-defined acceptance event, such as
valid && ready, should normally start the response timer. - A late response arrives after its deadline; a missing response has not arrived by the time the checker determines that the deadline has expired.
- Different transactions are accepted at different times and therefore have different deadlines.
- Reset may legally cancel outstanding operations, so old timeout state must be flushed or otherwise reclassified.
- A polling watchdog checks periodically, so the report can occur after the actual deadline and its resolution depends on the polling interval.
- The test may simply be ending before the protocol's response deadline has expired; Lesson 29 addresses deliberate end-of-test draining.
Key takeaways
- A timeout is a timing requirement applied to an outstanding transaction, not merely an empty response queue.
- Define precise request-acceptance and response-completion events before implementing the timer.
- Use simulation time when the requirement is time-based and cycle counting when the protocol requirement is naturally cycle-based.
- For multiple outstanding transactions, track deadlines independently using the protocol's correlation key.
- Missing responses require an independent mechanism that evaluates expired deadlines; checking only when responses arrive is insufficient.
- Reset must explicitly define what happens to outstanding timeout state.
- Late-response handling should be deliberate so timeout cleanup does not create misleading secondary errors.
- End-of-test draining and timeout detection are related but different problems.
Where this lesson fits
Lesson 27 established how a checker should classify and report failures. Lesson 28 adds time as another dimension of checker state.
Lesson 24 In-order scoreboard
↓
Lesson 25 Out-of-order scoreboard
↓
Lesson 26 Multi-stream scoreboard
↓
Lesson 27 Error handling
↓
Lesson 28 Timeout detection
↓
Lesson 29 End-of-test scoreboard draining
↓
Lesson 30 Debug-friendly diagnostics
The next lesson addresses a related but distinct problem: how a test should finish when transactions are still in flight. A correct environment must distinguish a legitimate drain period from a real missing-response timeout.