Metadata-Version: 2.4
Name: cocotbext-sva
Version: 0.1.0
Summary: SystemVerilog-style immediate and concurrent assertions for cocotb
Author: David Pavlović
License-Expression: MIT
Project-URL: Documentation, https://cocotbext-sva.readthedocs.io
Project-URL: Repository, https://github.com/dpavlo55/cocotbext-sva
Project-URL: Issues, https://github.com/dpavlo55/cocotbext-sva/issues
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: cocotb
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)
Classifier: Topic :: Software Development :: Testing
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: cocotb<3,>=2.0
Provides-Extra: fast
Requires-Dist: cocotbext-sva-kernel; extra == "fast"
Dynamic: license-file

<p align="center">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/dpavlo55/cocotbext-sva/main/docs/_static/logo-dark.svg">
    <img alt="cocotbext-sva" src="https://raw.githubusercontent.com/dpavlo55/cocotbext-sva/main/docs/_static/logo.svg" width="480">
  </picture>
</p>

<p align="center">
  <a href="https://cocotbext-sva.readthedocs.io/en/latest/"><img alt="Documentation" src="https://img.shields.io/readthedocs/cocotbext-sva?logo=readthedocs&logoColor=white&label=docs"></a>
  <a href="https://github.com/dpavlo55/cocotbext-sva/actions/workflows/ci.yml"><img alt="CI" src="https://img.shields.io/github/actions/workflow/status/dpavlo55/cocotbext-sva/ci.yml?branch=main&logo=github&label=CI"></a>
  <a href="https://github.com/dpavlo55/cocotbext-sva/blob/main/LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-blue"></a>
  <img alt="Python 3.10+" src="https://img.shields.io/badge/python-3.10%2B-blue?logo=python&logoColor=white">
  <img alt="cocotb 2.x" src="https://img.shields.io/badge/cocotb-2.x-blue">
</p>

<p align="center">
  <a href="https://cocotbext-sva.readthedocs.io/en/latest/getting-started.html"><img alt="Getting started" src="https://img.shields.io/badge/%F0%9F%9A%80-Getting%20started-7c6fd6"></a>
  <a href="https://cocotbext-sva.readthedocs.io/en/latest/guide/index.html"><img alt="User guide" src="https://img.shields.io/badge/%F0%9F%93%96-User%20guide-7c6fd6"></a>
  <a href="https://cocotbext-sva.readthedocs.io/en/latest/api.html"><img alt="API reference" src="https://img.shields.io/badge/%F0%9F%A7%A9-API%20reference-7c6fd6"></a>
</p>

> **Note:** this package was implemented with [Claude Code](https://claude.com/claude-code),
> and its results were validated against a commercial SVA simulator.

SystemVerilog-style **immediate and concurrent (temporal) assertions** for
[cocotb](https://www.cocotb.org) testbenches, written in SVA syntax. Works
with VHDL and Verilog designs.

Status: alpha (0.1.0, the first release). Requires cocotb 2.x and Python 3.10+.

```python
import cocotb
from cocotb.clock import Clock
from cocotbext.sva import Assertions, checked, posedge

@cocotb.test()
@checked                       # collect failures, fail the test at its end
async def test_handshake(dut):
    Clock(dut.clk, 10, unit="ns").start()
    a = Assertions(dut, clock=posedge(dut.clk), disable_iff="!rst_n", name="hs")
    a.assert_property("req |-> ##[1:3] ack", name="req_gets_ack")
    a.assert_property("(req, t = tag) |-> ##[1:8] (rsp && rsp_tag == t)", name="tag_returns")
    a.cover_property("req ##1 req ##1 req", name="three_reqs")
    ...                         # drive the design
```

A failure is logged at the time it happens, with the attempt's start time and
the sampled values:

```
   150.00ns ERROR    sva.hs.req_gets_ack   FAILED  attempt started 120 ns
                                               req |-> ##[1:3] ack
                                               sampled: req=0  ack=0
```

## Features

- **The SVA property language:** sequences, implications, local variables,
  `$past` and the other sampled-value functions, `always` / `eventually` /
  `until`, `disable iff`, `accept_on`, `cover`, `expect`, immediate
  assertions ([full list](https://cocotbext-sva.readthedocs.io/en/latest/guide/supported-sva.html)).
- **Several clocks:** clocks generated or derived in the HDL (exact SVA
  sampling), and multi-clock properties (`req |=> @(posedge clk_b) ack_b`).
- **Reuse:** parameterised properties, named sequences, checkers bound to
  several instances.
- **Speed:** all attempts of an assertion are merged and evaluated together;
  an optional compiled kernel makes a busy assertion cost about 0.05 µs per
  cycle; idle clocks are not followed at all.
- **`Probe`:** an optional generated HDL module that samples the signals
  inside the simulator and buffers them, for the lowest overhead.
- **Offline checking:** the same assertions on a VCD or FST dump after the
  simulation (`TraceSampler`).

## Install

```bash
pip install cocotbext-sva            # pure Python
pip install cocotbext-sva[fast]      # with the compiled kernel (same results, faster)
```

## Validation

- Tested on nvc, GHDL, Icarus Verilog and Verilator, and on a commercial
  simulator (VHDL and SystemVerilog).
- Results checked against a golden corpus of about 1,200 cases recorded from
  a commercial SVA implementation, and fuzzed against a reference
  interpreter of the IEEE 1800 formal semantics. Where the commercial tool
  and the standard disagree, the package follows the standard; the cases are
  listed in the [notes](https://cocotbext-sva.readthedocs.io/en/latest/notes.html).

## Documentation

The full documentation is at **https://cocotbext-sva.readthedocs.io**:

- [Getting started](https://cocotbext-sva.readthedocs.io/en/latest/getting-started.html):
  a first test with assertions, in five minutes.
- [User guide](https://cocotbext-sva.readthedocs.io/en/latest/guide/index.html): writing assertions,
  clocks and sampling, `Probe`, offline checking, semantics notes, speed.
- [API reference](https://cocotbext-sva.readthedocs.io/en/latest/api.html): every class and function.
- [Notes](https://cocotbext-sva.readthedocs.io/en/latest/notes.html): differences from the
  reference implementation, simulator-specific behaviour, measurements.
- [Design](https://cocotbext-sva.readthedocs.io/en/latest/design.html): architecture.
  [Releasing](https://cocotbext-sva.readthedocs.io/en/latest/release.html).

## Development

```bash
pip install -r requirements.txt
nox -s kernel                # build and install the compiled kernel (needs Rust)
nox -s tests                 # unit tests, fuzzing, golden corpus (no simulator)
nox -s simtests              # end-to-end tests on every simulator found
```

CI runs on GitHub Actions (`.github/workflows`).

License: MIT (see `LICENSE`).
