google / google/xls

Enhance C++ testing ergonomics of DSLX code

Open
#851 4 comments 1 reaction 1 assignee Claimed by @allight View on GitHub
dslx enhancement
Dominant language
C++
Stars
1.9k
Forks
283
Avg merge
2d 10h
Merged PRs (30d)
135

Description

DSLX test capability is limited due to the limited expressibility of the language relative to software languages. In particular, DSLX-based testing of procs is especially awkward. DSLX test features could be added/enhanced à la SystemVerilog or nontrivial testing could be shifted to another language like C++. I'd advocate leaning on C++ to do complex testing to avoid feature bloat in DSLX. Below is an example of what a C++ based testbench could look like:

DSLX to test:

```
struct Foo {
bar: u17,
baz: s44
}

struct ProcState {
a: bool,
b: u32
}

proc MyProc {
c0: chan in;
c1: chan out;
...
}
```

Spitballing what a C++ test might look like below. The generated header defines all the necessary types to make things easy.

```C++
#include "my_proc.h" // auto-generated header

MyProc proc;
Foo input = { .bar=DslxBits<17>(10), .baz=DslxSBits<44>(123) };
proc.GetChannel("c0").Write(input);
proc.Tick();
EXPECT_EQ(proc.GetChannel("c1").Read(), DslxBits<42>(444));
EXPECT_TRUE(proc.GetChannel("c1").empty());
EXPECT_EQ(proc.GetState(), ProcState {.a=DslxBits<1>(true), .b=DslxBits<32>(44)};
```

It might be good to support some of the features in the IR-level Proc runtime [interpreter/proc_runtime.h](https://github.com/google/xls/blob/main/xls/interpreter/proc_runtime.h) like `TickUntilOutput`, `TickUntilBlocked`., etc.

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.