google / google/xls

[enhancement] enable glass-box testing of functions

Open
#1,569 2 comments 0 reactions 0 assignees View on GitHub
dslx enhancement testing
Dominant language
C++
Stars
1.9k
Forks
283
Avg merge
2d 10h
Merged PRs (30d)
135

Description

### What's hard to do? (limit 100 words)

Due to the lack of interactive DSLX debugger when troubleshooting a logic issue in a `fn` developers can't really introspect value of intermediate let bindings for a given set of input.

Comparatively this is something possible to do w/ verilog simulator (e.g: `iverilog`) as they allow to assert or dump internal wires of the DUT's module instance.

### Current best alternative workaround (limit 100 words)

Developers can add temporary `trace_fmt!` statement to display intermediate value for a given test or `assert` invariant that holds true for any inputs.

### Your view of the "best case XLS enhancement" (limit 100 words)

It would be nice to able to surface intermediate value of let bindings to the caller `#[test]` functions.

This could take the form a `probe!` macros that would record the value of intermediate signals in the interpreter and surface them to tests, ex:
```
fn muladd(a: u8, b: u8, c: u8) -> u8 {
let p = a * b;
probe!("product", p);
let s = p + c;
probe!("sum", p);
}

#[test(with_probes=1)]
fn muladd_test(a: u8, b: u8, c: u8) -> u8 {
let (result, probes) = muladd(u8:1, u8:2, u8:3);
let (product, sum) = probes;
assert_eq(product.name, "product");
assert_eq(product.value , u8:2);
assert_eq(sum.name, "sum");
assert_eq(sum.value, u8: 5);
assert_eq(result, sum.value);
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.