Engine API Reference¶
The engine module (tsunami._engine) is a compiled Rust extension. All functions
are re-exported from tsunami directly.
_engine ¶
WaveformHandle ¶
Opaque handle to an opened waveform file.
Created by open(). Pass this handle as the
first argument to all query functions. The underlying waveform data is
memory-mapped and loaded lazily — only the signals you query are read
from disk.
open
builtin
¶
Open an FST or VCD waveform file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path to the waveform file. Format is auto-detected. |
required |
Returns:
| Type | Description |
|---|---|
WaveformHandle
|
A handle to use with all other query functions. |
Raises:
| Type | Description |
|---|---|
PanicException
|
If the file does not exist or cannot be parsed. |
waveform_info
builtin
¶
Get waveform metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handle
|
WaveformHandle
|
Waveform handle from |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict with keys: |
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
list_signals
builtin
¶
List signals matching a glob pattern.
This is typically the first call in any debugging session — use it to discover signal names before querying values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handle
|
WaveformHandle
|
Waveform handle. |
required |
pattern
|
str
|
Glob pattern to match against full hierarchical signal paths.
Supports |
'*'
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
List of dicts, each with keys: |
list[dict[str, Any]]
|
|
list[dict[str, Any]]
|
|
list[dict[str, Any]]
|
|
list[dict[str, Any]]
|
|
list_scopes
builtin
¶
List scopes (hierarchy levels) matching a prefix.
Use this to browse the design hierarchy without listing individual signals.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handle
|
WaveformHandle
|
Waveform handle. |
required |
prefix
|
str
|
Only return scopes whose full path starts with this string.
Use |
''
|
Returns:
| Type | Description |
|---|---|
list[str]
|
List of full scope path strings. |
get_value
builtin
¶
Get a signal's value at a specific time.
For querying multiple signals at the same time, prefer
get_snapshot() which is more efficient.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handle
|
WaveformHandle
|
Waveform handle. |
required |
signal
|
str
|
Full hierarchical signal path (e.g. |
required |
time_ps
|
int
|
Time point to query. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict with keys: |
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the signal path is not found. |
get_snapshot
builtin
¶
Get values of multiple signals at a single time point.
More efficient than calling get_value()
in a loop — signals are loaded in a single batch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handle
|
WaveformHandle
|
Waveform handle. |
required |
signals
|
list[str]
|
List of full signal paths. |
required |
time_ps
|
int
|
Time point to query. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, dict[str, Any]]
|
Dict mapping each signal path to its value dict (same format as |
dict[str, dict[str, Any]]
|
get_transitions
builtin
¶
get_transitions(handle: WaveformHandle, signal: str, t0_ps: int, t1_ps: int, max_edges: int = 1000) -> dict[str, Any]
Get signal transitions (value changes) in a time range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handle
|
WaveformHandle
|
Waveform handle. |
required |
signal
|
str
|
Full signal path. |
required |
t0_ps
|
int
|
Start time (inclusive). |
required |
t1_ps
|
int
|
End time (inclusive). |
required |
max_edges
|
int
|
Maximum number of transitions to return. If the signal
has more transitions in the range, the result is truncated but
|
1000
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict with keys: |
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
find_next_edge
builtin
¶
Find the next edge (value change) on a signal after a given time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handle
|
WaveformHandle
|
Waveform handle. |
required |
signal
|
str
|
Full signal path. |
required |
direction
|
str
|
One of |
required |
after_ps
|
int
|
Search for edges strictly after this time. |
required |
Returns:
| Type | Description |
|---|---|
int | None
|
Time of the next matching edge, or |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
find_first
builtin
¶
Find the first timestamp where a predicate expression is true.
The entire scan runs in Rust in a single pass over the union of transition points of all referenced signals.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handle
|
WaveformHandle
|
Waveform handle. |
required |
expr
|
Any
|
A predicate expression built with the
|
required |
after_ps
|
int
|
Search after this time. |
required |
Returns:
| Type | Description |
|---|---|
int | None
|
Time of the first match, or |
find_all
builtin
¶
Find all timestamps where a predicate expression is true.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handle
|
WaveformHandle
|
Waveform handle. |
required |
expr
|
Any
|
A predicate expression. |
required |
t0_ps
|
int
|
Start of search window. |
required |
t1_ps
|
int
|
End of search window. |
required |
Returns:
| Type | Description |
|---|---|
list[int]
|
List of timestamps where the predicate evaluated to true. |
scan
builtin
¶
Evaluate a predicate at every transition point in a window.
Unlike find_all() which returns only matching
timestamps, scan() returns the evaluated value at each point where the
predicate is true. Useful for building transaction decoders.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handle
|
WaveformHandle
|
Waveform handle. |
required |
expr
|
Any
|
A predicate expression. |
required |
t0_ps
|
int
|
Start of scan window. |
required |
t1_ps
|
int
|
End of scan window. |
required |
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
List of |
summarize
builtin
¶
Summarize a signal over a time window.
Computes statistics entirely in Rust before returning to Python. This is the mechanism that prevents large waveform windows from flooding the context window when used with an LLM.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handle
|
WaveformHandle
|
Waveform handle. |
required |
signal
|
str
|
Full signal path. |
required |
t0_ps
|
int
|
Start time. |
required |
t1_ps
|
int
|
End time. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict with keys: |
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
dict[str, Any]
|
|
summarize_window
builtin
¶
summarize_window(handle: WaveformHandle, signals: list[str], t0_ps: int, t1_ps: int) -> dict[str, dict[str, Any]]
Summarize multiple signals over a time window.
Calls summarize() for each signal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handle
|
WaveformHandle
|
Waveform handle. |
required |
signals
|
list[str]
|
List of signal paths. |
required |
t0_ps
|
int
|
Start time. |
required |
t1_ps
|
int
|
End time. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, dict[str, Any]]
|
Dict mapping each signal path to its summary dict. |
find_anomalies
builtin
¶
find_anomalies(handle: WaveformHandle, signal: str, t0_ps: int, t1_ps: int, expected_period_ps: int | None = None) -> list[dict[str, Any]]
Detect anomalies in a signal's transition pattern.
Looks for three kinds of anomaly:
- glitch: An interval shorter than 25% of the dominant period.
- gap: An interval longer than 200% of the dominant period.
- stuck: No transitions for a long time at the end of the window.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handle
|
WaveformHandle
|
Waveform handle. |
required |
signal
|
str
|
Full signal path. |
required |
t0_ps
|
int
|
Start time. |
required |
t1_ps
|
int
|
End time. |
required |
expected_period_ps
|
int | None
|
Expected period between transitions. If |
None
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
List of anomaly dicts, each with keys: |
list[dict[str, Any]]
|
|
list[dict[str, Any]]
|
|
list[dict[str, Any]]
|
|