[Verification 7] Measuring AXI Bus Throughput Automatically from FSDB Waveforms

Start (AW handshake) and end (B handshake) of AXI write transactions, and the measurement window

Written by

in

If functional verification asks "does it work correctly", performance verification asks "does it work fast enough". When you attach a high-speed interface IP such as USB, PCIe or Ethernet to an SoC, you need to check how much data that IP actually moves over the system bus (AXI).

You could open the waveforms after the simulation, count the transactions, measure the time and compute the throughput by hand. But with dozens of tests and dozens of configurations, that is not a job for a person. This post shows how to compute bus throughput automatically from waveform files (FSDB).


What is throughput calculated from?

Throughput is simple.

Throughput = amount of data transferred ÷ time taken

The question is how to extract those two values from the waveforms. For AXI, they can be defined like this.

The amount of data in one transaction

The number of bytes one AXI burst carries is set by two signals on the address channel.

Signal Meaning Value
AxLEN Burst length Actual number of beats = AxLEN + 1
AxSIZE Size of one beat Actual number of bytes = 2^AxSIZE

Bytes per burst = (AxLEN + 1) × 2^AxSIZE

For example, with AWLEN = 15 and AWSIZE = 3, that is 16 beats × 8 bytes = 128 bytes.

Start and end of a transaction

Start (AW handshake) and end (B handshake) of AXI write transactions, and the measurement window
Figure 1. An AXI write starts with the handshake on the address (AW) channel and ends with the handshake on the write response (B) channel. A read starts with the AR handshake and ends with the R handshake that carries RLAST. The measurement window runs from the first start to the last end.
Direction Start End
Write AWVALID && AWREADY BVALID && BREADY
Read ARVALID && ARREADY RVALID && RREADY && RLAST

Every AXI transfer happens when VALID and READY are both 1 on the same clock edge, so checking this condition at every clock is enough.


Designing for reuse: signal names go in a config file

Every IP has different signal names and hierarchy paths. If the script hard-codes the names, you have to edit it every time the IP changes. So move which signals to watch into a JSON config file, and let the script do only the calculation.

{
  "ip": "my_ip",
  "fsdb_path": "run_bulk_out_256k.fsdb",
  "hier_path": "tb_top.u_dut.u_axi_master",
  "bus_clock": "4ns",
  "data_size": {
    "interface": "AXI",
    "signal": [
      { "dir": "write", "burst_length": "awlen", "burst_size": "awsize" },
      { "dir": "read",  "burst_length": "arlen", "burst_size": "arsize" }
    ]
  },
  "signal": [
    {
      "dir": "write",
      "name": [
        { "point": "start", "signal": ["awvalid", "awready"],
          "opt_value": [ { "signal": "awaddr", "value": "0x80000000" } ] },
        { "point": "end",   "signal": ["bvalid", "bready"], "opt_value": [] }
      ]
    },
    {
      "dir": "read",
      "name": [
        { "point": "start", "signal": ["arvalid", "arready"], "opt_value": [] },
        { "point": "end",   "signal": ["rvalid", "rready", "rlast"], "opt_value": [] }
      ]
    }
  ]
}
Field Meaning
fsdb_path Waveform file to analyze
hier_path Hierarchy path where the signals live (prepended to build full names)
bus_clock Bus clock period
data_size.interface AXI computes from the burst signals; APB takes constants
signal[].name[].signal The moment these signals are all 1 counts as start/end
opt_value Conditions that narrow the start point (e.g. only transfers to a specific address)

Why opt_value is needed

Besides actual data transfers, an IP generates many other transactions, such as register accesses, descriptor reads and interrupt handling. If what you want to measure is only data going to a specific buffer, you need to filter by address to get an accurate number.

Buses without bursts, such as APB

APB has no bursts, so give the burst information as constants. For a 32-bit bus, for example, set "burst_length": "1" and "burst_size": "32" (bits), and use PSEL && PENABLE && PWRITE as the start and PENABLE as the end.


The calculation

However you read the waveforms, the calculation itself only needs a list of signal values sampled at every clock edge. Here is the core logic.

from dataclasses import dataclass

@dataclass
class Sample:
    t: int          # time (ps, for example)
    sig: dict       # {"awvalid": 1, "awready": 1, "awlen": 15, ...}

def all_high(s, names):
    return all(s.sig.get(n, 0) == 1 for n in names)

def match_opt(s, opts):
    return all(s.sig.get(o["signal"]) == int(o["value"], 0) for o in opts)

def throughput(samples, start, end, length_sig, size_sig, min_len=0):
    """
    samples   : list of Samples taken at every rising clock edge (in time order)
    start/end : start/end definitions from the config ({"signal": [...], "opt_value": [...]})
    min_len   : bursts shorter than this are left out of the data count (filters control transfers)
    """
    total_bytes, t_first, t_last, n = 0, None, None, 0
    for s in samples:
        if all_high(s, start["signal"]) and match_opt(s, start["opt_value"]):
            beats = s.sig[length_sig] + 1           # AxLEN + 1
            if beats >= min_len:
                total_bytes += beats * (1 << s.sig[size_sig])   # × 2^AxSIZE
                n += 1
                if t_first is None:
                    t_first = s.t
        if all_high(s, end["signal"]) and match_opt(s, end["opt_value"]):
            t_last = s.t

    if n == 0 or t_last is None or t_last <= t_first:
        return None
    seconds = (t_last - t_first) * 1e-12            # ps → s
    return {"transactions": n, "bytes": total_bytes,
            "MB_per_s": total_bytes / seconds / 1e6}

An option that filters out short bursts, like min_len, lets you drop small transfers caused by control or interrupts and look only at the real data transfers. It is convenient to take the direction and minimum burst length as arguments at run time, for example --dir read --strict 4.

💡 This calculation gives the average throughput over the whole measurement window. To see efficiency relative to the bus bandwidth, also print the bus utilization by dividing by the theoretical maximum (bus width (bytes) × clock frequency). If you are curious how the instantaneous throughput changes, split the time into windows and repeat the same calculation.


Reading signal values from the waveforms

FSDB is Synopsys Verdi's compressed waveform format, so an ordinary text parser cannot read it. There are two main approaches.

Approach Pros Cons
Verdi NPI (Native Programming Interface) Reads FSDB directly. Python bindings available. Fast even on large files Needs a Verdi license; see the Verdi documentation for the API
Dump to VCD, then parse Standard text format, can be parsed in any language Files get very large, dumping takes longer

With NPI you can read, in order, the times at which values change and the values for signals under a given hierarchy. Align those to the bus clock edges to build the Sample list above, and the rest uses the same calculation. Keeping waveform reading separate from the calculation like this also makes it easy to switch to another waveform format or tool later.


Tips for using it

  • Attach it to the regression: run it automatically after every performance test and collect the results in a table, and you will know right away when an RTL change makes performance drop.
  • Compare with the expected value: put the target throughput from the spec into the config file and mark the test FAIL if it falls short.
  • Look at reads and writes separately: when traffic in both directions is mixed, they affect each other, so calculate per direction.
  • Dump only the signals you need: the throughput calculation needs just a few bus signals. Dumping only that hierarchy instead of everything makes the simulation faster and the file smaller.

Summary

  • Throughput = amount of data ÷ time. In AXI, get the amount of data from (AxLEN+1) × 2^AxSIZE, and the start and end from VALID && READY handshakes.
  • Move signal names and hierarchy into a JSON config so it can be reused per IP.
  • Use address conditions (opt_value) and a minimum burst length to pick out only what you want to measure.
  • Read FSDB with Verdi NPI, and keep the calculation separate from the waveform format.

Further reading

Verification (8 posts)

  1. Verilog Testbenches: From Writing One to Waveform Debugging
  2. Getting Started with UVM: Structure, Phases, a Minimal Example and Verdi Debugging
  3. Functional Coverage in Practice: How to Write a covergroup
  4. Random Numbers for Verification Engineers: PRNGs and Random Stability
  5. Designing Verification Logs and Error Messages: Levels, Severity and Message IDs
  6. 3 SystemVerilog Portability Traps: VCS vs Xcelium
  7. Measuring AXI Bus Throughput Automatically from FSDB Waveforms Reading now
  8. Seeing Gate Shapes in Verdi Netlist Schematics

See the full Tech Notes index

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *