DSLX should be able to infer parameters from channel types
- Dominant language
- C++
- Stars
- 1.9k
- Forks
- 283
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 135
Description
It is possible to infer parameters in functions based on the type of the argument passed to the function. This is showcased in file [derived_parametrics_fn.x](https://github.com/antmicro/xls/blob/01c4b35caf19c387d167b072872a01462fef829a/xls/examples/derived_parametrics_fn.x) that can be tested with: `bazel run //xls/examples:derived_parametrics_fn_dslx_test`.
Unfortunately, something similar is not possible for procs.
We wanted to infer proc parameters based on the type of the channel but it looks like it is not supported. It is demonstrated in [derived_parametrics_proc.x](https://github.com/antmicro/xls/blob/01c4b35caf19c387d167b072872a01462fef829a/xls/examples/derived_parametrics_proc.x) file and can be tested with: `bazel run //xls/examples:derived_parametrics_proc_dslx_test`. Attempt to run this example resulted in the following error message:
```
ERROR: /data/work/google-xls/xls/xls/examples/BUILD:801:17: Parsing and type checking DSLX source files of target derived_parametrics_proc_dslx failed: (Exit 255): bash failed: error executing command (from target //xls/examples:derived_parametrics_proc_dslx) /bin/bash -c ... (remaining 1 argument skipped)
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
xls/examples/derived_parametrics_proc.x:31:40-31:47
0029: let (data8_s, data8_r) = chan;
0030: let (data32_s, data32_r) = chan;
0031: spawn derived_parametrics_proc(data8_r, data32_s);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^-----^ XlsTypeError: chan(uN[PARAM_B], dir=in) vs chan(uN[8], dir=in): Mismatch between parameter and argument types (after instantiation).
0032: (terminator, data8_s, data32_r)
0033: }
Error parsing and type checking DSLX source file: xls/examples/derived_parametrics_proc.x
```
The code for reproducing the issue is available [here](https://github.com/antmicro/xls/tree/issue-proc-parametrics-inference)
Contributor guide
Assessment
This issue has not been assessed yet.