Module 8: Protocol Projects | Intermediate UVM

Performance Checking Project

Build a UVM performance checker that measures latency, throughput, and response behavior against explicit requirements.

Learning objectives

  • Distinguish functional correctness from performance correctness.
  • Define measurable latency and throughput requirements for a verification scenario.
  • Collect timestamps from monitored transactions and calculate performance metrics.
  • Report performance violations with enough context to reproduce the scenario.
  • Use assertions and coverage to track performance behavior across a regression.

Step 1: Understand the concept

A DUT can be functionally correct and still fail a performance requirement. For example, a transaction may eventually receive the correct response, but the response may arrive too late. Similarly, a design may produce correct data but fail to sustain the required transaction rate.

Performance verification therefore asks questions such as: How long did the operation take? How many transactions can the DUT sustain? and Did performance remain within the required limits under different conditions?

The most useful metrics are defined before the test is written. Typical measurements include:

  • Latency: time from a defined request event to its corresponding response.
  • Throughput: amount of useful work completed per unit of time.
  • Response rate: number of completed operations over a measurement interval.
  • Queue or service delay: time spent waiting before the DUT begins processing.
  • Maximum latency: worst observed latency for a defined scenario.
Important: do not define performance as simply "fast." Express the requirement as a measurable condition, such as "every response must complete within 20 clock cycles" or "the DUT must sustain at least 100 transactions per measurement interval."

Step 2: Define the performance contract

A performance checker needs clear start and end events. For a request/response protocol, the request monitor might mark the start of an operation and the response monitor might mark its completion.

For example, suppose the requirement is:

Requirement:


Maximum response latency = 20 clock cycles
Minimum throughput      = 1 response every 4 cycles

Start event:
Request accepted by the DUT

End event:
Matching response observed

The matching rule is important. Do not simply pair the next response with the next request unless the protocol guarantees strict ordering. For an out-of-order or tagged protocol, use an identifier to associate each request with its response.

Step 3: Measure latency in the monitor or checker

A monitor can capture the relevant timestamp when a request is observed. When the matching response arrives, the checker calculates the elapsed time.

class performance_checker extends uvm_component;


time request_time[int];

int max_latency_cycles = 20;

function void record_request(int id);
request_time[id] = $time;
endfunction

function void record_response(int id);


time latency;

if (!request_time.exists(id)) begin
  `uvm_error("PERF",
    $sformatf("Response received with no matching request: id=%0d", id))
  return;
end

latency = $time - request_time[id];

if (latency > max_latency_cycles) begin
  `uvm_error("PERF",
    $sformatf("Latency violation: id=%0d latency=%0t limit=%0d",
              id, latency, max_latency_cycles))
end
else begin
  `uvm_info("PERF",
    $sformatf("Latency OK: id=%0d latency=%0t", id, latency),
    UVM_MEDIUM)
end

request_time.delete(id);


endfunction

endclass

This example demonstrates the basic measurement pattern: capture the start event, identify the operation, capture the completion event, calculate the elapsed time, and compare it against a requirement.

In a clock-based design, it is often more useful to measure latency in clock cycles rather than raw simulation time. That makes the requirement less dependent on the simulator time unit and directly relates the measurement to the interface protocol.

Step 4: Check throughput separately

Latency and throughput are related, but they are not the same metric. A DUT might have a latency of 10 cycles while still accepting a new transaction every cycle. Another DUT might have the same latency but only accept one transaction every 8 cycles.

Measure throughput over a defined interval rather than from a single transaction.

int response_count;


int required_responses = 25;

task measure_throughput();

response_count = 0;

repeat (100) @(posedge vif.clk);

if (response_count < required_responses) begin
`uvm_error("PERF",
      $sformatf("Throughput violation: responses=%0d required=%0d",
                response_count, required_responses))
  end
  else begin
    `uvm_info("PERF",
$sformatf("Throughput requirement met: responses=%0d",
response_count),
UVM_LOW)
end

endtask

The exact implementation depends on the protocol and performance requirement. The key principle is to define the measurement window and acceptance criteria explicitly so that different tests produce comparable results.

Step 5: Add performance assertions

Some timing requirements are naturally expressed as SystemVerilog Assertions (SVA). Assertions are particularly useful when the rule is closely tied to clocked interface behavior.

// Example requirement:


// Once a request is accepted, a response must occur
// no later than 20 clock cycles later.

property response_within_limit;
@(posedge clk)
request_accepted |-> ##[1:20] response_valid;
endproperty

assert property (response_within_limit)
else $error("Performance violation: response exceeded latency limit");

Use assertions for local temporal rules and UVM components for measurements that require transaction context, matching IDs, accumulated statistics, or more detailed reporting. These approaches complement rather than replace one another.

Step 6: Build the project incrementally

  1. Define the requirement. Write down the latency, throughput, or response-rate limit before implementing the checker.
  2. Identify measurement points. Decide exactly which observed event starts and ends each measurement.
  3. Implement one latency check. Start with a deterministic request/response scenario.
  4. Add context to failures. Report the transaction ID, measured value, limit, test name, and useful configuration.
  5. Add throughput measurement. Use a clearly defined measurement interval and sufficient traffic to make the result meaningful.
  6. Add assertions. Express simple clock-based timing requirements directly as temporal properties.
  7. Stress the design. Repeat measurements with different traffic patterns, payloads, idle gaps, and configuration states.
  8. Collect coverage. Track which performance scenarios and operating conditions have actually been measured.

Step 7: Make failures reproducible

Performance failures are often sensitive to traffic patterns and randomization. A useful performance report should therefore contain enough information to reproduce the measurement.

`uvm_error("PERF",


$sformatf(
"test=%s id=%0d latency=%0d cycles limit=%0d load=%0d",
get_full_name(),
transaction_id,
measured_latency,
max_latency_cycles,
outstanding_transactions
))

When a regression finds a violation, preserve the random seed, test name, configuration, traffic pattern, and relevant performance measurements. Then rerun the smallest scenario that still reproduces the violation.

Step 8: Cover performance conditions

Performance results can change significantly depending on operating conditions. Useful coverage dimensions may include:

  • Light, medium, and heavy traffic.
  • Different request and response sizes.
  • Different numbers of outstanding transactions.
  • Idle gaps versus back-to-back traffic.
  • Different configuration or operating modes.
  • Minimum, typical, and maximum observed latency.

A performance coverage model should answer whether important operating conditions have been measured—not merely whether the test ran successfully.

Performance versus functional checking

Question Functional check Performance check
Is the response correct? Yes Not necessarily
Did the response arrive on time? Usually not the primary focus Yes
Was required throughput achieved? Usually not Yes
Was the transaction protocol legal? Yes May be relevant

A strong verification environment combines both. Passing a functional scoreboard does not prove that the DUT satisfies its performance requirements.

Try it yourself

Build a small performance-checking environment for a request/response interface. Use the following project requirements:

  1. Maximum response latency: 20 clock cycles.
  2. Measure at least 25 completed transactions.
  3. Record the minimum, maximum, and average observed latency.
  4. Generate a UVM error when the maximum latency requirement is violated.
  5. Add one SVA property for the latency requirement.
  6. Run both light traffic and back-to-back traffic.
  7. Record the seed and configuration whenever a performance check fails.

As an extension, deliberately add an artificial delay to the DUT or test configuration. Confirm that the checker detects the violation and that the resulting log contains enough information to reproduce it.

Key takeaways

  • Performance verification requires measurable requirements, not vague goals such as "fast enough."
  • Latency measures the time for an operation; throughput measures how much work the system can sustain.
  • Use transaction IDs or protocol-defined ordering rules when matching requests with responses.
  • Use UVM checkers for contextual measurements and SVA for concise clock-based timing rules.
  • Performance failures should report the measured value, requirement, transaction context, and reproduction information.
  • Measure performance under multiple traffic and configuration conditions and track those conditions with coverage.