google / google/xls

[enhancement] Add `#[quickcheck_proc]` to the DLSX

Open
#1,528 1 comment 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)

Currently DSLX has 2 way to test functions:
*`#[test]` - behaves as an function unit test
*`#[quickcheck]` - generates random input that is used to test function.
On the other hand procs have only one test facility: `#[test_proc]` which only acts as an unit test.
Testing proc or a network of procs with random input is extremely challenging and impossible to write in the DSLX.

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

Right now DSLX has no workarounds and requires external solution such as writing external script/program that:
* generates random inputs and expected outputs,
* dumps them into .textproto file
* convert .textproto to dslx file using `proto_to_dslx`
* read DSLX inputs in the test file and use them to stimulate the tested network.

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

My suggestion is to add `[#quickcheck_proc]` annotation,
and proc config function signature will be:
`config(terminator: chan out, random_variable: uN[something])`
matmul_4x4.x already uses integer value in the [config function](https://github.com/google/xls/blob/main/xls/examples/matmul_4x4/matmul_4x4.x#L36-L37)

XLS will only have to supply one random value to the proc, and handling this variable will be defined by the user,
so that user can:
* use it as and acm_random seed,
* directly in the data channel,
* or some other use case.

XLS will run test multiple times and print value of the seed used during [#quickcheck_proc] as it does in the [#quickcheck] tests. XLS will also print a `random_variable` value on the test failure.

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.